JBoss Tools SVN: r26226 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui: marker and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2010-11-03 10:14:14 -0400 (Wed, 03 Nov 2010)
New Revision: 26226
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
https://jira.jboss.org/browse/JBIDE-5134
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-11-03 14:10:08 UTC (rev 26225)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-11-03 14:14:14 UTC (rev 26226)
@@ -387,8 +387,11 @@
public static String ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE;
public static String CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE;
+
public static String ADD_SETTER_MARKER_RESOLUTION_TITLE;
+ public static String ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java 2010-11-03 14:14:14 UTC (rev 26226)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.marker;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.preferences.SeamPreferencesMessages;
+import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
+
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddNewSeamRuntimeMarkerResolution implements IMarkerResolution2{
+ private IProject project;
+ private String runtimeName;
+ private String label;
+
+ private SeamRuntimeListFieldEditor seamRuntimes;
+
+ public AddNewSeamRuntimeMarkerResolution(IMarker marker){
+ project = (IProject)marker.getResource();
+
+ IEclipsePreferences preferences = SeamCorePlugin.getSeamPreferences(project);
+
+ runtimeName = preferences.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,"");
+ this.label = MessageFormat.format(SeamUIMessages.ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE, new Object[]{runtimeName});
+ seamRuntimes = new SeamRuntimeListFieldEditor(
+ "rtlist", SeamPreferencesMessages.SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES, new ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ Composite root = new Composite(shell, SWT.NONE);
+ root.setVisible(false);
+ seamRuntimes.getEditorControls(root);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ if(marker.getResource() instanceof IProject){
+ String runtimeVersion = "";
+
+ try{
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(ISeamFacetDataModelProperties.SEAM_FACET_ID);
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject!=null) {
+ IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(facet);
+ if(facetVersion!=null){
+ runtimeVersion = SeamVersion.parseFromString(facetVersion.getVersionString()).toString();
+ }
+ }
+ }catch(CoreException ex){
+ SeamGuiPlugin.getPluginLog().logError(ex);
+ }
+
+ seamRuntimes.getAddAction().run(runtimeName, runtimeVersion);
+
+ for (SeamRuntime rt : seamRuntimes.getAddedSeamRuntimes()) {
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ }
+ SeamRuntimeManager.getInstance().save();
+ }
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+}
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddNewSeamRuntimeMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java 2010-11-03 14:10:08 UTC (rev 26225)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/MarkerResolutionGenerator.java 2010-11-03 14:14:14 UTC (rev 26226)
@@ -45,7 +45,7 @@
public IMarkerResolution[] getResolutions(IMarker marker) {
if(findResolutions(marker))
- return new IMarkerResolution[] { new SeamRuntimeMarkerResolution() };
+ return new IMarkerResolution[] { new SeamRuntimeMarkerResolution(), new AddNewSeamRuntimeMarkerResolution(marker) };
else
return new IMarkerResolution[]{};
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-11-03 14:10:08 UTC (rev 26225)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-11-03 14:14:14 UTC (rev 26226)
@@ -203,3 +203,4 @@
ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE=Add @Destroy annotated method
CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE=Change scope to ''{0}''
ADD_SETTER_MARKER_RESOLUTION_TITLE=Add setter for ''{0}'' property in ''{1}'' class
+ADD_NEW_SEAM_RUNTIME_MARKER_RESOLUTION_TITLE=Add ''{0}'' Seam Runtime
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2010-11-03 14:10:08 UTC (rev 26225)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2010-11-03 14:14:14 UTC (rev 26226)
@@ -108,6 +108,8 @@
private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
private List<SeamRuntime> removed = new ArrayList<SeamRuntime>();
+
+ private AddAction addAction;
// ------------------------------------------------------------------------
// Constructors
@@ -127,6 +129,12 @@
Object defaultValue) {
super(name, label, defaultValue);
}
+
+ public AddAction getAddAction(){
+ if(addAction == null)
+ addAction = new AddAction();
+ return addAction;
+ }
/**
* TBD
@@ -334,7 +342,7 @@
protected void createActionBar() {
actionPanel = new ActionPanel(root, new BaseAction[] {
- new AddAction(), new EditAction(), new RemoveAction()});
+ getAddAction(), new EditAction(), new RemoveAction()});
tableView.addSelectionChangedListener(actionPanel);
}
@@ -1024,6 +1032,21 @@
tableView.refresh();
setDefaultRuntimes();
}
+
+ public void run(String name, String version) {
+ SeamRuntimeNewWizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) getValue(), added);
+
+ wiz.page1.name.setValue(name);
+
+ wiz.page1.version.setValue(version);
+
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntimes();
+ }
}
/**
13 years, 6 months
JBoss Tools SVN: r26225 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-11-03 10:10:08 -0400 (Wed, 03 Nov 2010)
New Revision: 26225
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
Log:
removed system.out messages
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-11-03 13:32:42 UTC (rev 26224)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java 2010-11-03 14:10:08 UTC (rev 26225)
@@ -109,7 +109,6 @@
}
public void setUrl(String url) {
- System.err.println("url set to: " + url);
getPropertyChangeSupport().firePropertyChange(PROPERTY_URL, this.url, this.url = url);
}
@@ -118,7 +117,6 @@
}
public void setType(DeltaCloudClient.DeltaCloudType cloudType) {
- System.err.println("cloud type set to " + cloudType);
getPropertyChangeSupport().firePropertyChange(PROPERTY_TYPE, this.cloudType, this.cloudType = cloudType);
}
}
13 years, 6 months
JBoss Tools SVN: r26224 - trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2010-11-03 09:32:42 -0400 (Wed, 03 Nov 2010)
New Revision: 26224
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
Log:
JBIDE-6655 ModeShape Servers view Edit Server dialog description misleading. Changed dialog description to "Define the URL and authentication details for this ModeShape server instance."
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-03 12:51:41 UTC (rev 26223)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-03 13:32:42 UTC (rev 26224)
@@ -147,7 +147,7 @@
serverPageAuthenticationGroupTitle = Authentication
serverPageInvalidServerProperties = Cannot construct a server because all server properties are not valid
-serverPageOkStatusMsg = Define the server information where the ModeShape repositories are located.
+serverPageOkStatusMsg = Define the URL and authentication details for this ModeShape server instance.
serverPagePasswordLabel = Password:
serverPagePasswordToolTip = The password used to authenticate the user when connecting to the server
serverPageSavePasswordButton = Save password
13 years, 6 months
JBoss Tools SVN: r26223 - trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/tools.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-11-03 08:51:41 -0400 (Wed, 03 Nov 2010)
New Revision: 26223
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/tools/hibernate-tools.jar
Log:
JBIDE-7488
MySQLMetaDataDialect should use "catalog" but not "schema" as db_name
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/tools/hibernate-tools.jar
===================================================================
(Binary files differ)
13 years, 6 months
JBoss Tools SVN: r26222 - trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-11-03 08:21:37 -0400 (Wed, 03 Nov 2010)
New Revision: 26222
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GlobalUsageSettingsTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/HttpRemotePropertiesTest.java
Log:
[JBIDE-7474] switched to plugin logger adapter which does not log if tracing is not enabled
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GlobalUsageSettingsTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GlobalUsageSettingsTest.java 2010-11-03 12:14:35 UTC (rev 26221)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GlobalUsageSettingsTest.java 2010-11-03 12:21:37 UTC (rev 26222)
@@ -110,7 +110,7 @@
@Override
protected IPropertiesProvider createRemoteMap(String url, char valueDelimiter, Plugin plugin,
String... keys) {
- return new HttpRemotePropertiesProvider(url, valueDelimiter, plugin, keys) {
+ return new HttpRemotePropertiesProvider(url, valueDelimiter, new SystemOutLogger(), keys) {
@Override
protected InputStreamReader request(HttpURLConnection urlConnection)
throws UnsupportedEncodingException {
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/HttpRemotePropertiesTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/HttpRemotePropertiesTest.java 2010-11-03 12:14:35 UTC (rev 26221)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/HttpRemotePropertiesTest.java 2010-11-03 12:21:37 UTC (rev 26222)
@@ -55,7 +55,7 @@
final String stringValue, final String anotherValue, char valueDelimiter, String... keys) {
return new HttpRemotePropertiesProvider("http://dummy", valueDelimiter,
- JBossToolsUsageTestActivator.getDefault(), keys) {
+ new SystemOutLogger(), keys) {
@Override
protected InputStreamReader request(HttpURLConnection urlConnection)
throws UnsupportedEncodingException {
13 years, 6 months
JBoss Tools SVN: r26221 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-11-03 08:14:35 -0400 (Wed, 03 Nov 2010)
New Revision: 26221
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
Log:
[JBDS-1373] cleanup: added comments, removed commented code
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java 2010-11-03 11:48:16 UTC (rev 26220)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java 2010-11-03 12:14:35 UTC (rev 26221)
@@ -17,6 +17,9 @@
import org.osgi.framework.Bundle;
/**
+ * Emulates a Firefox Browser User-Agent String but reports eclipse related
+ * informations.
+ *
* @author Andre Dietisheim
*/
public class EclipseUserAgent implements IEclipseUserAgent {
@@ -70,17 +73,6 @@
String productId = getApplicationName();
String productVersion = getApplicationVersion();
- /**
- * Google API for android: this.userAgent = String.format(
- * "GoogleAnalytics/%s (Linux; U; Android %s; %s-%s; %s; Build/%s)" ,
- * new Object[] { "1.0" , Build.VERSION.RELEASE ,
- * (localLocale.getLanguage() != null) ?
- * localLocale.getLanguage().toLowerCase() : "en" ,
- * (localLocale.getCountry() != null) ?
- * localLocale.getCountry().toLowerCase() : "" , Build.MODEL, Build.ID
- * });
- */
-
return MessageFormat.format(
getUserAgentPattern(getOS())
, productId
@@ -101,11 +93,11 @@
private String getUserAgentPattern(String os) {
String userAgentPattern = ""; //$NON-NLS-1$
if (Platform.OS_LINUX.equals(os)) {
- return USERAGENT_LINUX; //$NON-NLS-1$
+ return USERAGENT_LINUX;
} else if (Platform.OS_MACOSX.equals(os)) {
- return USERAGENT_MAC; //$NON-NLS-1$
+ return USERAGENT_MAC;
} else if (Platform.OS_WIN32.equals(os)) {
- return USERAGENT_WIN; //$NON-NLS-1$
+ return USERAGENT_WIN;
}
return userAgentPattern;
}
@@ -137,5 +129,4 @@
return Platform.getBundle(ECLIPSE_RUNTIME_BULDEID);
}
}
-
}
13 years, 6 months
JBoss Tools SVN: r26220 - in trunk/jst/plugins/org.jboss.tools.jst.jsp: src/org/jboss/tools/jst/jsp/bundle and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-11-03 07:48:16 -0400 (Wed, 03 Nov 2010)
New Revision: 26220
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
Log:
https://jira.jboss.org/browse/JBIDE-7381 , While creating new resource bundle Externalize String Dialog will suggest to select several way to register this bundle in the web application (or web page).
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2010-11-03 11:48:16 UTC (rev 26220)
@@ -59,3 +59,4 @@
org.eclipse.ui
Bundle-Version: 3.2.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.jboss.tools.jsf.model.pv
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -196,13 +196,15 @@
if(entry == null){
if (hasJsfProjectNatureType()) {
- IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
- XModel model = EclipseResourceUtil.getModelNature(project).getModel();
- String prefix2 = prefix;
- if(propertyName != null && prefix != null) {
- prefix2 = prefix + "." + propertyName; //$NON-NLS-1$
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ XModel model = EclipseResourceUtil.getModelNature(project).getModel();
+ String prefix2 = prefix;
+ if(propertyName != null && prefix != null) {
+ prefix2 = prefix + "." + propertyName; //$NON-NLS-1$
+ }
+ WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_BEAN_OPEN, prefix2, null);
}
- WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_BEAN_OPEN, prefix2, null);
}
return false;
}
@@ -213,12 +215,13 @@
p.put(WebPromptingProvider.KEY, propertyName);
if (locale != null) p.put(WebPromptingProvider.LOCALE, locale);
p.put(WebPromptingProvider.FILE, ((IFileEditorInput)editor.getEditorInput()).getFile().getProject());
-
- IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
- XModel model = EclipseResourceUtil.getModelNature(project).getModel();
-
- WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_OPEN_KEY, entry.uri, p);
- String error = p.getProperty(WebPromptingProvider.ERROR);
+ String error = null;
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ XModel model = EclipseResourceUtil.getModelNature(project).getModel();
+ WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_OPEN_KEY, entry.uri, p);
+ error = p.getProperty(WebPromptingProvider.ERROR);
+ }
return (error == null || error.length() == 0);
}
return false;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -13,6 +13,12 @@
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jsf.model.pv.JSFProjectTreeConstants;
+import org.jboss.tools.jsf.model.pv.JSFProjectsRoot;
+import org.jboss.tools.jsf.model.pv.JSFProjectsTree;
+import org.jboss.tools.jst.web.model.pv.WebProjectNode;
import org.w3c.dom.Element;
/**
@@ -50,5 +56,34 @@
}
return isSelectionCorrect;
}
-
+
+ public static XModelObject findFacesConfig(XModel model) {
+ XModelObject facesConfig = null;
+ JSFProjectsRoot root = JSFProjectsTree.getProjectsRoot(model);
+ if (root != null) {
+ WebProjectNode n = (WebProjectNode) root
+ .getChildByPath(JSFProjectTreeConstants.CONFIGURATION);
+ if (n != null) {
+ /*
+ * The array contains the all configuration files in the project
+ * including files from jar archives.
+ * Only editable object is be the necessary faces-config file.
+ */
+ XModelObject[] os = n.getTreeChildren();
+ for (XModelObject o : os) {
+ if (o.isObjectEditable()) {
+ facesConfig = o;
+ break;
+ }
+ }
+ }
+ }
+ /*
+ * When nothing has been found try the last straight-forward way.
+ */
+ if (facesConfig == null) {
+ facesConfig = model.getByPath("/faces-config.xml"); //$NON-NLS-1$
+ }
+ return facesConfig;
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -13,30 +13,58 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.common.model.ui.editors.dnd.DropURI;
+import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
+import org.jboss.tools.jst.jsp.jspeditor.SourceEditorPageContext;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.URIConstants;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class ExternalizeStringsWizard extends Wizard {
- public String ExternalizeStringsWizardPageName = "ExternalizeStringsWizardPage"; //$NON-NLS-1$
- public String NewFileCreationPageName = "NewFileCreationPage"; //$NON-NLS-1$
+ public static final String EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE =
+ "EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE"; //$NON-NLS-1$
ITextEditor editor = null;
BundleMap bm = null;
ExternalizeStringsWizardPage page1 = null;
WizardNewFileCreationPage page2 = null;
+ ExternalizeStringsWizardRegisterBundlePage page3 = null;
public ExternalizeStringsWizard(ITextEditor editor, BundleMap bm) {
super();
@@ -50,13 +78,29 @@
public void addPages() {
super.addPages();
page1 = new ExternalizeStringsWizardPage(
- ExternalizeStringsWizardPageName, editor, bm);
- page2 = new WizardNewFileCreationPage(NewFileCreationPageName,
+ ExternalizeStringsWizardPage.PAGE_NAME, editor, bm);
+ page2 = new WizardNewFileCreationPage(EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE,
(IStructuredSelection) editor.getSelectionProvider().getSelection()) {
protected InputStream getInitialContents() {
return new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
}
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete();
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ /*
+ * Update the status for the next page
+ */
+ page3.updateStatus();
+ return super.getNextPage();
+ }
};
+ page3 = new ExternalizeStringsWizardRegisterBundlePage(
+ ExternalizeStringsWizardRegisterBundlePage.PAGE_NAME);
page2.setTitle(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
page2.setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
page2.setImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
@@ -64,22 +108,37 @@
* https://jira.jboss.org/browse/JBIDE-7247
* Set initial values for the new properties file
*/
- if (editor.getEditorInput() instanceof IStorageEditorInput) {
+ IPath containerFullPath = null;
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ IResource[] src = EclipseUtil.getJavaSourceRoots(project);
+ if (src.length > 0) {
+ containerFullPath = src[0].getFullPath();
+ }
+ } else if (editor.getEditorInput() instanceof IStorageEditorInput) {
try {
- IPath fullPath = ((IStorageEditorInput) editor.getEditorInput()).getStorage().getFullPath();
- page2.setContainerFullPath(fullPath);
+ containerFullPath = ((IStorageEditorInput) editor.getEditorInput()).getStorage().getFullPath();
} catch (CoreException e) {
JspEditorPlugin.getDefault().logError(e);
}
-
}
+ if (null != containerFullPath) {
+ page2.setContainerFullPath(containerFullPath);
+ }
String fileName = editor.getEditorInput().getName();
int pos = fileName.lastIndexOf(Constants.DOT);
if (pos != -1) {
fileName = fileName.substring(0, pos) + Constants.PROPERTIES_EXTENTION;
}
+ /*
+ * Set the file name
+ */
page2.setFileName(fileName);
/*
+ * Set the supported extension
+ */
+ page2.setFileExtension("properties"); //$NON-NLS-1$
+ /*
* The new file should not exist
*/
page2.setAllowExistingResources(false);
@@ -88,17 +147,21 @@
*/
addPage(page1);
addPage(page2);
+ addPage(page3);
}
@Override
public boolean canFinish() {
return (!page1.isNewFile() && page1.isPageComplete())
- || (page1.isNewFile() && page2.isPageComplete());
+ || (page1.isNewFile() && page2.isPageComplete() && page3.isPageComplete()
+ && (getContainer().getCurrentPage() == page3));
}
@Override
public boolean performFinish() {
- if (!page1.isDuplicatedKeyValue()) {
+ String var = page1.getBundlePrefix();
+ String key = page1.getKey();
+ if (!page1.isDuplicatedKeyAndValue()) {
IFile bundleFile = null;
if (page1.isNewFile()) {
bundleFile = page2.createNewFile();
@@ -133,13 +196,159 @@
e.printStackTrace();
}
}
+ /*
+ * Register new resource bundle when new file is created.
+ */
+ if (page1.isNewFile() && !page3.isUserDefined()) {
+ var = page3.getBundleName();
+ if (editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editor.getEditorInput()).getFile().getProject();
+ String userDefinedPath = page2.getContainerFullPath().toString();
+ /*
+ * Get the source folders for the project
+ */
+ IResource[] src = EclipseUtil.getJavaSourceRoots(project);
+ /*
+ * When there are multiple source folders --
+ * match user defined folder to them.
+ */
+ String srcPath = userDefinedPath;
+ String bundlePath = Constants.EMPTY;
+ if (src.length > 1) {
+ for (IResource res : src) {
+ srcPath = res.getFullPath().toString();
+ if (userDefinedPath.indexOf(srcPath) > -1) {
+ break;
+ }
+ }
+ } else if (src.length == 1) {
+ srcPath = src[0].getFullPath().toString();
+ }
+ /*
+ * After the source folder has been found --
+ * generate the bundle path.
+ */
+ if (userDefinedPath.indexOf(srcPath) > -1) {
+ /*
+ * User has selected the folder in the projects's source path.
+ * Replace the beginning
+ */
+ bundlePath = userDefinedPath.replaceFirst(srcPath, "").replaceAll("/", "\\."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ /*
+ * User defined path is different from the source folder.
+ * Thus base-name would be incorrect.
+ * Simply replace slashes with dots
+ */
+ bundlePath = userDefinedPath.replaceAll("/", "\\."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (bundlePath.startsWith(".")) { //$NON-NLS-1$
+ bundlePath = bundlePath.substring(1);
+ }
+ String fileName = page2.getFileName();
+ int pos = fileName.indexOf(Constants.PROPERTIES_EXTENTION);
+ if (pos > -1) {
+ fileName = fileName.substring(0, pos);
+ }
+ if (bundlePath.length() != 0) {
+ bundlePath = bundlePath + Constants.DOT;
+ }
+ bundlePath = bundlePath + fileName;
+ /*
+ * And then decide where to register the resource bundle
+ */
+ if (page3.isInFacesConfig()) {
+ /*
+ * Register new bundle in the faces-config.xml
+ * We should write only correct base-name.
+ * If it is not -- then just skip it. But such a situation
+ * should never happen.
+ */
+ XModel model = EclipseResourceUtil.getModelNature(project).getModel();
+ XModelObject facesConfig = ExternalizeStringsUtils.findFacesConfig(model);
+ XModelObject application = facesConfig.getChildByPath("application"); //$NON-NLS-1$
+ XModelObject resourceBundle = facesConfig.getModel().createModelObject("JSFResourceBundle", null); //$NON-NLS-1$
+ resourceBundle.setAttributeValue("base-name", bundlePath); //$NON-NLS-1$
+ resourceBundle.setAttributeValue("var", var); //$NON-NLS-1$
+ try {
+ DefaultCreateHandler.addCreatedObject(application, resourceBundle, 0);
+ } catch (XModelException e) {
+ JspEditorPlugin.getDefault().logError(
+ "Could not add <resource-bundle> to the faces-config.xml", e); //$NON-NLS-1$
+ }
+ /*
+ * When the faces-config.xml is opened in the editor the following
+ * action should be called to ensure that changes have been applied.
+ */
+ XActionInvoker.invoke("SaveActions.Save", facesConfig, new Properties()); //$NON-NLS-1$
+ } else if (page3.isViaLoadBundle()) {
+ /*
+ * Add <f:loadBundle> tag to the current page.
+ * Insert the tag before currently selected tag.
+ */
+ ISelection sel = editor.getSelectionProvider().getSelection();
+ if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) sel;
+ Object selectedElement = structuredSelection.getFirstElement();
+ if (selectedElement instanceof Node) {
+ Node node = (Node) selectedElement;
+ List<TaglibData> taglibs = null;
+ String jsfCoreTaglibPrefix = "f"; //$NON-NLS-1$
+ boolean isJsfCoreTaglibRegistered = false;
+ if (editor instanceof JSPMultiPageEditor) {
+ StructuredTextEditor ed = ((JSPMultiPageEditor) editor).getSourceEditor();
+ if (ed instanceof JSPTextEditor) {
+ IVisualContext context = ((JSPTextEditor) ed).getPageContext();
+ if (context instanceof SourceEditorPageContext) {
+ SourceEditorPageContext sourcePageContext = (SourceEditorPageContext) context;
+ taglibs = sourcePageContext.getTagLibs();
+ if (null == taglibs) {
+ JspEditorPlugin.getDefault().logError(
+ JstUIMessages.CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT);
+ } else {
+ for (TaglibData tl : taglibs) {
+ if (DropURI.JSF_CORE_URI.equalsIgnoreCase(tl.getUri())) {
+ isJsfCoreTaglibRegistered = true;
+ jsfCoreTaglibPrefix = tl.getPrefix();
+ break;
+ }
+ }
+ if (!isJsfCoreTaglibRegistered) {
+ /*
+ * Register the required taglib
+ */
+ PaletteTaglibInserter PaletteTaglibInserter = new PaletteTaglibInserter();
+ Properties p = new Properties();
+ p.put("selectionProvider", editor.getSelectionProvider()); //$NON-NLS-1$
+ p.setProperty(URIConstants.LIBRARY_URI, DropURI.JSF_CORE_URI);
+ p.setProperty(URIConstants.LIBRARY_VERSION, ""); //$NON-NLS-1$
+ p.setProperty(URIConstants.DEFAULT_PREFIX, jsfCoreTaglibPrefix);
+ p.setProperty(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true"); //$NON-NLS-1$
+ p.setProperty(JSPPaletteInsertHelper.PROPOPERTY_REFORMAT_BODY, "yes"); //$NON-NLS-1$
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT,
+ "<%@ taglib uri=\"http://java.sun.com/jsf/core\" prefix=\"f\" %>\\n"); //$NON-NLS-1$
+ PaletteTaglibInserter.inserTaglib(ed.getTextViewer().getDocument(), p);
+ }
+ }
+ }
+ }
+ }
+ Element loadBundle = node.getOwnerDocument().createElement(
+ jsfCoreTaglibPrefix + Constants.COLON + "loadBundle"); //$NON-NLS-1$
+ loadBundle.setAttribute("var", var); //$NON-NLS-1$
+ loadBundle.setAttribute("basename", bundlePath); //$NON-NLS-1$
+ node.getParentNode().insertBefore(loadBundle, node);
+ }
+ }
+ }
+ }
+ }
}
/*
* Replace text in the editor
*/
- page1.replaceText();
-
+ String replacement = "#{" + var + Constants.DOT + key + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ page1.replaceText(replacement);
return true;
}
-
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -92,6 +92,8 @@
public class ExternalizeStringsWizardPage extends WizardPage {
+ public static final String PAGE_NAME = "ExternalizeStringsWizardBasicPage"; //$NON-NLS-1$
+
private final char[] REPLACED_CHARACTERS = new char[] {'~', '!', '@', '#',
'$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '{', '}', '[', ']', ':', ';', ',', '.', '?', '\\', '/'};
private final char[] LINE_DELEMITERS = new char[] {'\r', '\n', '\t'};
@@ -266,8 +268,192 @@
*/
setControl(composite);
}
+
+ /**
+ * Generate properties key.
+ * Replaces all non-word characters with
+ * underline character.
+ *
+ * @param text the text
+ * @return the result string
+ */
+ public String generatePropertyKey(String text) {
+ String result = text.trim();
+ /*
+ * Replace all other symbols with '_'
+ */
+ for (char ch : REPLACED_CHARACTERS) {
+ result = result.replace(ch, '_');
+ }
+ /*
+ * Replace line delimiters white space
+ */
+ for (char ch : LINE_DELEMITERS) {
+ result = result.replace(ch, ' ');
+ }
+ /*
+ * Replace all white spaces with '_'
+ */
+ result = result.replaceAll(Constants.WHITE_SPACE,
+ Constants.UNDERSCORE);
+ /*
+ * Correct underline symbols:
+ * show only one of them
+ */
+ result = result.replaceAll("_+", Constants.UNDERSCORE); //$NON-NLS-1$
+ /*
+ * Remove leading and trailing '_'
+ */
+ if (result.startsWith(Constants.UNDERSCORE)) {
+ result = result.substring(1);
+ }
+ if (result.endsWith(Constants.UNDERSCORE)) {
+ result = result.substring(0, result.length() - 1);
+ }
+ /*
+ * Return the result
+ */
+ return result;
+ }
/**
+ * Gets the bundle prefix.
+ *
+ * @return the bundle prefix
+ */
+ public String getBundlePrefix() {
+ String bundlePrefix = Constants.EMPTY;
+ if (!isNewFile()) {
+ for (BundleEntry be : bm.getBundles()) {
+ if (be.uri.equalsIgnoreCase(rbCombo.getText())) {
+ bundlePrefix = be.prefix;
+ }
+ }
+ }
+ return bundlePrefix;
+ }
+
+ /**
+ * Gets resource bundle's file
+ * @return the file
+ */
+ public IFile getBundleFile() {
+ return bm.getBundleFile(rbCombo.getText());
+ }
+
+ /**
+ * Use existed key-value pair from the properties file
+ * without writing any data to the file.
+ *
+ * @return
+ */
+ public boolean isDuplicatedKeyAndValue() {
+ boolean exists = false;
+ if (isValueDuplicated(propsValue.getText())
+ && isKeyDuplicated(propsKey.getText())) {
+ exists = true;
+ }
+ return exists;
+ }
+
+ /**
+ * Gets <code>key=value</code> pair
+ *
+ * @return a pair <code>key=value</code>
+ */
+ public String getKeyValuePair() {
+ return propsKey.getText() + Constants.EQUAL + propsValue.getText();
+ }
+
+ /**
+ * Gets the key.
+ *
+ * @return the key
+ */
+ public String getKey() {
+ return propsKey.getText();
+ }
+
+ /**
+ * Check if "Create new file.." option is enabled
+ *
+ * @return the status
+ */
+ public boolean isNewFile() {
+ return newFile.getSelection();
+ }
+
+ /**
+ * Replaces the text in the current file
+ */
+ public void replaceText(String replacement) {
+ IDocumentProvider prov = editor.getDocumentProvider();
+ IDocument doc = prov.getDocument(editor.getEditorInput());
+ ISelection sel = editor.getSelectionProvider().getSelection();
+ if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
+ try {
+ /*
+ * Get source text and new text
+ */
+ TextSelection textSel = (TextSelection) sel;
+ IStructuredSelection structuredSelection = (IStructuredSelection) sel;
+ Object firstElement = structuredSelection.getFirstElement();
+ int offset = 0;
+ int length = 0;
+ /*
+ * When user selection is empty
+ * underlying node will e automatically selected.
+ * Thus we need to correct replacement offsets.
+ */
+ if ((textSel.getLength() != 0)) {
+ offset = textSel.getOffset();
+ length = textSel.getLength();
+ } else if (firstElement instanceof TextImpl) {
+ TextImpl ti = (TextImpl) firstElement;
+ offset = ti.getStartOffset();
+ length = ti.getLength();
+ } else if (firstElement instanceof AttrImpl) {
+ AttrImpl ai = (AttrImpl) firstElement;
+ /*
+ * Get offset and length without quotes ".."
+ */
+ offset = ai.getValueRegionStartOffset() + 1;
+ length = ai.getValueRegionText().length() - 2;
+ }
+ /*
+ * Replace text in the editor with "key.value"
+ */
+ doc.replace(offset, length, replacement);
+ } catch (BadLocationException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ boolean isPageComplete = false;
+ /*
+ * The page is ready when there are no error messages
+ * and the bundle is selected
+ * and "key=value" exists.
+ */
+ if ((getErrorMessage() == null)
+ && !Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim())
+ && !Constants.EMPTY.equalsIgnoreCase(propsValue.getText().trim())
+ && ((rbCombo.getSelectionIndex() != -1) || isNewFile())) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete() && (getNextPage() != null)
+ && isNewFile();
+ }
+
+ /**
* Initialize dialog's controls.
* Fill in appropriate text and make validation.
*/
@@ -596,88 +782,6 @@
}
/**
- * Gets <code>key=value</code> pair
- *
- * @return a pair <code>\nkey=value\n</code>
- */
- public String getKeyValuePair() {
- return propsKey.getText() + Constants.EQUAL + propsValue.getText();
- }
-
- /**
- * Gets resource bundle's file
- * @return the file
- */
- public IFile getBundleFile() {
- return bm.getBundleFile(rbCombo.getText());
- }
-
- /**
- * Check if "Create new file.." option is enabled
- *
- * @return the status
- */
- public boolean isNewFile() {
- return newFile.getSelection();
- }
-
- /**
- * Replaces the text in the current file
- */
- public void replaceText() {
- IDocumentProvider prov = editor.getDocumentProvider();
- IDocument doc = prov.getDocument(editor.getEditorInput());
- ISelection sel = editor.getSelectionProvider().getSelection();
- if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
- try {
- /*
- * Get source text and new text
- */
- TextSelection textSel = (TextSelection) sel;
- IStructuredSelection structuredSelection = (IStructuredSelection) sel;
- Object firstElement = structuredSelection.getFirstElement();
- int offset = 0;
- int length = 0;
- /*
- * When user selection is empty
- * underlying node will e automatically selected.
- * Thus we need to correct replacement offsets.
- */
- if ((textSel.getLength() != 0)) {
- offset = textSel.getOffset();
- length = textSel.getLength();
- } else if (firstElement instanceof TextImpl) {
- TextImpl ti = (TextImpl) firstElement;
- offset = ti.getStartOffset();
- length = ti.getLength();
- } else if (firstElement instanceof AttrImpl) {
- AttrImpl ai = (AttrImpl) firstElement;
- /*
- * Get offset and length without quotes ".."
- */
- offset = ai.getValueRegionStartOffset() + 1;
- length = ai.getValueRegionText().length() - 2;
- }
- /*
- * Replace text in the editor with "key.value"
- */
- String bundlePrefix = Constants.EMPTY;
- if (!isNewFile()) {
- for (BundleEntry be : bm.getBundles()) {
- if (be.uri.equalsIgnoreCase(rbCombo.getText())) {
- bundlePrefix = be.prefix;
- }
- }
- }
- String newText = "#{" + bundlePrefix + Constants.DOT + propsKey.getText() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- doc.replace(offset, length, newText);
- } catch (BadLocationException ex) {
- ex.printStackTrace();
- }
- }
- }
-
- /**
* Update duplicate key status.
*/
private void updateDuplicateKeyStatus() {
@@ -803,29 +907,6 @@
}
}
- @Override
- public boolean isPageComplete() {
- boolean isPageComplete = false;
- /*
- * The page is ready when there are no error messages
- * and the bundle is selected
- * and "key=value" exists.
- */
- if ((getErrorMessage() == null)
- && !Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim())
- && !Constants.EMPTY.equalsIgnoreCase(propsValue.getText().trim())
- && ((rbCombo.getSelectionIndex() != -1) || isNewFile())) {
- isPageComplete = true;
- }
- return isPageComplete;
- }
-
- @Override
- public boolean canFlipToNextPage() {
- return isPageComplete() && (getNextPage() != null)
- && isNewFile();
- }
-
/**
* Creates new bundle map if no one was specified
* during initialization of the page.
@@ -946,68 +1027,6 @@
}
return bm;
}
-
- /**
- * Use existed key-value pair from the properties file
- * without writing any data to the file.
- *
- * @return
- */
- public boolean isDuplicatedKeyValue() {
- boolean exists = false;
- if (isValueDuplicated(propsValue.getText())
- && isKeyDuplicated(propsKey.getText())) {
- exists = true;
- }
- return exists;
- }
-
- /**
- * Generate properties key.
- * Replaces all non-word characters with
- * underline character.
- *
- * @param text the text
- * @return the result string
- */
- public String generatePropertyKey(String text) {
- String result = text.trim();
- /*
- * Replace all other symbols with '_'
- */
- for (char ch : REPLACED_CHARACTERS) {
- result = result.replace(ch, '_');
- }
- /*
- * Replace line delimiters white space
- */
- for (char ch : LINE_DELEMITERS) {
- result = result.replace(ch, ' ');
- }
- /*
- * Replace all white spaces with '_'
- */
- result = result.replaceAll(Constants.WHITE_SPACE,
- Constants.UNDERSCORE);
- /*
- * Correct underline symbols:
- * show only one of them
- */
- result = result.replaceAll("_+", Constants.UNDERSCORE); //$NON-NLS-1$
- /*
- * Remove leading and trailing '_'
- */
- if (result.startsWith(Constants.UNDERSCORE)) {
- result = result.substring(1);
- }
- if (result.endsWith(Constants.UNDERSCORE)) {
- result = result.substring(0, result.length() - 1);
- }
- /*
- * Return the result
- */
- return result;
- }
/**
* Sets the resource bundle path according to the selection
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardRegisterBundlePage.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.i18n;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+
+/**
+ * The Class ExternalizeStringsWizardRegisterBundlePage.
+ */
+public class ExternalizeStringsWizardRegisterBundlePage extends WizardPage
+ implements SelectionListener {
+
+ public static final String PAGE_NAME = "ExternalizeStringsWizardRegisterBundlePage"; //$NON-NLS-1$
+ /*
+ * Constants that indicate user selection
+ */
+ public static final int FACES_CONFIG = 1;
+ public static final int LOAD_BUNDLE = 2;
+ public static final int USER_DEFINED = 3;
+
+ private final int DIALOG_WIDTH = 450;
+ private final int DIALOG_HEIGHT = 650;
+
+ private Button facesConfig;
+ private Button laodBundle;
+ private Button userDefined;
+ private Label bundleLabel;
+ private Text bundleName;
+
+ /**
+ * Instantiates a new externalize strings wizard register bundle page.
+ *
+ * @param pageName the page name
+ */
+ public ExternalizeStringsWizardRegisterBundlePage(String pageName) {
+ super(pageName, JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
+ ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
+ setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
+ setPageComplete(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ /*
+ * Create basic container
+ */
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = DIALOG_WIDTH;
+ gd.heightHint = DIALOG_HEIGHT;
+ composite.setLayoutData(gd);
+ /*
+ * Input field with bundle name
+ */
+ bundleLabel = new Label(composite, SWT.NONE);
+ bundleLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+ bundleLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_BUNDLE_NAME);
+ bundleName = new Text(composite, SWT.BORDER);
+ bundleName.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
+ String fileName = Constants.EMPTY;
+ if (getWizard() instanceof ExternalizeStringsWizard) {
+ fileName = ((ExternalizeStringsWizard) getWizard()).editor
+ .getEditorInput().getName();
+ int pos = fileName.lastIndexOf(Constants.DOT);
+ if (pos != -1) {
+ fileName = fileName.substring(0, pos);
+ }
+ }
+ bundleName.setText(fileName);
+
+ /*
+ * Group with a place for bundle
+ */
+ Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ group.setLayout(new GridLayout(1, true));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ group.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_SAVE_RESOURCE_BUNDLE);
+
+ facesConfig = new Button(group, SWT.RADIO);
+ laodBundle = new Button(group, SWT.RADIO);
+ userDefined = new Button(group, SWT.RADIO);
+ facesConfig.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_FACES_CONFIG);
+ laodBundle.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_LOAD_BUNDLE);
+ userDefined.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_USER_DEFINED);
+
+ userDefined.setSelection(true);
+
+ facesConfig.addSelectionListener(this);
+ laodBundle.addSelectionListener(this);
+ userDefined.addSelectionListener(this);
+
+ updateBundleNameField();
+ /*
+ * Wizard Page control should be initialized.
+ */
+ setControl(composite);
+ }
+
+ /**
+ * Gets the user specified bundle name.
+ *
+ * @return the bundle name
+ */
+ public String getBundleName() {
+ String name = Constants.EMPTY;
+ if (bundleName != null) {
+ name = bundleName.getText();
+ }
+ return name;
+ }
+
+ /**
+ * Checks if user has selected faces config.
+ *
+ * @return true, if in faces config
+ */
+ public boolean isInFacesConfig() {
+ return (null != facesConfig) && facesConfig.getSelection();
+ }
+
+ /**
+ * Checks if user has selected load bundle.
+ *
+ * @return true, if via load bundle
+ */
+ public boolean isViaLoadBundle() {
+ return (null != laodBundle) && laodBundle.getSelection();
+ }
+
+ /**
+ * Checks if user will register the bundle manually.
+ *
+ * @return true, if user defined
+ */
+ public boolean isUserDefined() {
+ return (null != userDefined) && userDefined.getSelection();
+ }
+
+ /**
+ * Update the dialog status.
+ */
+ public void updateStatus() {
+ /*
+ * If user has entered a path that is different from the source folder
+ * the base-name will be incorrect.
+ * Thus show warning message.
+ */
+ if (isSourceFolderSelected()) {
+ setMessage(null, IMessageProvider.NONE);
+ } else {
+ setMessage(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_BUNDLE_PLACEMENT,
+ IMessageProvider.WARNING);
+ }
+ }
+
+ /**
+ * Gets the selected place.
+ *
+ * @return the selected place
+ */
+ private int getSelectedPlace() {
+ int place = FACES_CONFIG;
+ if (isInFacesConfig()) {
+ place = FACES_CONFIG;
+ } else if (isViaLoadBundle()) {
+ place = LOAD_BUNDLE;
+ } else if (isUserDefined()) {
+ place = USER_DEFINED;
+ }
+ return place;
+ }
+
+ /**
+ * Update bundle name field.
+ */
+ private void updateBundleNameField() {
+ if (isUserDefined()) {
+ bundleLabel.setEnabled(false);
+ bundleName.setEnabled(false);
+ } else {
+ bundleLabel.setEnabled(true);
+ bundleName.setEnabled(true);
+ }
+ }
+
+ /**
+ * Checks if the source folder is selected.
+ *
+ * @return true, if the source folder is selected.
+ */
+ private boolean isSourceFolderSelected() {
+ boolean sourceFolderSelected = false;
+ if (getWizard() instanceof ExternalizeStringsWizard) {
+ ExternalizeStringsWizard wiz = (ExternalizeStringsWizard) getWizard();
+ if (wiz.editor.getEditorInput() instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)(wiz.editor.getEditorInput())).getFile().getProject();
+ WizardNewFileCreationPage page2 = (WizardNewFileCreationPage)wiz.getPage(
+ ExternalizeStringsWizard.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE_PAGE);
+ String userDefinedPath = page2.getContainerFullPath().toString();
+ /*
+ * Get the source folders for the project
+ */
+ IResource[] src = EclipseUtil.getJavaSourceRoots(project);
+ /*
+ * When there are multiple source folders --
+ * match user defined folder to them.
+ */
+ String srcPath = Constants.EMPTY;
+ for (IResource res : src) {
+ srcPath = res.getFullPath().toString();
+ if (userDefinedPath.indexOf(srcPath) > -1) {
+ sourceFolderSelected = true;
+ break;
+ }
+ }
+ }
+ }
+ return sourceFolderSelected;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ */
+ public boolean isPageComplete() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ updateBundleNameField();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateBundleNameField();
+ }
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-11-03 11:48:16 UTC (rev 26220)
@@ -158,5 +158,11 @@
public static String EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME;
public static String EXTERNALIZE_STRINGS_DIALOG_SELECT_RESOURCE_BUNDLE;
public static String CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT;
+ public static String EXTERNALIZE_STRINGS_DIALOG_SAVE_RESOURCE_BUNDLE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_FACES_CONFIG;
+ public static String EXTERNALIZE_STRINGS_DIALOG_LOAD_BUNDLE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_USER_DEFINED;
+ public static String EXTERNALIZE_STRINGS_DIALOG_BUNDLE_NAME;
+ public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_BUNDLE_PLACEMENT;
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-11-03 11:45:14 UTC (rev 26219)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-11-03 11:48:16 UTC (rev 26220)
@@ -137,3 +137,9 @@
EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME=Please specify the property key
EXTERNALIZE_STRINGS_DIALOG_SELECT_RESOURCE_BUNDLE=Please select the resource bundle
CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT=Cannot load taglibs from PageContext!
+EXTERNALIZE_STRINGS_DIALOG_SAVE_RESOURCE_BUNDLE=Select a place to register the bundle
+EXTERNALIZE_STRINGS_DIALOG_FACES_CONFIG=in the faces-config.xml file
+EXTERNALIZE_STRINGS_DIALOG_LOAD_BUNDLE=via <f:loadBundle> tag on the current page
+EXTERNALIZE_STRINGS_DIALOG_USER_DEFINED=manually by user
+EXTERNALIZE_STRINGS_DIALOG_BUNDLE_NAME=Bundle name:
+EXTERNALIZE_STRINGS_DIALOG_WRONG_BUNDLE_PLACEMENT=Resource Bundle file should be created in the source folder.\n Basename will be incorect.
13 years, 6 months
JBoss Tools SVN: r26219 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common: model/ui/texteditors/xmleditor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-11-03 07:45:14 -0400 (Wed, 03 Nov 2010)
New Revision: 26219
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
Log:
JBIDE-7301
https://jira.jboss.org/browse/JBIDE-7301
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2010-11-03 11:44:00 UTC (rev 26218)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2010-11-03 11:45:14 UTC (rev 26219)
@@ -345,7 +345,11 @@
if(monitor != null) monitor.setCanceled(true);
return;
}
- if(textEditor != null && textEditor.isModified()) textEditor.save();
+ lock2 = false;
+ try {
+ if(textEditor != null && textEditor.isModified()) {
+ textEditor.save();
+ }
XModelObject o = getModelObject();
if(o == null || !o.isActive()) return;
XModelObject p = o.getParent();
@@ -372,6 +376,9 @@
saveX(monitor);
f.updateRegistration(o);
+ } finally {
+ lock2 = false;
+ }
}
@@ -495,21 +502,16 @@
boolean lock2 = false;
boolean waitForMerge = false;
- int waitingEventsCount = 0;
public void nodeChanged(XModelTreeEvent event) {
if(lock2) return;
if(event.getDetails() == XModelTreeEvent.BEFORE_MERGE && event.getModelObject() == getModelObject()) {
waitForMerge = true;
- waitingEventsCount = 0;
return;
}
if(event.getDetails() == XModelTreeEvent.AFTER_MERGE && event.getModelObject() == getModelObject()) {
waitForMerge = false;
-// System.out.println("waitingEventsCount=" + waitingEventsCount);
- waitingEventsCount = 0;
}
- waitingEventsCount++;
if(waitForMerge) return;
if(needsUpdate()) {
Display.getDefault().syncExec(new U());
@@ -518,7 +520,6 @@
public void structureChanged(XModelTreeEvent event) {
if(lock2) return;
- waitingEventsCount++;
if(waitForMerge) return;
if(needsUpdate()) {
Display.getDefault().syncExec(new U());
@@ -725,7 +726,7 @@
e.widget.getDisplay().asyncExec(new Runnable() {
public void run() {
handleActivation();
- if(getActivePage() != getSourcePageIndex() && textEditor != null && textEditor.isModified()) {
+ if(textEditor != null && textEditor.isModified()) {
textEditor.save();
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2010-11-03 11:44:00 UTC (rev 26218)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2010-11-03 11:45:14 UTC (rev 26219)
@@ -253,20 +253,24 @@
class TextFocusListener extends FocusAdapter {
public void focusLost(FocusEvent e) {
- if(!XMLTextEditor.super.isDirty()) return;
- Display.getDefault().syncExec(
- new Runnable() {
- public void run() {
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- //ignore
- }
- save();
+ saveInThread();
+ }
+ }
+
+ private void saveInThread() {
+ if(!XMLTextEditor.super.isDirty()) return;
+ Display.getDefault().syncExec(
+ new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ //ignore
}
+ save();
}
- );
- }
+ }
+ );
}
public void save() {
@@ -274,7 +278,7 @@
lock = true;
try {
FileAnyImpl f = (FileAnyImpl)getModelObject();
- if(f != null) f.edit(getSourceViewer().getDocument().get());
+ if(f != null) f.edit(getSourceViewer().getDocument().get());
} catch (XModelException e) {
ModelUIPlugin.getPluginLog().logError(e);
} finally {
@@ -446,6 +450,12 @@
public void documentChanged(DocumentEvent event) {
textChanged(null);
+ StyledText text = getSourceViewer() != null ? getSourceViewer().getTextWidget() : null;
+ if(text != null && !text.isDisposed()) {
+ if(!text.isFocusControl() && text.isVisible()) {
+ saveInThread();
+ }
+ }
}
public void doRevertToSaved() {
13 years, 6 months
JBoss Tools SVN: r26218 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-11-03 07:44:00 -0400 (Wed, 03 Nov 2010)
New Revision: 26218
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
Log:
JBIDE-7301
https://jira.jboss.org/browse/JBIDE-7301
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2010-11-03 11:14:28 UTC (rev 26217)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2010-11-03 11:44:00 UTC (rev 26218)
@@ -608,9 +608,10 @@
public void updateChildFile(XModelObject o, File f) throws XModelException {
FileSystemPeer peer = getFileSystem().getPeer();
+ if(f.isFile() && peer.contains(f) && !peer.isUpdated(f)) return;
+ int i = (!o.isModified()) ? 0 : question(f);
+ if(i < 0) return;
if(!registerFileInPeer(peer, f)) return;
- int i = (!o.isModified()) ? 0 :
- question(f);
if(i == 0) {
reload(o, f);
}
13 years, 6 months
JBoss Tools SVN: r26217 - in trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage: internal/preferences and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-11-03 07:14:28 -0400 (Wed, 03 Nov 2010)
New Revision: 26217
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/http/HttpRemotePropertiesProvider.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java
Log:
[JBIDE-7474] switched to plugin logger adapter which does not log if tracing is not enabled
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/http/HttpRemotePropertiesProvider.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/http/HttpRemotePropertiesProvider.java 2010-11-03 11:04:00 UTC (rev 26216)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/http/HttpRemotePropertiesProvider.java 2010-11-03 11:14:28 UTC (rev 26217)
@@ -17,11 +17,13 @@
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.tools.common.log.ILoggingAdapter;
import org.jboss.tools.usage.util.HttpEncodingUtils;
import org.jboss.tools.usage.util.LoggingUtils;
import org.jboss.tools.usage.util.StatusUtils;
@@ -39,20 +41,18 @@
static final String GET_METHOD_NAME = "GET"; //$NON-NLS-1$
- protected Plugin plugin;
private Map<String, String> valuesMap;
-
private String[] keys;
-
private String url;
-
private char valueDelimiter;
+ protected Plugin plugin;
+ private ILoggingAdapter loggingAdapter;
- public HttpRemotePropertiesProvider(String url, char valueDelimiter, Plugin plugin, String... keys) {
+ public HttpRemotePropertiesProvider(String url, char valueDelimiter, ILoggingAdapter loggingAdapter, String... keys) {
this.url = url;
this.keys = keys;
this.valueDelimiter = valueDelimiter;
- this.plugin = plugin;
+ this.loggingAdapter = loggingAdapter;
}
@@ -93,17 +93,11 @@
LoggingUtils.log(status, plugin);
responseReader = getInputStreamReader(urlConnection.getInputStream(), urlConnection.getContentType());
} else {
- IStatus status = StatusUtils.getErrorStatus(
- plugin.getBundle().getSymbolicName()
- , HttpMessages.HttpGetMethod_Error_Http, null, url, responseCode);
- plugin.getLog().log(status);
+ loggingAdapter.error(MessageFormat.format(HttpMessages.HttpGetMethod_Error_Http, url, responseCode));
}
return responseReader;
} catch (IOException e) {
- IStatus status = StatusUtils.getErrorStatus(
- plugin.getBundle().getSymbolicName()
- , HttpMessages.HttpGetMethod_Error_Io, e, url, e.getMessage());
- plugin.getLog().log(status);
+ loggingAdapter.debug(MessageFormat.format(HttpMessages.HttpGetMethod_Error_Io, url, e.toString()));
throw e;
}
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java 2010-11-03 11:04:00 UTC (rev 26216)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/internal/preferences/GlobalUsageSettings.java 2010-11-03 11:14:28 UTC (rev 26217)
@@ -17,6 +17,7 @@
import org.jboss.tools.usage.http.HttpRemotePropertiesProvider;
import org.jboss.tools.usage.http.IPropertiesProvider;
import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.tracker.internal.UsagePluginLogger;
/**
* A class that implements a global reporting enablement setting. The current
@@ -108,7 +109,7 @@
return new HttpRemotePropertiesProvider(
url,
valueDelimiter,
- plugin,
+ new UsagePluginLogger(plugin),
keys);
}
}
13 years, 6 months