Author: dmaliarevich
Date: 2010-09-30 10:27:08 -0400 (Thu, 30 Sep 2010)
New Revision: 25332
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/localeProvider.exsd
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/
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/BundleMapListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsDialog.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/i18n/ILocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/FaceletsUtil.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMapListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsDialog.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizard.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/ExternalizeStringsContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ExternalizeStringsAction.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfView.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditorFactory.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.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
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPartFactory.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7060 , Externalize strings wizard has been moved from
org.jboss.tools.vpe to org.jboss.tools.jst.jsp.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml 2010-09-30 14:13:11 UTC (rev
25331)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml 2010-09-30 14:27:08 UTC (rev
25332)
@@ -8,7 +8,7 @@
path="templates/vpe-templates-jsf.xml"/>
</extension>
<extension
- point="org.jboss.tools.vpe.localeProvider">
+ point="org.jboss.tools.jst.jsp.localeProvider">
<localeProvider
class="org.jboss.tools.jsf.vpe.jsf.i18n.JsfLocaleProvider">
</localeProvider>
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -20,7 +20,7 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jsf.model.helpers.converter.OpenKeyHelper;
-import org.jboss.tools.vpe.editor.i18n.ILocaleProvider;
+import org.jboss.tools.jst.jsp.i18n.ILocaleProvider;
/**
* Implementation of {@link ILocaleProvider} for JSF projects.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfView.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfView.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfView.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -15,8 +15,8 @@
import java.util.Locale;
import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
+import org.jboss.tools.jst.jsp.i18n.MainLocaleProvider;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.i18n.MainLocaleProvider;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -14,7 +14,7 @@
import java.util.List;
import java.util.Locale;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
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-09-30 14:13:11 UTC
(rev 25331)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2010-09-30 14:27:08 UTC
(rev 25332)
@@ -28,7 +28,9 @@
org.jboss.tools.jst.jsp.text,
org.jboss.tools.jst.jsp.ui.action,
org.jboss.tools.jst.jsp.util,
- org.jboss.tools.jst.jsp.selection
+ org.jboss.tools.jst.jsp.selection,
+ org.jboss.tools.jst.jsp.i18n,
+ org.jboss.tools.jst.jsp.bundle
Require-Bundle: org.jboss.tools.common.el.core,
org.jboss.tools.common.model.ui,
org.jboss.tools.jst.web,
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-09-30 14:13:11 UTC (rev
25331)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-09-30 14:27:08 UTC (rev
25332)
@@ -4,9 +4,9 @@
<extension-point id="occurrenceStructureProviders"
name="%occurrenceStructureProvidersExtensionPoint" />
- <extension-point id="visulaEditorImplementations" name="Visual Editor
Implementations" schema="schema/visulaEditorImplementations.exsd">
- </extension-point>
- <extension-point id="editorContentAssistent"
name="editorContentAssistent"
schema="schema/editorContentAssistent.exsd"/>
+ <extension-point id="visulaEditorImplementations" name="Visual Editor
Implementations" schema="schema/visulaEditorImplementations.exsd" />
+ <extension-point id="editorContentAssistent"
name="editorContentAssistent"
schema="schema/editorContentAssistent.exsd"/>
+ <extension-point id="localeProvider" name="Locale provider for an
opened file" schema="schema/localeProvider.exsd"/>
<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
@@ -281,7 +281,6 @@
</extension>
<extension
point="org.eclipse.ui.menus">
-
<menuContribution
locationURI="menu:sourceMenuId?after=sourceBegin">
<command commandId="org.eclipse.wst.sse.ui.toggle.comment"
id="ToggleComment"
@@ -332,6 +331,22 @@
</visibleWhen>
</command>
</menuContribution>
+
+ <menuContribution
+ locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor.source.EditorContext?after=org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
+ <dynamic
+
class="org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem"
+
id="org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem">
+ </dynamic>
+ </menuContribution>
+ <menuContribution
+
locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor.source.EditorContext?after=org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
+ <dynamic
+
class="org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem"
+
id="org.jboss.tools.jst.jsp.i18n.ExternalizeStringsContributionItem">
+ </dynamic>
+ </menuContribution>
+
</extension>
<extension
Copied: trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/localeProvider.exsd (from rev
25318, trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/localeProvider.exsd
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/localeProvider.exsd 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.vpe"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.vpe"
id="localeProvider" name="Locale provider for an opened file"/>
+ </appInfo>
+ <documentation>
+ This extension point is intented to determine the locale
+ of an opened document in the VPE.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="localeProvider"/>
+ <element ref="nature" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="localeProvider">
+ <annotation>
+ <documentation>
+ The locale provider class description.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+ Fully qualified class name of a ILocaleProvider implementation.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.vpe.editor.ILocaleProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="nature">
+ <annotation>
+ <documentation>
+ Project nature IDs, in which the localeProvider is able to determine the
locale.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+ Nature ID.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"
basedOn="org.eclipse.core.resources.natures/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -39,6 +39,9 @@
* The main plugin class to be used in the desktop.
*/
public class JspEditorPlugin extends BaseUIPlugin {
+
+ public static final String EXTESION_POINT_LOCALE_PROVIDER =
"org.jboss.tools.jst.jsp.localeProvider"; //$NON-NLS-1$
+
//The shared instance.
private static JspEditorPlugin plugin;
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,672 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.bundle;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.event.XModelTreeEvent;
+import org.jboss.tools.common.model.event.XModelTreeListener;
+import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.i18n.MainLocaleProvider;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+public class BundleMap {
+
+ public static final String TITLE_ATTRIBUTE_NAME = "title"; //$NON-NLS-1$
+ private static final String[] JSF_PROJECT_NATURES = {
+ WebProject.JSF_NATURE_ID
+ };
+
+ private BundleMapListener[] bundleMapListeners = new BundleMapListener[0];
+ private StructuredTextEditor editor;
+
+ private String[] javaSources;
+ /*
+ * Stores the current VPE locale.
+ */
+ private Locale locale;
+ private BundleEntry[] bundles = new BundleEntry[0];
+ private Map<String,UsedKey> usedKeys = new HashMap<String,UsedKey>();
+
+ boolean showBundleUsageAsEL =
JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
+ IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL);
+
+ XModelTreeListener modelListener = new ML();
+
+ public void init(StructuredTextEditor editor){
+ this.editor = editor;
+ IEditorInput input = editor.getEditorInput();
+
+ if (input instanceof IFileEditorInput) {
+ javaSources =
getJavaProjectSrcLocations(((IFileEditorInput)input).getFile().getProject());
+ }
+ /*
+ * Initialize the locale with default value.
+ */
+ locale = MainLocaleProvider.getInstance().getLocale(editor);
+ refreshRegisteredBundles();
+ PreferenceModelUtilities.getPreferenceModel().addModelTreeListener(modelListener);
+ }
+
+ public void refreshRegisteredBundles() {
+ if (hasJsfProjectNatureType()
+ && (editor.getEditorInput() instanceof IFileEditorInput)) {
+ IProject project = ((IFileEditorInput) editor.getEditorInput())
+ .getFile().getProject();
+ IModelNature modelNature = EclipseResourceUtil
+ .getModelNature(project);
+ if (modelNature != null) {
+ XModel model = modelNature.getModel();
+ List<Object> l = WebPromptingProvider.getInstance().getList(
+ model, WebPromptingProvider.JSF_REGISTERED_BUNDLES,
+ null, null);
+ if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
+ Map<?, ?> map = (Map<?, ?>) l.get(1);
+ /*
+ * Fix for
https://jira.jboss.org/jira/browse/JBIDE-5218
+ * When updating f:view's locale attribute right after
+ * template creation - map of registered bundles is empty
+ * and couldn't be updated. To change bundle's locale they
+ * should be accessed through <code>bundles</code> variable.
+ */
+ if (map.keySet().size() > 0) {
+ Iterator<?> it = map.keySet().iterator();
+ while (it.hasNext()) {
+ String uri = it.next().toString();
+ String prefix = map.get(uri).toString();
+ int hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
+ removeBundle(hash);
+ addBundle(hash, prefix, uri, true);
+ }
+ } else if (bundles.length > 0) {
+ for (int i = 0; i < bundles.length; i++) {
+ String uri = bundles[i].uri;
+ String prefix = bundles[i].prefix;
+ int hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
+ removeBundle(hash);
+ addBundle(hash, prefix, uri, true);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void clearAll() {
+ bundles = new BundleEntry[0];
+ usedKeys = new HashMap<String,UsedKey>();
+ }
+
+ public void dispose() {
+ PreferenceModelUtilities.getPreferenceModel().removeModelTreeListener(modelListener);
+ }
+
+ public boolean isShowBundleUsageAsEL() {
+ return showBundleUsageAsEL;
+ }
+
+ private boolean hasJsfProjectNatureType() {
+ boolean hasJsfProjectNatureType = false;
+ try {
+ IEditorInput ei = editor.getEditorInput();
+ if(ei instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)ei).getFile().getProject();
+ if (project.exists() && project.isOpen()) {
+ for (int i = 0; i < JSF_PROJECT_NATURES.length; i++) {
+ if (project.hasNature(JSF_PROJECT_NATURES[i]))
+ hasJsfProjectNatureType = true;
+ break;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ return hasJsfProjectNatureType;
+ }
+
+ public boolean openBundle(String expression, String locale){
+ List<ELInstance> is = parseJSFExpression(expression);
+ if(is == null || is.size() == 0) return false;
+ String prefix = null;
+ String propertyName = null;
+ for (ELInstance i: is) {
+ ELExpression expr = i.getExpression();
+ if(expr == null) continue;
+ List<ELInvocationExpression> invs = expr.getInvocations();
+ if(invs.size() > 0) {
+ String[] values = getCall(invs.get(0));
+ if(values != null) {
+ prefix = values[0];
+ propertyName = values[1];
+ break;
+ }
+ }
+ }
+ if(prefix == null) return false;
+
+ BundleEntry entry = getBundle(prefix);
+
+ 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$
+ }
+ WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_BEAN_OPEN,
prefix2, null);
+ }
+ return false;
+ }
+
+ if (hasJsfProjectNatureType()) {
+ Properties p = new Properties();
+ p.put(WebPromptingProvider.BUNDLE, entry.uri);
+ 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);
+ return (error == null || error.length() == 0);
+ }
+ return false;
+ }
+
+ /**
+ * Gets the bundle file based on the locale
+ * from the loaded resource bundle.
+ *
+ * @param uri the uri
+ * @return the bundle file
+ */
+ public IFile getBundleFile(String uri){
+ IEditorInput input = editor.getEditorInput();
+ IProject project = ((FileEditorInput)input).getFile().getProject();
+ if(project == null || !project.isOpen()) {
+ return null;
+ }
+ try {
+ if(!project.hasNature(JavaCore.NATURE_ID)) {
+ return null;
+ }
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
+ for (int i = 0; i < es.length; i++) {
+ if(es[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) {
+ continue;
+ }
+ IFile file = (IFile) project.getWorkspace().getRoot()
+ .getFolder(es[i].getPath()).findMember("/" + getBundleFileName(uri));
//$NON-NLS-1$
+ if(file != null && file.exists()) {
+ return file;
+ }
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * Gets the bundle file name.
+ * <a
href="https://jira.jboss.org/browse/JBIDE-6729">
+ * Related Jira</a>
+ *
+ * @param uri the uri
+ * @return the bundle file name
+ */
+ private String getBundleFileName(String uri) {
+ String resultUri = uri.replace('.','/');
+ ResourceBundle bundle = getBundleByUrl(uri, locale);
+ String localeString = bundle.getLocale().toString();
+ if ((null != localeString) && (localeString.length() > 0)) {
+ /*
+ * getLanguage() method in ResourceBundle could return "en_us" string.
+ * Bundle's file is case sensitive thus country name
+ * should be transformed to UpperCase.
+ */
+ String[] parts = localeString.split(Constants.UNDERSCORE);
+ if (parts.length == 2) {
+ parts[1] = parts[1].toUpperCase();
+ }
+ for (String part : parts) {
+ resultUri += Constants.UNDERSCORE + part;
+ }
+ }
+ resultUri += ".properties"; //$NON-NLS-1$
+ return resultUri;
+ }
+
+ private ResourceBundle getBundleByUrl(String uri, Locale locale) {
+ try {
+ if (javaSources!=null) {
+ File file;
+ URL[] urls = new URL[javaSources.length];
+ for (int i=0;i<javaSources.length;++i) {
+ try {
+ file = new File(javaSources[i]).getCanonicalFile();
+ urls[i] = file.toURL();
+ } catch (IOException ioe) {
+ JspEditorPlugin.getDefault().logError(ioe);
+ return null;
+ }
+ }
+
+ ClassLoader classLoader = new URLClassLoader(urls,
ClassLoader.getSystemClassLoader());
+ ResourceBundle bundle = ResourceBundle.getBundle(uri, locale, classLoader);
+ return bundle;
+ }
+ } catch (MissingResourceException ex) {
+ // Ignore this exception
+ }
+
+ return null;
+ }
+
+ private static String[] getJavaProjectSrcLocations(IProject project) {
+ return EclipseResourceUtil.getJavaProjectSrcLocations(project);
+ }
+
+ private void removeBundle(int hashCode, boolean refresh) {
+ if (bundles.length == 0) {
+ return;
+ }
+ int index = -1;
+ for (int i = 0; i < bundles.length; i++) {
+ if (hashCode == bundles[i].hashCode){
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ return;
+ }
+ if (bundles.length == 1) {
+ bundles = new BundleEntry[0];
+ return;
+ }
+ BundleEntry[] newBundles = new BundleEntry[bundles.length - 1];
+ System.arraycopy(bundles, 0, newBundles, 0, index);
+ System.arraycopy(bundles, index + 1, newBundles, index, bundles.length - index - 1);
+ bundles = newBundles;
+ if (refresh) {
+ refreshUsedKeys();
+ }
+ }
+
+ public void removeBundle(int hashCode) {
+ removeBundle(hashCode, true);
+ }
+
+ public void addBundle(int hashCode, String prefix, String uri,boolean refresh) {
+ ResourceBundle bundle = getBundleByUrl(uri, locale);
+ BundleEntry entry = new BundleEntry(bundle, uri, prefix, hashCode);
+ if (bundle != null) {
+ BundleEntry[] newBundles = new BundleEntry[bundles.length + 1];
+ System.arraycopy(bundles, 0, newBundles, 0, bundles.length);
+ bundles = newBundles;
+ bundles[bundles.length - 1] = entry;
+ }
+ if (refresh) {
+ refreshUsedKeys();
+ }
+ }
+
+ public void changeBundle(int hashCode, String prefix, String uri){
+ removeBundle(hashCode, false);
+ addBundle(hashCode, prefix, uri, true);
+ }
+
+ private void changeBundleWithoutRefresh(int hashCode, String prefix, String uri){
+ removeBundle(hashCode, false);
+ addBundle(hashCode, prefix, uri, false);
+ }
+
+ private BundleEntry getBundle(String prefix) {
+ if (prefix == null) {
+ return null;
+ }
+ BundleEntry lastBundle = null;
+ for (int i = 0; i < bundles.length; i++) {
+ if (prefix.equals(bundles[i].prefix)) {
+ lastBundle = bundles[i];
+ }
+ }
+ return lastBundle;
+ }
+
+ public void refresh(){
+ refreshRegisteredBundles();
+ IEditorInput input = editor.getEditorInput();
+
+ if (input instanceof IFileEditorInput) {
+ javaSources =
getJavaProjectSrcLocations(((IFileEditorInput)input).getFile().getProject());
+ UsedKey key;
+ UsedKey[] array = new UsedKey[0];
+ array = usedKeys.values().toArray(array);
+
+ for(int i=0; i<array.length;i++){
+ key = (UsedKey)array[i];
+ changeBundleWithoutRefresh(key.hashCode, key.prefix, key.uri);
+ }
+ refreshUsedKeys();
+ }
+ }
+
+ private void refreshUsedKeys(){
+ UsedKey keyValue;
+
+
+ /* yradtsevich: Fix of JBIDE-5818. The map usedKey cannot be modified
+ * in the following foreach loop. Therefore the keys to remove
+ * are marked and removed after the loop. */
+ List<String> keysToBeRemoved = new ArrayList<String>(0);
+
+ Set<String> usedKeysSet = this.usedKeys.keySet();
+ for(String key : usedKeysSet){
+ keyValue =this.usedKeys.get(key);
+ BundleEntry entry = getBundle(keyValue.prefix);
+ if(entry != null){
+ String value;
+ try{
+ value = (String)entry.bundle.getObject(keyValue.key);
+ }catch(MissingResourceException ex){
+ value = null;
+ fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
+ // Fix of JBIDE-5818
+ keysToBeRemoved.add(key);
+ continue;
+ }
+ if((value == null && keyValue.value != null) || (value != null &&
keyValue.value == null)){
+ keyValue.value = value;
+ fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
+ continue;
+ }else if(value != null && keyValue.value != null &&
!value.equals(keyValue.value)){
+ keyValue.value = value;
+ fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
+ continue;
+ }
+ } else{
+ keyValue.value = null;
+ fireBundleKeyChanged(keyValue.prefix, keyValue.key, null);
+ }
+ }
+
+ // Fix of JBIDE-5818
+ for (String key : keysToBeRemoved) {
+ this.usedKeys.remove(key);
+ }
+ }
+
+ private List<ELInstance> parseJSFExpression(String expression){
+ ELParser parser = ELParserUtil.getDefaultFactory().createParser();
+ ELModel model = parser.parse(expression);
+ List<ELInstance> is = model.getInstances();
+ return is;
+ }
+
+ public String getBundleValue(String name) {
+// System.out.println("\n1 BM -> getBundleValue -> " + name);
+// System.out.println("2 BM -> showBundleUsageAsEL = "
+// + showBundleUsageAsEL);
+ String bundleValue = name;
+ if (!showBundleUsageAsEL) {
+ List<ELInstance> is = parseJSFExpression(name);
+ if (is != null) {
+ StringBuffer sb = new StringBuffer();
+ int index = 0;
+ for (ELInstance i : is) {
+ int start = i.getStartPosition();
+ sb.append(name.substring(index, start));
+ index = start;
+ if (i.getExpression() instanceof ELInvocationExpression) {
+ ELInvocationExpression expr = (ELInvocationExpression) i
+ .getExpression();
+ String[] values = getCall(expr);
+ if (values != null) {
+ String value = getBundleValue(values[0], values[1]);
+ if (value != null) {
+ sb.append(value);
+ index = i.getEndPosition();
+ }
+
+ }
+ }
+ if (index < i.getEndPosition()) {
+ // fix has been added by Maksim Areshkau
+ //
https://jira.jboss.org/jira/browse/JBIDE-6064
+ if (name.length() > i.getEndPosition()) {
+ sb.append(name.substring(index, i.getEndPosition()));
+ index = i.getEndPosition();
+ } else {
+ sb.append(name.substring(index, name.length()));
+ index = name.length();
+ }
+ }
+ }
+ bundleValue = sb.append(name.substring(index)).toString();
+ }
+ }
+// System.out.println("3 BM -> getBundleValue -> " + bundleValue);
+ return bundleValue;
+ }
+
+ String[] getCall(ELInvocationExpression expr) {
+ if(expr == null) return null;
+ ELInvocationExpression left = expr.getLeft();
+ if(left == null) return null;
+ String name = expr.getMemberName();
+ if(name == null || name.length() == 0) return null;
+ if(expr instanceof ELPropertyInvocation) {
+ return new String[]{left.getText(), name};
+ } else if(expr instanceof ELArgumentInvocation) {
+ if(name.startsWith("\"") || name.startsWith("'")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ name = name.substring(1);
+ }
+ if(name.endsWith("\"") || name.endsWith("'")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ name = name.substring(0, name.length() - 1);
+ }
+ if(name.length() == 0) return null;
+ return new String[]{left.getText(), name};
+ }
+ return null;
+ }
+
+ private String getBundleValue(String prefix, String propertyName) {
+ String bundleValue = null;
+ BundleEntry entry = getBundle(prefix);
+ if (entry != null) {
+ String name = prefix + "." + propertyName; //$NON-NLS-1$
+ try {
+ bundleValue = (String) entry.bundle.getObject(propertyName);
+ if (!usedKeys.containsKey(name))
+ usedKeys.put(name, new UsedKey(entry.uri, prefix,
+ propertyName, bundleValue, entry.hashCode));
+ } catch (MissingResourceException ex) {
+ /*
+ * Null string will be returned.
+ */
+ }
+ }
+ return bundleValue;
+ }
+
+ public void addBundleMapListener(BundleMapListener listener) {
+ if (listener != null) {
+ BundleMapListener[] newBundleMapListener = new
BundleMapListener[bundleMapListeners.length + 1];
+ System.arraycopy(bundleMapListeners, 0, newBundleMapListener, 0,
bundleMapListeners.length);
+ bundleMapListeners = newBundleMapListener;
+ bundleMapListeners[bundleMapListeners.length - 1] = listener;
+ }
+ }
+
+ public void removeBundleMapListener(BundleMapListener listener) {
+ if (listener == null || bundleMapListeners.length == 0) return;
+ int index = -1;
+ for (int i = 0; i < bundleMapListeners.length; i++) {
+ if (listener == bundleMapListeners[i]){
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) return;
+ if (bundleMapListeners.length == 1) {
+ bundleMapListeners = new BundleMapListener[0];
+ return;
+ }
+ BundleMapListener[] newBundleMapListener = new
BundleMapListener[bundleMapListeners.length - 1];
+ System.arraycopy(bundleMapListeners, 0, newBundleMapListener, 0, index);
+ System.arraycopy(bundleMapListeners, index + 1, newBundleMapListener, index,
bundleMapListeners.length - index - 1);
+ bundleMapListeners = newBundleMapListener;
+ }
+
+ private void fireBundleKeyChanged(String prefix, String key, String value) {
+ for (int i = 0; i < bundleMapListeners.length; i++) {
+ bundleMapListeners[i].bundleKeyChanged(prefix, key, value);
+ }
+ }
+
+ public void updateShowBundleUsageAsEL(boolean showBundlesAsEL) {
+ if(showBundleUsageAsEL != showBundlesAsEL) {
+ showBundleUsageAsEL = showBundlesAsEL;
+ refresh();
+ }
+ }
+
+ public void updateShowBundleUsageAsEL() {
+ updateShowBundleUsageAsEL(JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
+ IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL));
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ static class Expression {
+ public String prefix;
+ public String propertyName;
+ }
+
+ /*
+ *
https://jira.jboss.org/browse/JBIDE-6287
+ * It was required to get access to BundleEntry class.
+ */
+ public static class BundleEntry {
+ public ResourceBundle bundle;
+ public String uri;
+ public String prefix;
+ public int hashCode;
+
+ public BundleEntry(ResourceBundle bundle, String uri, String prefix,
+ int hashCode) {
+ this.bundle = bundle;
+ this.uri = uri;
+ this.prefix = prefix;
+ this.hashCode = hashCode;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleEntry [prefix=" + prefix + ", uri=" + uri + ",
hashCode=" + hashCode //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + ", bundle="+ bundle +"]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ }
+
+ static class UsedKey {
+ public int hashCode;
+ public String uri;
+ public String prefix;
+ public String key;
+ public String value;
+
+ public UsedKey(String uri, String prefix, String key, String value,
+ int hashCode) {
+ this.uri = uri;
+ this.prefix = prefix;
+ this.key = key;
+ this.value = value;
+ this.hashCode = hashCode;
+
+ }
+ }
+
+ class ML implements XModelTreeListener {
+
+ public void nodeChanged(XModelTreeEvent event) {
+ updateShowBundleUsageAsEL();
+ }
+
+ public void structureChanged(XModelTreeEvent event) {
+ }
+
+ }
+
+ /**
+ * @param showBundleUsageAsEL the showBundleUsageAsEL to set
+ */
+ public void setShowBundleUsageAsEL(boolean showBundleUsageAsEL) {
+ this.showBundleUsageAsEL = showBundleUsageAsEL;
+ }
+
+ public BundleEntry[] getBundles() {
+ return bundles;
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapListener.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMapListener.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapListener.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapListener.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.bundle;
+
+public interface BundleMapListener {
+ public void bundleKeyChanged(String bundlePrefix, String key, String value);
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditorFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditorFactory.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditorFactory.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -12,9 +12,12 @@
import org.eclipse.ui.part.EditorPart;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
public interface IVisualEditorFactory {
- public IVisualEditor createVisualEditor(EditorPart multiPageEditor, StructuredTextEditor
textEditor, boolean visualMode);
+ public IVisualEditor createVisualEditor(EditorPart multiPageEditor,
+ StructuredTextEditor textEditor, boolean visualMode,
+ BundleMap bundleMap);
}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ExternalizeStringsAction.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsAction.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+
+public class ExternalizeStringsAction extends Action {
+
+ private JSPMultiPageEditor editor;
+
+ public ExternalizeStringsAction() {
+ super();
+ editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ }
+
+ @Override
+ public void run() {
+ ISelection sel = editor.getSelectionProvider().getSelection();
+
+ if ((sel instanceof TextSelection)
+ && (sel instanceof IStructuredSelection)
+ && (((IStructuredSelection) sel).size() == 1)) {
+ /*
+ * Pass null for Bundle Map that it will be created by the page itself.
+ */
+ ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ new ExternalizeStringsWizard(editor.getSourceEditor(), null));
+ dlg.open();
+ } else {
+ MessageDialog.openWarning(
+ PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION);
+ }
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/ExternalizeStringsContributionItem.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsContributionItem.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.jface.action.ActionContributionItem;
+import org.eclipse.swt.widgets.Menu;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+
+public class ExternalizeStringsContributionItem extends ActionContributionItem {
+
+ /**
+ * Instantiates a new externalize strings contribution item.
+ * Default constructor is used to create
+ * source editor context menu from plugin.xml
+ */
+ public ExternalizeStringsContributionItem() {
+ super(new ExternalizeStringsAction());
+ }
+
+ @Override
+ public void fill(Menu parent, int index) {
+ /*
+ * Simply sets the title
+ */
+ getAction().setText(JstUIMessages.EXTERNALIZE_STRINGS);
+ super.fill(parent, index);
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsDialog.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsDialog.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsDialog.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsDialog.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+public class ExternalizeStringsDialog extends WizardDialog {
+
+ public ExternalizeStringsDialog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ Button finishButton = getButton(IDialogConstants.FINISH_ID);
+ finishButton.setText(IDialogConstants.OK_LABEL);
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizard.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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 java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+
+public class ExternalizeStringsWizard extends Wizard {
+
+ public String ExternalizeStringsWizardPageName =
"ExternalizeStringsWizardPage"; //$NON-NLS-1$
+ public String NewFileCreationPageName = "NewFileCreationPage"; //$NON-NLS-1$
+
+ StructuredTextEditor editor = null;
+ BundleMap bm = null;
+ ExternalizeStringsWizardPage page1 = null;
+ WizardNewFileCreationPage page2 = null;
+
+ public ExternalizeStringsWizard(StructuredTextEditor editor, BundleMap bm) {
+ super();
+ setHelpAvailable(false);
+ setWindowTitle(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
+ this.editor = editor;
+ this.bm = bm;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page1 = new ExternalizeStringsWizardPage(
+ ExternalizeStringsWizardPageName, editor, bm);
+ page2 = new WizardNewFileCreationPage(NewFileCreationPageName,
+ (IStructuredSelection) editor.getSelectionProvider().getSelection()) {
+ protected InputStream getInitialContents() {
+ return new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
+ }
+ };
+ page2.setTitle(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
+ page2.setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
+ page2.setImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
+ addPage(page1);
+ addPage(page2);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return (!page1.isNewFile() && page1.isPageComplete())
+ || (page1.isNewFile() && page2.isPageComplete());
+ }
+
+ @Override
+ public boolean performFinish() {
+ IFile bundleFile = null;
+ if (page1.isNewFile()) {
+ bundleFile = page2.createNewFile();
+ } else {
+ bundleFile = page1.getBundleFile();
+ }
+ /*
+ * Exit when the file is null
+ */
+ if (bundleFile == null) {
+ return false;
+ }
+ /*
+ * Add "key=value" to the bundle if file is not new,
+ * If it is new, it got input by getInitialContent()
+ */
+ if (bundleFile.exists() && !page1.isNewFile()) {
+ InputStream is = new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
+ try {
+ bundleFile.appendContents(is, false, true, null);
+ is.close();
+ is = null;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ /*
+ * Replace text in the editor
+ */
+ page1.replaceText();
+
+ return true;
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,914 @@
+/*******************************************************************************
+ * 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 java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
+import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.eclipse.wst.xml.core.internal.document.TextImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap.BundleEntry;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
+import org.jboss.tools.jst.jsp.jspeditor.SourceEditorPageContext;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.util.FaceletsUtil;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ExternalizeStringsWizardPage extends WizardPage {
+
+ private final char[] REPLACED_CHARACTERS = new char[] {'~', '!',
'@', '#',
+ '$', '%', '^', '&', '*', '(',
')', '-', '+', '=', '{', '}', '[',
']', ':', ';', ',', '.', '?',
'\\', '/'};
+ private final char[] LINE_DELEMITERS = new char[] {'\r', '\n',
'\t'};
+ private final int DIALOG_WIDTH = 450;
+ private final int DIALOG_HEIGHT = 650;
+ private StructuredTextEditor editor;
+ private Text propsKey;
+ private Text propsValue;
+ private Button newFile;
+ private Label propsFileLabel;
+ private Text propsFile;
+ private Label rbListLabel;
+ private Combo rbCombo;
+ private BundleMap bm;
+ private Group propsFilesGroup;
+ private Status propsKeyStatus;
+ private Status propsValueStatus;
+ private Status duplicateKeyStatus;
+ private Table tagsTable;
+
+
+ public ExternalizeStringsWizardPage(String pageName, StructuredTextEditor editor,
BundleMap bm) {
+ /*
+ * Setting dialog Title, Description, Image.
+ */
+ super(pageName,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
+ ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
+ setDescription(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
+ setPageComplete(false);
+ this.editor = editor;
+ if (bm != null) {
+ this.bm = bm;
+ } else {
+ /*
+ * When BundleMap is null create it manually
+ * with all necessary initialization
+ */
+ this.bm = createBundleMap(editor);
+ }
+ propsKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
+ propsValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
+ duplicateKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID,
Constants.EMPTY);
+ }
+
+ public void createControl(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = DIALOG_WIDTH;
+ gd.heightHint = DIALOG_HEIGHT;
+ composite.setLayoutData(gd);
+
+ /*
+ * Create properties string group
+ */
+ Group propsStringGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ propsStringGroup.setLayout(new GridLayout(3, false));
+ propsStringGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
+ propsStringGroup.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+
+ /*
+ * Create Properties Key label
+ */
+ Label propsKeyLabel = new Label(propsStringGroup, SWT.NONE);
+ propsKeyLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+ propsKeyLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY);
+ /*
+ * Create Properties Key value
+ */
+ propsKey = new Text(propsStringGroup, SWT.BORDER);
+ propsKey.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+ propsKey.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY);
+
+ /*
+ * Create Properties Value label
+ */
+ Label propsValueLabel = new Label(propsStringGroup, SWT.NONE);
+ propsValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+ propsValueLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE);
+ /*
+ * Create Properties Value value
+ */
+ propsValue = new Text(propsStringGroup, SWT.BORDER);
+ propsValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+ propsValue.setText(Constants.EMPTY);
+ propsValue.setEditable(false);
+
+ /*
+ * Create New File Checkbox
+ */
+ newFile = new Button(composite, SWT.CHECK);
+ newFile.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false, 1, 1));
+ newFile.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE);
+
+ /*
+ * Create properties string group
+ */
+ propsFilesGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ propsFilesGroup.setLayout(new GridLayout(3, false));
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ gd.heightHint = 300;
+ propsFilesGroup.setLayoutData(gd);
+ propsFilesGroup.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP);
+
+ /*
+ * Create Resource Bundles List label
+ */
+ rbListLabel = new Label(propsFilesGroup, SWT.NONE);
+ rbListLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
+ rbListLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST);
+ /*
+ * Create Resource Bundles combobox
+ */
+ rbCombo = new Combo(propsFilesGroup, SWT.NONE);
+ rbCombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
+
+ /*
+ * Create Properties File label
+ */
+ propsFileLabel = new Label(propsFilesGroup, SWT.NONE);
+ propsFileLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false,false, 1, 1));
+ propsFileLabel.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE);
+ /*
+ * Create Properties File path field
+ */
+ propsFile = new Text(propsFilesGroup, SWT.BORDER);
+ propsFile.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true,false, 2, 1));
+ propsFile.setText(Constants.EMPTY);
+ propsFile.setEditable(false);
+ /*
+ * Create properties file table of content
+ */
+ tagsTable = new Table(propsFilesGroup, SWT.BORDER);
+ TableLayout layout = new TableLayout();
+ tagsTable.setLayout(layout);
+ tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+ tagsTable.setHeaderVisible(true);
+ tagsTable.setLinesVisible(true);
+
+ ColumnLayoutData columnLayoutData;
+ TableColumn propNameColumn = new TableColumn(tagsTable, SWT.NONE);
+ propNameColumn.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME);
+ columnLayoutData = new ColumnWeightData(200, true);
+ layout.addColumnData(columnLayoutData);
+ TableColumn propValueColumn = new TableColumn(tagsTable, SWT.NONE);
+
propValueColumn.setText(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE);
+ columnLayoutData = new ColumnWeightData(200, true);
+ layout.addColumnData(columnLayoutData);
+
+ /*
+ * Initialize all fields with real values.
+ */
+ initializeFieldsAndAddLIsteners();
+
+ /*
+ * Wizard Page control should be initialized.
+ */
+ setControl(composite);
+ }
+
+ /**
+ * Initialize dialog's controls.
+ * Fill in appropriate text and make validation.
+ */
+ private void initializeFieldsAndAddLIsteners() {
+ ISelection sel = editor.getSelectionProvider().getSelection();
+ if (isSelectionCorrect(sel)) {
+ String text = Constants.EMPTY;
+ String stringToUpdate = Constants.EMPTY;
+ TextSelection textSelection = null;
+ IStructuredSelection structuredSelection = (IStructuredSelection) sel;
+ textSelection = (TextSelection) sel;
+ text = textSelection.getText();
+ Object selectedElement = structuredSelection.getFirstElement();
+ /*
+ * When selected text is empty
+ * parse selected element and find a string to replace..
+ */
+ if ((text.trim().length() == 0)) {
+ if (selectedElement instanceof org.w3c.dom.Text) {
+ /*
+ * ..it could be a plain text
+ */
+ org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
+ if (textNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = textNode.getNodeValue();
+ editor.getSelectionProvider().setSelection(new
StructuredSelection(stringToUpdate));
+ }
+ } else if (selectedElement instanceof Attr) {
+ /*
+ * ..or an attribute's value
+ */
+ Attr attrNode = (Attr) selectedElement;
+ if (attrNode.getNodeValue().trim().length() > 0) {
+ stringToUpdate = attrNode.getNodeValue();
+ editor.getSelectionProvider().setSelection(new
StructuredSelection(stringToUpdate));
+ }
+ }
+ if ((stringToUpdate.trim().length() > 0)) {
+ text = stringToUpdate;
+ }
+ }
+ /*
+ * Update text string field.
+ * Trim the text to remove line breaks and caret returns.
+ * Replace line delimiters white space
+ */
+ for (char ch : LINE_DELEMITERS) {
+ text = text.trim().replace(ch, ' ');
+ }
+ propsValue.setText(text);
+ propsKey.setText(generatePropertyKey(text));
+ /*
+ * Initialize bundle messages field
+ */
+ if (bm == null) {
+ JspEditorPlugin.getDefault().logWarning(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING);
+ } else {
+ BundleEntry[] bundles = bm.getBundles();
+ Set<String> uriSet = new HashSet<String>();
+ for (BundleEntry bundleEntry : bundles) {
+ if (!uriSet.contains(bundleEntry.uri)) {
+ uriSet.add(bundleEntry.uri);
+ rbCombo.add(bundleEntry.uri);
+ }
+ }
+ /*
+ * Select the first bundle if there is any in the list
+ */
+ if (rbCombo.getItemCount() > 0) {
+ rbCombo.select(0);
+ setResourceBundlePath(rbCombo.getText());
+ }
+ }
+ /*
+ * Check the initial key value
+ * If there is the error - add sequence number to the key
+ */
+ updateDuplicateKeyStatus();
+ while (!duplicateKeyStatus.isOK()) {
+ int index = propsKey.getText().lastIndexOf('_');
+ String newKey = Constants.EMPTY;
+ if (index != -1) {
+ /*
+ * String sequence at the end should be checked.
+ * If it is a sequence number - it should be increased by 1.
+ * If not - new number should be added.
+ */
+ String numberString = propsKey.getText().substring(index + 1);
+ int number;
+ try {
+ number = Integer.parseInt(numberString);
+ number++;
+ newKey = propsKey.getText().substring(0, index + 1) + number;
+ } catch (NumberFormatException e) {
+ newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ }
+ } else {
+ /*
+ * If the string has no sequence number - add it.
+ */
+ newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ }
+ /*
+ * Set the new key text
+ */
+ propsKey.setText(newKey);
+ updateDuplicateKeyStatus();
+ }
+ /*
+ *
https://jira.jboss.org/browse/JBIDE-6945
+ * Set the greeting message only.
+ * All the validation will take place in the fields' listeners
+ * after user enters some new values.
+ */
+ setMessage(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME,
+ IMessageProvider.INFORMATION);
+ /*
+ * Update the Buttons state.
+ * When all the fields are correct --
+ * then user should be abke to press OK
+ */
+ setPageComplete(isPageComplete());
+ /*
+ * Add selection listeners to the fields
+ */
+ propsKey.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateStatus();
+ }
+ });
+ propsValue.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateStatus();
+ }
+ });
+ newFile.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean selected = ((Button)e.getSource()).getSelection();
+ if (selected) {
+ enableBundleGroup(false);
+ } else {
+ enableBundleGroup(true);
+ }
+ updateStatus();
+ }
+ });
+ rbCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setResourceBundlePath(rbCombo.getText());
+ updateDuplicateKeyStatus();
+ updateStatus();
+ }
+ });
+ } else {
+ JspEditorPlugin.getDefault().logWarning(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
+ }
+ }
+
+ /**
+ * Checks user has selected a correct string.
+ *
+ * @param selection the current selection
+ * @return <code>true</code> if correct
+ */
+ private boolean isSelectionCorrect(ISelection selection) {
+ if ((selection instanceof TextSelection)
+ && (selection instanceof IStructuredSelection)
+ && (((IStructuredSelection) selection).size() == 1)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks keys in the selected resource bundle.
+ *
+ * @param key the key name
+ * @return <code>true</code> if there is a key with the specified name
+ */
+ private boolean isDuplicatedKey(String key) {
+ boolean isDupliacted = false;
+ if ((tagsTable.getItemCount() > 0) && (null != key) && !isNewFile())
{
+ TableItem[] items = tagsTable.getItems();
+ for (TableItem tableItem : items) {
+ if (key.equalsIgnoreCase(tableItem.getText(0))) {
+ isDupliacted = true;
+ break;
+ }
+ }
+ }
+ return isDupliacted;
+ }
+
+ /**
+ * Update resource bundle table according to the selected file:
+ * it fills key and value columns.
+ *
+ * @param file the resource bundle file
+ */
+ private void updateTable(IFile file) {
+ if ((file != null) && file.exists()) {
+ try {
+ /*
+ * Read the file content
+ */
+ String encoding = FileUtil.getEncoding(file);
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ file.getContents(), encoding));
+ Properties properties = new Properties();
+ properties.load(in);
+ in.close();
+ in = null;
+ /*
+ * Clear the table
+ */
+ tagsTable.removeAll();
+ /*
+ * Fill in new values
+ */
+ int k = 0;
+ Set<String> keys = properties.stringPropertyNames();
+ List<String> keysList = new ArrayList<String>(keys);
+ Collections.sort(keysList);
+ for (String key : keysList) {
+ TableItem tableItem = null;
+ tableItem = new TableItem(tagsTable, SWT.BORDER, k);
+ k++;
+ tableItem.setText(new String[] {key, properties.getProperty(key)});
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getDefault().logError(
+ "Could not load file content for '" + file + "'", e);
//$NON-NLS-1$ //$NON-NLS-2$
+ } catch (IOException e) {
+ JspEditorPlugin.getDefault().logError(
+ "Could not read file: '" + file + "'", e); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ } else {
+ JspEditorPlugin.getDefault().logError(
+ "Bundle File'" + file + "' does not exist!");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Enables or disables resource bundle information
+ *
+ * @param enabled shows the status
+ */
+ private void enableBundleGroup(boolean enabled) {
+ propsFilesGroup.setEnabled(enabled);
+ propsFileLabel.setEnabled(enabled);
+ propsFile.setEnabled(enabled);
+ rbListLabel.setEnabled(enabled);
+ rbCombo.setEnabled(enabled);
+ tagsTable.setEnabled(enabled);
+ }
+
+ /**
+ * Gets <code>key=value</code> pair
+ *
+ * @return a pair <code>\nkey=value\n</code>
+ */
+ public String getKeyValuePair() {
+ return "\n" + propsKey.getText() + Constants.EQUAL + propsValue.getText() +
"\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * 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 (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() {
+ if (isDuplicatedKey(propsKey.getText())) {
+ duplicateKeyStatus = new Status(
+ IStatus.ERROR,
+ JspEditorPlugin.PLUGIN_ID,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS);
+ } else {
+ duplicateKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID,
Constants.EMPTY);
+ }
+ }
+
+ private void updatePropertiesValueStatus() {
+ String text = propsValue.getText();
+ if ((text == null)
+ || (Constants.EMPTY.equalsIgnoreCase(text.trim()))
+ || (text.indexOf(Constants.GT) != -1)
+ || (text.indexOf(Constants.LT) != -1)) {
+ propsValueStatus = new Status(
+ IStatus.ERROR,
+ JspEditorPlugin.PLUGIN_ID,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
+ } else {
+ propsValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID,
Constants.EMPTY);
+ }
+ }
+
+ /**
+ * Update properties key status.
+ */
+ private void updatePropertiesKeyStatus() {
+ if ((propsKey.getText() == null)
+ || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
+ propsKeyStatus = new Status(
+ IStatus.ERROR,
+ JspEditorPlugin.PLUGIN_ID,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
+ } else {
+ propsKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
+
+ /**
+ * Update page status.
+ */
+ private void updateStatus() {
+ /*
+ * Update all statuses
+ */
+ updatePropertiesKeyStatus();
+ updatePropertiesValueStatus();
+ updateDuplicateKeyStatus();
+ /*
+ * Apply status to the dialog
+ */
+ applyStatus(this, new IStatus[] {propsKeyStatus, propsValueStatus,
duplicateKeyStatus});
+ /*
+ * Set page complete
+ */
+ setPageComplete(isPageComplete());
+ }
+
+ /**
+ * Apply status to the dialog.
+ *
+ * @param page the page
+ * @param statuses all the statuses
+ */
+ private void applyStatus(DialogPage page, IStatus[] statuses) {
+ IStatus severeStatus = statuses[0];
+ for (IStatus status : statuses) {
+ severeStatus = severeStatus.getSeverity() >= status.getSeverity()
+ ? severeStatus : status;
+ }
+
+ String message = severeStatus.getMessage();
+ switch (severeStatus.getSeverity()) {
+ case IStatus.OK:
+ page.setMessage(null, IMessageProvider.NONE);
+ page.setErrorMessage(null);
+ break;
+
+ case IStatus.WARNING:
+ page.setMessage(message, IMessageProvider.WARNING);
+ page.setErrorMessage(null);
+ break;
+
+ case IStatus.INFO:
+ page.setMessage(message, IMessageProvider.INFORMATION);
+ page.setErrorMessage(null);
+ break;
+
+ default:
+ if (message.length() == 0) {
+ message = null;
+ }
+ page.setMessage(null);
+ page.setErrorMessage(message);
+ break;
+ }
+ }
+
+ @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)
+ && ((rbCombo.getSelectionIndex() != -1) || isNewFile())) {
+ isPageComplete = true;
+ }
+ return isPageComplete;
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete() && (getNextPage() != null)
+ && (newFile.getSelection() == true);
+ }
+
+ /**
+ * Creates new bundle map if no one was specified
+ * during initialization of the page.
+ *
+ * @param editor the source editor
+ * @return the new bundle map
+ */
+ private BundleMap createBundleMap(StructuredTextEditor editor) {
+ String uri = null;
+ String prefix = null;
+ int hash;
+ Map<?, ?> map = null;
+ BundleMap bm = new BundleMap();
+ bm.init(editor);
+
+ /*
+ * Check JSF Nature
+ */
+ boolean hasJsfProjectNatureType = false;
+ try {
+ IEditorInput ei = editor.getEditorInput();
+ if(ei instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)ei).getFile().getProject();
+ if (project.exists() && project.isOpen()) {
+ if (project.hasNature(WebProject.JSF_NATURE_ID)) {
+ hasJsfProjectNatureType = true;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ /*
+ * Get Bundles from faces-config.xml
+ */
+ if (hasJsfProjectNatureType
+ && (editor.getEditorInput() instanceof IFileEditorInput)) {
+ IProject project = ((IFileEditorInput) editor.getEditorInput())
+ .getFile().getProject();
+ IModelNature modelNature = EclipseResourceUtil.getModelNature(project);
+ if (modelNature != null) {
+ XModel model = modelNature.getModel();
+ List<Object> l = WebPromptingProvider.getInstance().getList(model,
+ WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
+ if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
+ map = (Map<?, ?>) l.get(1);
+ if ((null != map) && (map.keySet().size() > 0)) {
+ Iterator<?> it = map.keySet().iterator();
+ while (it.hasNext()) {
+ uri = it.next().toString();
+ prefix = map.get(uri).toString();
+ hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
+ bm.addBundle(hash, prefix, uri, false);
+ }
+ }
+ }
+ }
+ }
+ ISourceEditingTextTools sourceEditingTextTools =
+ (ISourceEditingTextTools) editor
+ .getAdapter(ISourceEditingTextTools.class);
+ IDOMSourceEditingTextTools domSourceEditingTextTools =
+ (IDOMSourceEditingTextTools) sourceEditingTextTools;
+ Document documentWithBundles = domSourceEditingTextTools.getDOMDocument();
+
+ /*
+ * When facelets are used -- get bundles from the template file
+ */
+ if (editor instanceof JSPTextEditor) {
+ IVisualContext context = ((JSPTextEditor) editor).getPageContext();
+ List<TaglibData> taglibs = null;
+ 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 {
+ Element root =
FaceletsUtil.findComponentElement(documentWithBundles.getDocumentElement());
+ if ((root != null) && FaceletsUtil.isFacelet(root, taglibs)
+ && root.hasAttribute("template")) { //$NON-NLS-1$
+ String filePath= root.getAttributeNode("template").getNodeValue();
//$NON-NLS-1$
+ if (((JSPTextEditor) editor).getEditorInput() instanceof FileEditorInput) {
+ FileEditorInput fei = (FileEditorInput) ((JSPTextEditor) editor).getEditorInput();
+ IFile templateFile = (IFile)
fei.getFile().getProject().getFolder("WebContent").findMember(filePath);
//$NON-NLS-1$
+ Document document = null;
+ try {
+ IDOMModel wtpModel =
(IDOMModel)StructuredModelManager.getModelManager().getModelForRead(templateFile);
+ if (wtpModel != null) {
+ document = wtpModel.getDocument();
+ }
+ } catch(IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ } catch(CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ if (null != document) {
+ /*
+ * Change the document where to look bundles
+ */
+ documentWithBundles = document;
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Add bundles from <f:loadBundle> tags on the current page
+ */
+ NodeList list = documentWithBundles.getElementsByTagName("f:loadBundle");
//$NON-NLS-1$
+ for (int i = 0; i < list.getLength(); i++) {
+ Element node = (Element) list.item(i);
+ uri = node.getAttribute("basename"); //$NON-NLS-1$
+ prefix = node.getAttribute("var"); //$NON-NLS-1$
+ hash = node.hashCode();
+ bm.addBundle(hash, prefix, uri, false);
+ }
+ return bm;
+ }
+
+ /**
+ * 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
+ * from the bundles list.
+ *
+ * @param bundleName the resource bundle name
+ */
+ private void setResourceBundlePath(String bundleName) {
+ IFile bundleFile = bm.getBundleFile(bundleName);
+ String bundlePath = Constants.EMPTY;
+ if (bundleFile != null) {
+ bundlePath = bundleFile.getFullPath().toString();
+ updateTable(bundleFile);
+ } else {
+ JspEditorPlugin.getDefault().logError(
+ "Could not get Bundle File for resource '" //$NON-NLS-1$
+ + bundleName + "'"); //$NON-NLS-1$
+ }
+ propsFile.setText(bundlePath);
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.i18n;
+
+import java.util.Locale;
+
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+/**
+ * This interface is intended for creation extensions of {@code localeProvider}
+ * extension point.
+ *
+ * @author yradtsevich
+ */
+public interface ILocaleProvider {
+ /**
+ * Returns the locale for given {@code editor}. Implementations
+ * may return {@code null} if they can not determine the locale.
+ */
+ Locale getLocale(StructuredTextEditor editor);
+
+ /**
+ * Shows the string representation of the locale
+ * returned by #getLocale(StructuredTextEditor) method.
+ *
+ * @return the string representation of the locale
+ */
+ String getLocaleString();
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
(from rev 25118,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.i18n;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+
+/**
+ * Aggregates extensions of all {@code localeProvider} extension points.
+ * This class is a singleton.
+ * <P>
+ * Typical use of this class:
+ * <code>MainLocaleProvider.getInstance().getLocale(editor)</code>
+ *
+ * @author yradtsevich
+ */
+public class MainLocaleProvider implements ILocaleProvider {
+ private static final String ELEMENT_NATURE = "nature"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
+ private static final String ELEMENT_LOCALE_PROVIDER = "localeProvider";
//$NON-NLS-1$
+ private Map<String, ? extends List<IExtension>> natureToExtensions;
+ private Map<IExtension, ILocaleProvider> extensionToProvider
+ = new HashMap<IExtension, ILocaleProvider>();
+ private IExtensionPoint extensionPoint;
+ private static MainLocaleProvider instance;
+
+ private String localeString = ""; //$NON-NLS-1$
+
+ /**
+ * The constructor
+ */
+ private MainLocaleProvider() {
+ extensionPoint =
RegistryFactory.getRegistry().getExtensionPoint(JspEditorPlugin.EXTESION_POINT_LOCALE_PROVIDER);
+ initNatureExtensionsMap();
+ }
+
+ /**
+ * Returns a shared instance of {@link MainLocaleProvider}.
+ */
+ public static MainLocaleProvider getInstance() {
+ if (instance == null) {
+ instance = new MainLocaleProvider();
+ }
+ return instance;
+ }
+
+ /**
+ * Tries to determine the locale of the {@code editor} using
+ * {@code localeProvider} extensions. Returns the default
+ * system locale if nothing found (never returns {@code null}).
+ */
+ public Locale getLocale(StructuredTextEditor editor) {
+ IEditorInput editorInput = editor.getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editorInput)
+ .getFile().getProject();
+
+ try {
+ if(project.isAccessible()) {
+ String[] natures = project.getDescription().getNatureIds();
+ for (String natureId : natures) {
+ for (ILocaleProvider provider : getProviders(natureId)) {
+ Locale locale = provider.getLocale(editor);
+ if (locale != null) {
+ localeString = provider.getLocaleString();
+ return locale;
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(
+ MessageFormat.format("Error in getting locale for
{0}.",((IFileEditorInput)editorInput)
+ .getFile().getLocation().toOSString()), e);
+ }
+ }
+
+ return Locale.getDefault();
+ }
+
+ private void initNatureExtensionsMap() {
+ Map<String, ArrayList<IExtension>> natureExtensionsMap
+ = new HashMap<String, ArrayList<IExtension>>();
+
+ IExtension[] extensions
+ = extensionPoint.getExtensions();
+
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements
+ = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ if (ELEMENT_NATURE.equals(element.getName())) {
+ String natureId = element.getAttribute(ATTRIBUTE_ID);
+ ArrayList<IExtension> extensionList
+ = natureExtensionsMap.get(natureId);
+
+ if (extensionList == null) {
+ extensionList = new ArrayList<IExtension>();
+ natureExtensionsMap.put(natureId, extensionList);
+ }
+
+ extensionList.add(extension);
+ }
+ }
+ }
+
+ for (ArrayList<IExtension> configurationsList
+ : natureExtensionsMap.values()) {
+ configurationsList.trimToSize();
+ }
+
+ this.natureToExtensions = natureExtensionsMap;
+ }
+
+ /**
+ * Returns all available instances of {@link ILocaleProvider} for given
+ * {@code natureId}. It loads extensions using lazy initialization.
+ */
+ private List<ILocaleProvider> getProviders(String natureId) {
+ List<IExtension> extensions = natureToExtensions.get(natureId);
+ if (extensions == null) {
+ return Collections.emptyList();
+ }
+
+ List<ILocaleProvider> providers
+ = new ArrayList<ILocaleProvider>(extensions.size());
+
+ for (IExtension extension : extensions) {
+ ILocaleProvider provider
+ = extensionToProvider.get(extension);
+
+ if (provider == null) {
+ provider = createLocaleProvider(extension);
+ }
+ if (provider != null) {
+ providers.add(provider);
+ }
+ }
+
+ return providers;
+ }
+
+ private ILocaleProvider createLocaleProvider(IExtension extension) {
+ ILocaleProvider provider = null;
+ try {
+ for (IConfigurationElement element
+ : extension.getConfigurationElements()) {
+ if (ELEMENT_LOCALE_PROVIDER.equals(element.getName())) {
+ provider = (ILocaleProvider) element
+ .createExecutableExtension(ATTRIBUTE_CLASS);
+ extensionToProvider.put(extension, provider);
+ break;
+ }
+ }
+ } catch (InvalidRegistryObjectException e) {
+ JspEditorPlugin.getPluginLog().logError(
+ "The extension registry object " //$NON-NLS-1$
+ + "is no longer valid.", e); //$NON-NLS-1$
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(
+ "CoreException occured.", e); //$NON-NLS-1$
+ }
+ return provider;
+ }
+
+ public String getLocaleString() {
+ return localeString;
+ }
+
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -82,6 +82,7 @@
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.editor.IVisualEditorFactory;
import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
@@ -116,6 +117,8 @@
private int previewIndex=-1;//by default 1, so if there no visual editor impl, this tab
will be not available
// private boolean osWindows = true;
+
+ private BundleMap bundleMap;
protected XModelTreeListenerSWTASync syncListener = new XModelTreeListenerSWTASync(
this);
@@ -460,10 +463,19 @@
}
private void createPagesForVPE() {
+ /*
+ * Create Source Editor and BundleMap
+ */
sourceEditor = new JSPTextEditor(this);
+ /*
+ * Create Bundle Map here but Initialize it in the VpeController
+ * or here if there is only the source part.
+ */
+ bundleMap = new BundleMap();
+
if (visualEditorFactory != null) {
visualEditor = visualEditorFactory.createVisualEditor(this,
- sourceEditor, false);
+ sourceEditor, false, bundleMap);
}
try {
if (visualEditor != null) {
@@ -510,7 +522,16 @@
} catch (PartInitException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
-
+
+ /*
+ * When there is only the source part --
+ * then VpeController very likely hasn't been created.
+ * Thus Bundle Map should be initialized here instead of
+ * VpeController.
+ */
+ if (visualEditor == null) {
+ bundleMap.init(sourceEditor);
+ }
}
public void doSave(IProgressMonitor monitor) {
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-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -128,5 +128,33 @@
public static String CONFIRM_SELECTION_BAR_DIALOG_TOGGLE_MESSAGE;
public static String SelectionBar_MoreNodes;
public static String HIDE_SELECTION_BAR;
+
+ public static String EXTERNALIZE_STRINGS;
+ public static String EXTERNALIZE_STRINGS_DIALOG_TITLE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION;
+ public static String EXTERNALIZE_STRINGS_DIALOG_TEXT_STRING;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP;
+ public static String EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR;
+ public static String EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING;
+ public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION;
+ public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY;
+ public static String EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET;
+ public static String EXTERNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET;
+ public static String EXTERNALIZE_STRINGS_DIALOG_NEW_FILE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY;
+ public static String EXTERNALIZE_STRINGS_DIALOG_DEFAULT_VALUE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME;
+ public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE;
+ public static String EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS;
+ 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;
}
\ 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-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-09-30
14:27:08 UTC (rev 25332)
@@ -105,4 +105,33 @@
CONFIRM_SELECTION_BAR_DIALOG_MESSAGE=Hide selection bar?
CONFIRM_SELECTION_BAR_DIALOG_TOGGLE_MESSAGE=Always hide selection bar without prompt
SelectionBar_MoreNodes=More Nodes...
-HIDE_SELECTION_BAR=Hide selection bar
\ No newline at end of file
+HIDE_SELECTION_BAR=Hide selection bar
+
+# Externalize Strings Dialog
+EXTERNALIZE_STRINGS=Externalize strings
+EXTERNALIZE_STRINGS_DIALOG_TITLE=Externalize Strings
+EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION=Externalize your strings via properties file
+EXTERNALIZE_STRINGS_DIALOG_TEXT_STRING=Text string:
+EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY=Property key:
+EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE=Property value:
+EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE=Properties file:
+EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST=Select resource bundle:
+EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP=Externalize strings
+EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP=Handle properties file
+EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR=Could not initialize externalization
dialog!
+EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING=Could not initialize resource bundles!
+EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION=Wrong selection! Please select correct
string.
+EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT=Wrong selected text. Please select correct
string.
+EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE=- Please select bundle -
+EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY=Selected text is empty
+EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET=Key must be set
+EXTERNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET=Value must be set
+EXTERNALIZE_STRINGS_DIALOG_NEW_FILE=Create a new properties file (See details on the next
page)
+EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY=key
+EXTERNALIZE_STRINGS_DIALOG_DEFAULT_VALUE=value
+EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME=Property name
+EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE=Property value
+EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS=Such a key already exists
+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!
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -71,15 +71,18 @@
public static final String EMPTY = ""; //$NON-NLS-1$
public static final String WHITE_SPACE = " "; //$NON-NLS-1$
- public static String COLON = ":"; //$NON-NLS-1$
- public static String SEMICOLON = ";"; //$NON-NLS-1$
- public static String COMMA = ","; //$NON-NLS-1$
- public static String DOT = "."; //$NON-NLS-1$
- public static String DASH = "-"; //$NON-NLS-1$
- public static String SLASH = "/"; //$NON-NLS-1$
- public static String EQUAL = "="; //$NON-NLS-1$
+ public static final String COLON = ":"; //$NON-NLS-1$
+ public static final String SEMICOLON = ";"; //$NON-NLS-1$
+ public static final String COMMA = ","; //$NON-NLS-1$
+ public static final String DOT = "."; //$NON-NLS-1$
+ public static final String DASH = "-"; //$NON-NLS-1$
+ public static final String SLASH = "/"; //$NON-NLS-1$
+ public static final String EQUAL = "="; //$NON-NLS-1$
+ public static final String UNDERSCORE = "_"; //$NON-NLS-1$
public static final String START_BRACKET = "("; //$NON-NLS-1$
public static final String END_BRACKET = ")"; //$NON-NLS-1$
+ public static final String GT = ">"; //$NON-NLS-1$
+ public static final String LT = "<"; //$NON-NLS-1$
public static final String LEFT_BRACE = "{"; //$NON-NLS-1$
public static final String RIGHT_BRACE = "}"; //$NON-NLS-1$
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/FaceletsUtil.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/FaceletsUtil.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/FaceletsUtil.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -0,0 +1,48 @@
+package org.jboss.tools.jst.jsp.util;
+
+import java.util.List;
+
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class FaceletsUtil {
+
+ public static final String TAG_COMPOSITION = "composition"; //$NON-NLS-1$
+ public static final String TAG_COMPONENT = "component"; //$NON-NLS-1$
+ public static final String FACELETS_URI = "http://java.sun.com/jsf/facelets";
//$NON-NLS-1$
+
+ public static Element findComponentElement(Element root) {
+ if(root==null) {
+ return null;
+ }
+ NodeList children = root.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element trimmedElement = findComponentElement((Element) child);
+ if (trimmedElement != null)
+ return trimmedElement;
+ }
+ }
+ if (TAG_COMPOSITION.equalsIgnoreCase(root.getLocalName())
+ || TAG_COMPONENT.equalsIgnoreCase(root.getLocalName())) {
+ return root;
+ }
+ return null;
+ }
+
+ public static boolean isFacelet(Node sourceNode, List<TaglibData> taglibs) {
+ boolean isFacelet = false;
+ String sourcePrefix = sourceNode.getPrefix();
+ TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourcePrefix, taglibs);
+ if (null != sourceNodeTaglib) {
+ String sourceNodeUri = sourceNodeTaglib.getUri();
+ if (FACELETS_URI.equalsIgnoreCase(sourceNodeUri)) {
+ isFacelet = true;
+ }
+ }
+ return isFacelet;
+ }
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -183,14 +183,11 @@
* @return
*/
public static TaglibData getTaglibForPrefix(String prefix, List<TaglibData>
taglibData){
-
for (TaglibData data : taglibData) {
-
if(data.getPrefix()!=null && data.getPrefix().equalsIgnoreCase(prefix)) {
return data;
}
}
-
return null;
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2010-09-30 14:13:11 UTC
(rev 25331)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2010-09-30 14:27:08 UTC
(rev 25332)
@@ -11,11 +11,9 @@
org.jboss.tools.vpe,
org.jboss.tools.vpe.dnd,
org.jboss.tools.vpe.editor,
- org.jboss.tools.vpe.editor.bundle,
org.jboss.tools.vpe.editor.context,
org.jboss.tools.vpe.editor.dnd.context,
org.jboss.tools.vpe.editor.dnd.context.xpl,
- org.jboss.tools.vpe.editor.i18n,
org.jboss.tools.vpe.editor.mapping,
org.jboss.tools.vpe.editor.menu,
org.jboss.tools.vpe.editor.menu.action,
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2010-09-30 14:13:11 UTC (rev 25331)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2010-09-30 14:27:08 UTC (rev 25332)
@@ -2,9 +2,7 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="templates" name="Path to xml file with
templates definitionj" schema="schema/templates.exsd"/>
- <extension-point id="localeProvider" name="Locale provider for an
opened file" schema="schema/localeProvider.exsd"/>
-
<extension point="org.jboss.tools.common.model.meta">
<meta path="meta/vpe.meta"/>
</extension>
@@ -99,13 +97,6 @@
id="org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
</dynamic>
</menuContribution>
- <menuContribution
-
locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor.source.EditorContext?after=org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
- <dynamic
-
class="org.jboss.tools.vpe.editor.menu.ExternalizeStringsContributionItem"
-
id="org.jboss.tools.vpe.editor.menu.ExternalizeStringsContributionItem">
- </dynamic>
- </menuContribution>
</extension>
<extension
point="org.eclipse.ui.menus">
@@ -126,13 +117,6 @@
id="org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
</dynamic>
</menuContribution>
- <menuContribution
-
locationURI="popup:org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor.source.EditorContext?after=org.jboss.tools.vpe.editor.menu.SetupTemplateContributionItem">
- <dynamic
-
class="org.jboss.tools.vpe.editor.menu.ExternalizeStringsContributionItem"
-
id="org.jboss.tools.vpe.editor.menu.ExternalizeStringsContributionItem">
- </dynamic>
- </menuContribution>
</extension>
<extension
Deleted: trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd 2010-09-30 14:13:11
UTC (rev 25331)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd 2010-09-30 14:27:08
UTC (rev 25332)
@@ -1,129 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.vpe"
xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.jboss.tools.vpe"
id="localeProvider" name="Locale provider for an opened file"/>
- </appInfo>
- <documentation>
- This extension point is intented to determine the locale
- of an opened document in the VPE.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="localeProvider"/>
- <element ref="nature" minOccurs="1"
maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string"
use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="localeProvider">
- <annotation>
- <documentation>
- The locale provider class description.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string"
use="required">
- <annotation>
- <documentation>
- Fully qualified class name of a ILocaleProvider implementation.
- </documentation>
- <appInfo>
- <meta.attribute kind="java"
basedOn=":org.jboss.tools.vpe.editor.ILocaleProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="nature">
- <annotation>
- <documentation>
- Project nature IDs, in which the localeProvider is able to determine the
locale.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string"
use="required">
- <annotation>
- <documentation>
- Nature ID.
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier"
basedOn="org.eclipse.core.resources.natures/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -30,7 +30,6 @@
public static final String PLUGIN_ID = "org.jboss.tools.vpe"; //$NON-NLS-1$
public static final String EXTESION_POINT_VPE_TEMPLATES =
"org.jboss.tools.vpe.templates"; //$NON-NLS-1$
- public static final String EXTESION_POINT_LOCALE_PROVIDER =
"org.jboss.tools.vpe.localeProvider"; //$NON-NLS-1$
//The shared instance.
private static VpePlugin plugin;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -81,6 +81,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.resref.core.ResourceReferenceListListener;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
@@ -92,7 +93,6 @@
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.dnd.VpeDnD;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
@@ -178,8 +178,8 @@
private int commentRemoveCount = 0;
private int commentAddCount = 0;
private VpePageContext pageContext;
- private BundleMap bundle;
private VpeEditorPart editPart;
+ private BundleMap bundleMap;
public static final int LEFT_BUTTON = 0;
private CSSReferenceList cssReferenceListListener;
@@ -226,17 +226,17 @@
dropWindow = new VpeDropWindow(editPart.getSite().getShell());
}
- void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor) {
+ void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor, BundleMap
bundleMap) {
this.sourceEditor = sourceEditor;
+ this.bundleMap = bundleMap;
if (sourceEditor instanceof IJSPTextEditor) {
((IJSPTextEditor) sourceEditor).setVPEController(this);
dropWindow.setEditor((IJSPTextEditor) sourceEditor);
}
this.visualEditor = visualEditor;
visualEditor.setController(this);
- bundle = new BundleMap();
- bundle.init(sourceEditor);
- pageContext = new VpePageContext(bundle, editPart);
+ bundleMap.init(sourceEditor);
+ pageContext = new VpePageContext(bundleMap, editPart);
domMapping = new VpeDomMapping(pageContext);
sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
VpeTemplateManager.getInstance(), sourceEditor, pageContext);
@@ -977,8 +977,8 @@
model.removeModelLifecycleListener(this);
IDOMModel sourceModel = (IDOMModel) getModel();
sourceModel.addModelLifecycleListener(this);
- bundle.clearAll();
- bundle.refresh();
+ bundleMap.clearAll();
+ bundleMap.refresh();
// visualBuilder.setSelectionRectangle(null);
IDOMDocument sourceDocument = sourceModel.getDocument();
// JBIDE-1457
@@ -1721,8 +1721,8 @@
VpeTemplateManager.getInstance().reload();
- if (bundle != null) {
- bundle.refresh();
+ if (bundleMap != null) {
+ bundleMap.refresh();
if (pageContext != null) {
if (!switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -69,6 +69,7 @@
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.util.ModelUtilities;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.jspeditor.StorageRevisionEditorInputAdapter;
import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
@@ -95,6 +96,7 @@
protected EditorSettings editorSettings;
private StructuredTextEditor sourceEditor = null;
private MozillaEditor visualEditor;
+ private BundleMap bundleMap;
private IEditorPart activeEditor;
private ControlListener controlListener;
private XModelTreeListener listener;
@@ -245,9 +247,10 @@
}
public VpeEditorPart(EditorPart multiPageEditor,
- StructuredTextEditor textEditor, boolean visualMode) {
+ StructuredTextEditor textEditor, boolean visualMode, BundleMap bundleMap) {
sourceEditor = textEditor;
// this.visualMode = visualMode;
+ this.bundleMap = bundleMap;
this.multiPageEditor = multiPageEditor;
}
@@ -876,9 +879,7 @@
visualEditor.setEditorLoadWindowListener(null);
VpeController vpeController = new VpeController(
VpeEditorPart.this);
-// selectionBar.setVpeController(vpeController);
-// vpeController.setSelectionBarController(selectionBar);
- vpeController.init(sourceEditor, visualEditor);
+ vpeController.init(sourceEditor, visualEditor, bundleMap);
}
});
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPartFactory.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPartFactory.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPartFactory.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -13,13 +13,14 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.editor.IVisualEditorFactory;
public class VpeEditorPartFactory implements IVisualEditorFactory {
- public IVisualEditor createVisualEditor(final EditorPart multiPageEditor,
StructuredTextEditor textEditor, boolean visualMode) {
- return new VpeEditorPart(multiPageEditor, textEditor, visualMode){
+ public IVisualEditor createVisualEditor(final EditorPart multiPageEditor,
StructuredTextEditor textEditor, boolean visualMode, BundleMap bundleMap) {
+ return new VpeEditorPart(multiPageEditor, textEditor, visualMode, bundleMap) {
public void doSave(IProgressMonitor monitor){
multiPageEditor.doSave(monitor);
}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,667 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.vpe.editor.bundle;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.event.XModelTreeEvent;
-import org.jboss.tools.common.model.event.XModelTreeListener;
-import org.jboss.tools.common.model.options.PreferenceModelUtilities;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
-import org.jboss.tools.jst.web.project.WebProject;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.i18n.MainLocaleProvider;
-import org.jboss.tools.vpe.editor.util.Constants;
-
-public class BundleMap {
-
- public static final String TITLE_ATTRIBUTE_NAME = "title"; //$NON-NLS-1$
- private static final String[] JSF_PROJECT_NATURES = {
- WebProject.JSF_NATURE_ID
- };
-
- private BundleMapListener[] bundleMapListeners = new BundleMapListener[0];
- private StructuredTextEditor editor;
-
- private String[] javaSources;
- /*
- * Stores the current VPE locale.
- */
- private Locale locale;
- private BundleEntry[] bundles = new BundleEntry[0];
- private Map<String,UsedKey> usedKeys = new HashMap<String,UsedKey>();
-
- boolean showBundleUsageAsEL =
JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
- IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL);
-
- XModelTreeListener modelListener = new ML();
-
- public void init(StructuredTextEditor editor){
- this.editor = editor;
- IEditorInput input = editor.getEditorInput();
-
- if (input instanceof IFileEditorInput) {
- javaSources =
getJavaProjectSrcLocations(((IFileEditorInput)input).getFile().getProject());
- }
- /*
- * Initialize the locale with default value.
- */
- locale = MainLocaleProvider.getInstance().getLocale(editor);
- refreshRegisteredBundles();
- PreferenceModelUtilities.getPreferenceModel().addModelTreeListener(modelListener);
- }
-
- public void refreshRegisteredBundles() {
- if (hasJsfProjectNatureType()
- && (editor.getEditorInput() instanceof IFileEditorInput)) {
- IProject project = ((IFileEditorInput) editor.getEditorInput())
- .getFile().getProject();
- IModelNature modelNature = EclipseResourceUtil
- .getModelNature(project);
- if (modelNature != null) {
- XModel model = modelNature.getModel();
- List<Object> l = WebPromptingProvider.getInstance().getList(
- model, WebPromptingProvider.JSF_REGISTERED_BUNDLES,
- null, null);
- if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
- Map<?, ?> map = (Map<?, ?>) l.get(1);
- /*
- * Fix for
https://jira.jboss.org/jira/browse/JBIDE-5218
- * When updating f:view's locale attribute right after
- * template creation - map of registered bundles is empty
- * and couldn't be updated. To change bundle's locale they
- * should be accessed through <code>bundles</code> variable.
- */
- if (map.keySet().size() > 0) {
- Iterator<?> it = map.keySet().iterator();
- while (it.hasNext()) {
- String uri = it.next().toString();
- String prefix = map.get(uri).toString();
- int hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
- removeBundle(hash);
- addBundle(hash, prefix, uri, true);
- }
- } else if (bundles.length > 0) {
- for (int i = 0; i < bundles.length; i++) {
- String uri = bundles[i].uri;
- String prefix = bundles[i].prefix;
- int hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
- removeBundle(hash);
- addBundle(hash, prefix, uri, true);
- }
- }
- }
- }
- }
- }
-
- public void clearAll() {
- bundles = new BundleEntry[0];
- usedKeys = new HashMap<String,UsedKey>();
- }
-
- public void dispose() {
- PreferenceModelUtilities.getPreferenceModel().removeModelTreeListener(modelListener);
- }
-
- public boolean isShowBundleUsageAsEL() {
- return showBundleUsageAsEL;
- }
-
- private boolean hasJsfProjectNatureType() {
- boolean hasJsfProjectNatureType = false;
- try {
- IEditorInput ei = editor.getEditorInput();
- if(ei instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)ei).getFile().getProject();
- if (project.exists() && project.isOpen()) {
- for (int i = 0; i < JSF_PROJECT_NATURES.length; i++) {
- if (project.hasNature(JSF_PROJECT_NATURES[i]))
- hasJsfProjectNatureType = true;
- break;
- }
- }
- }
- } catch (CoreException e) {
- VpePlugin.getPluginLog().logError(e);
- }
- return hasJsfProjectNatureType;
- }
-
- public boolean openBundle(String expression, String locale){
- List<ELInstance> is = parseJSFExpression(expression);
- if(is == null || is.size() == 0) return false;
- String prefix = null;
- String propertyName = null;
- for (ELInstance i: is) {
- ELExpression expr = i.getExpression();
- if(expr == null) continue;
- List<ELInvocationExpression> invs = expr.getInvocations();
- if(invs.size() > 0) {
- String[] values = getCall(invs.get(0));
- if(values != null) {
- prefix = values[0];
- propertyName = values[1];
- break;
- }
- }
- }
- if(prefix == null) return false;
-
- BundleEntry entry = getBundle(prefix);
-
- 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$
- }
- WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_BEAN_OPEN,
prefix2, null);
- }
- return false;
- }
-
- if (hasJsfProjectNatureType()) {
- Properties p = new Properties();
- p.put(WebPromptingProvider.BUNDLE, entry.uri);
- 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);
- return (error == null || error.length() == 0);
- }
- return false;
- }
-
- /**
- * Gets the bundle file based on the locale
- * from the loaded resource bundle.
- *
- * @param uri the uri
- * @return the bundle file
- */
- public IFile getBundleFile(String uri){
- IEditorInput input = editor.getEditorInput();
- IProject project = ((FileEditorInput)input).getFile().getProject();
- if(project == null || !project.isOpen()) {
- return null;
- }
- try {
- if(!project.hasNature(JavaCore.NATURE_ID)) {
- return null;
- }
- IJavaProject javaProject = JavaCore.create(project);
- IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
- for (int i = 0; i < es.length; i++) {
- if(es[i].getEntryKind() != IClasspathEntry.CPE_SOURCE) {
- continue;
- }
- IFile file = (IFile) project.getWorkspace().getRoot()
- .getFolder(es[i].getPath()).findMember("/" + getBundleFileName(uri));
//$NON-NLS-1$
- if(file != null && file.exists()) {
- return file;
- }
- }
- } catch (CoreException e) {
- VpePlugin.getPluginLog().logError(e);
- return null;
- }
- return null;
- }
-
- /**
- * Gets the bundle file name.
- * <a
href="https://jira.jboss.org/browse/JBIDE-6729">
- * Related Jira</a>
- *
- * @param uri the uri
- * @return the bundle file name
- */
- private String getBundleFileName(String uri) {
- String resultUri = uri.replace('.','/');
- ResourceBundle bundle = getBundleByUrl(uri, locale);
- String localeString = bundle.getLocale().toString();
- if ((null != localeString) && (localeString.length() > 0)) {
- /*
- * getLanguage() method in ResourceBundle could return "en_us" string.
- * Bundle's file is case sensitive thus country name
- * should be transformed to UpperCase.
- */
- String[] parts = localeString.split(Constants.UNDERSCORE);
- if (parts.length == 2) {
- parts[1] = parts[1].toUpperCase();
- }
- for (String part : parts) {
- resultUri += Constants.UNDERSCORE + part;
- }
- }
- resultUri += ".properties"; //$NON-NLS-1$
- return resultUri;
- }
-
- private ResourceBundle getBundleByUrl(String uri, Locale locale) {
- try {
- if (javaSources!=null) {
- File file;
- URL[] urls = new URL[javaSources.length];
- for (int i=0;i<javaSources.length;++i) {
- try {
- file = new File(javaSources[i]).getCanonicalFile();
- urls[i] = file.toURL();
- } catch (IOException ioe) {
- VpePlugin.reportProblem(ioe);
- return null;
- }
- }
-
- ClassLoader classLoader = new URLClassLoader(urls,
ClassLoader.getSystemClassLoader());
- ResourceBundle bundle = ResourceBundle.getBundle(uri, locale, classLoader);
- return bundle;
- }
- } catch (MissingResourceException ex) {
- // Ignore this exception
- }
-
- return null;
- }
-
- private static String[] getJavaProjectSrcLocations(IProject project) {
- return EclipseResourceUtil.getJavaProjectSrcLocations(project);
- }
-
- private void removeBundle(int hashCode, boolean refresh) {
- if (bundles.length == 0) {
- return;
- }
- int index = -1;
- for (int i = 0; i < bundles.length; i++) {
- if (hashCode == bundles[i].hashCode){
- index = i;
- break;
- }
- }
- if (index == -1) {
- return;
- }
- if (bundles.length == 1) {
- bundles = new BundleEntry[0];
- return;
- }
- BundleEntry[] newBundles = new BundleEntry[bundles.length - 1];
- System.arraycopy(bundles, 0, newBundles, 0, index);
- System.arraycopy(bundles, index + 1, newBundles, index, bundles.length - index - 1);
- bundles = newBundles;
- if (refresh) {
- refreshUsedKeys();
- }
- }
-
- public void removeBundle(int hashCode) {
- removeBundle(hashCode, true);
- }
-
- public void addBundle(int hashCode, String prefix, String uri,boolean refresh) {
- ResourceBundle bundle = getBundleByUrl(uri, locale);
- BundleEntry entry = new BundleEntry(bundle, uri, prefix, hashCode);
- if (bundle != null) {
- BundleEntry[] newBundles = new BundleEntry[bundles.length + 1];
- System.arraycopy(bundles, 0, newBundles, 0, bundles.length);
- bundles = newBundles;
- bundles[bundles.length - 1] = entry;
- }
- if (refresh) {
- refreshUsedKeys();
- }
- }
-
- public void changeBundle(int hashCode, String prefix, String uri){
- removeBundle(hashCode, false);
- addBundle(hashCode, prefix, uri, true);
- }
-
- private void changeBundleWithoutRefresh(int hashCode, String prefix, String uri){
- removeBundle(hashCode, false);
- addBundle(hashCode, prefix, uri, false);
- }
-
- private BundleEntry getBundle(String prefix) {
- if (prefix == null) {
- return null;
- }
- BundleEntry lastBundle = null;
- for (int i = 0; i < bundles.length; i++) {
- if (prefix.equals(bundles[i].prefix)) {
- lastBundle = bundles[i];
- }
- }
- return lastBundle;
- }
-
- public void refresh(){
- refreshRegisteredBundles();
- IEditorInput input = editor.getEditorInput();
-
- if (input instanceof IFileEditorInput) {
- javaSources =
getJavaProjectSrcLocations(((IFileEditorInput)input).getFile().getProject());
- UsedKey key;
- UsedKey[] array = new UsedKey[0];
- array = usedKeys.values().toArray(array);
-
- for(int i=0; i<array.length;i++){
- key = (UsedKey)array[i];
- changeBundleWithoutRefresh(key.hashCode, key.prefix, key.uri);
- }
- refreshUsedKeys();
- }
- }
-
- private void refreshUsedKeys(){
- UsedKey keyValue;
-
-
- /* yradtsevich: Fix of JBIDE-5818. The map usedKey cannot be modified
- * in the following foreach loop. Therefore the keys to remove
- * are marked and removed after the loop. */
- List<String> keysToBeRemoved = new ArrayList<String>(0);
-
- Set<String> usedKeysSet = this.usedKeys.keySet();
- for(String key : usedKeysSet){
- keyValue =this.usedKeys.get(key);
- BundleEntry entry = getBundle(keyValue.prefix);
- if(entry != null){
- String value;
- try{
- value = (String)entry.bundle.getObject(keyValue.key);
- }catch(MissingResourceException ex){
- value = null;
- fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
- // Fix of JBIDE-5818
- keysToBeRemoved.add(key);
- continue;
- }
- if((value == null && keyValue.value != null) || (value != null &&
keyValue.value == null)){
- keyValue.value = value;
- fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
- continue;
- }else if(value != null && keyValue.value != null &&
!value.equals(keyValue.value)){
- keyValue.value = value;
- fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
- continue;
- }
- } else{
- keyValue.value = null;
- fireBundleKeyChanged(keyValue.prefix, keyValue.key, null);
- }
- }
-
- // Fix of JBIDE-5818
- for (String key : keysToBeRemoved) {
- this.usedKeys.remove(key);
- }
- }
-
- private List<ELInstance> parseJSFExpression(String expression){
- ELParser parser = ELParserUtil.getDefaultFactory().createParser();
- ELModel model = parser.parse(expression);
- List<ELInstance> is = model.getInstances();
- return is;
- }
-
- public String getBundleValue(String name){
- if(showBundleUsageAsEL) {
- return name;
- }
- List<ELInstance> is = parseJSFExpression(name);
- if(is == null) return null;
- StringBuffer sb = new StringBuffer();
- int index = 0;
- for (ELInstance i: is) {
- int start = i.getStartPosition();
- sb.append(name.substring(index, start));
- index = start;
- if(i.getExpression() instanceof ELInvocationExpression) {
- ELInvocationExpression expr = (ELInvocationExpression)i.getExpression();
- String[] values = getCall(expr);
- if(values != null) {
- String value = getBundleValue(values[0], values[1]);
- if(value != null) {
- sb.append(value);
- index = i.getEndPosition();
- }
-
- }
- }
- if(index < i.getEndPosition()) {
- //fix has been added by Maksim Areshkau
- //
https://jira.jboss.org/jira/browse/JBIDE-6064
- if(name.length()>i.getEndPosition()) {
- sb.append(name.substring(index, i.getEndPosition()));
- index = i.getEndPosition();
- }else {
- sb.append(name.substring(index, name.length()));
- index =name.length();
- }
- }
- }
- sb.append(name.substring(index));
- return sb.toString();
- }
-
- String[] getCall(ELInvocationExpression expr) {
- if(expr == null) return null;
- ELInvocationExpression left = expr.getLeft();
- if(left == null) return null;
- String name = expr.getMemberName();
- if(name == null || name.length() == 0) return null;
- if(expr instanceof ELPropertyInvocation) {
- return new String[]{left.getText(), name};
- } else if(expr instanceof ELArgumentInvocation) {
- if(name.startsWith("\"") || name.startsWith("'")) {
//$NON-NLS-1$ //$NON-NLS-2$
- name = name.substring(1);
- }
- if(name.endsWith("\"") || name.endsWith("'")) {
//$NON-NLS-1$ //$NON-NLS-2$
- name = name.substring(0, name.length() - 1);
- }
- if(name.length() == 0) return null;
- return new String[]{left.getText(), name};
- }
- return null;
- }
-
- private String getBundleValue(String prefix, String propertyName) {
- String bundleValue = null;
- BundleEntry entry = getBundle(prefix);
- if (entry != null) {
- String name = prefix + "." + propertyName; //$NON-NLS-1$
- try {
- bundleValue = (String) entry.bundle.getObject(propertyName);
- if (!usedKeys.containsKey(name))
- usedKeys.put(name, new UsedKey(entry.uri, prefix,
- propertyName, bundleValue, entry.hashCode));
- } catch (MissingResourceException ex) {
- /*
- * Null string will be returned.
- */
- }
- }
- return bundleValue;
- }
-
- public void addBundleMapListener(BundleMapListener listener) {
- if (listener != null) {
- BundleMapListener[] newBundleMapListener = new
BundleMapListener[bundleMapListeners.length + 1];
- System.arraycopy(bundleMapListeners, 0, newBundleMapListener, 0,
bundleMapListeners.length);
- bundleMapListeners = newBundleMapListener;
- bundleMapListeners[bundleMapListeners.length - 1] = listener;
- }
- }
-
- public void removeBundleMapListener(BundleMapListener listener) {
- if (listener == null || bundleMapListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < bundleMapListeners.length; i++) {
- if (listener == bundleMapListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (bundleMapListeners.length == 1) {
- bundleMapListeners = new BundleMapListener[0];
- return;
- }
- BundleMapListener[] newBundleMapListener = new
BundleMapListener[bundleMapListeners.length - 1];
- System.arraycopy(bundleMapListeners, 0, newBundleMapListener, 0, index);
- System.arraycopy(bundleMapListeners, index + 1, newBundleMapListener, index,
bundleMapListeners.length - index - 1);
- bundleMapListeners = newBundleMapListener;
- }
-
- private void fireBundleKeyChanged(String prefix, String key, String value) {
- for (int i = 0; i < bundleMapListeners.length; i++) {
- bundleMapListeners[i].bundleKeyChanged(prefix, key, value);
- }
- }
-
- public void updateShowBundleUsageAsEL(boolean showBundlesAsEL) {
- if(showBundleUsageAsEL != showBundlesAsEL) {
- showBundleUsageAsEL = showBundlesAsEL;
- refresh();
- }
- }
-
- public void updateShowBundleUsageAsEL() {
- updateShowBundleUsageAsEL(JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
- IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL));
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- static class Expression {
- public String prefix;
- public String propertyName;
- }
-
- /*
- *
https://jira.jboss.org/browse/JBIDE-6287
- * It was required to get access to BundleEntry class.
- */
- public static class BundleEntry {
- public ResourceBundle bundle;
- public String uri;
- public String prefix;
- public int hashCode;
-
- public BundleEntry(ResourceBundle bundle, String uri, String prefix,
- int hashCode) {
- this.bundle = bundle;
- this.uri = uri;
- this.prefix = prefix;
- this.hashCode = hashCode;
- }
-
- @Override
- public String toString() {
- return "BundleEntry [prefix=" + prefix + ", uri=" + uri + ",
hashCode=" + hashCode //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + ", bundle="+ bundle +"]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- static class UsedKey {
- public int hashCode;
- public String uri;
- public String prefix;
- public String key;
- public String value;
-
- public UsedKey(String uri, String prefix, String key, String value,
- int hashCode) {
- this.uri = uri;
- this.prefix = prefix;
- this.key = key;
- this.value = value;
- this.hashCode = hashCode;
-
- }
- }
-
- class ML implements XModelTreeListener {
-
- public void nodeChanged(XModelTreeEvent event) {
- updateShowBundleUsageAsEL();
- }
-
- public void structureChanged(XModelTreeEvent event) {
- }
-
- }
-
- /**
- * @param showBundleUsageAsEL the showBundleUsageAsEL to set
- */
- public void setShowBundleUsageAsEL(boolean showBundleUsageAsEL) {
- this.showBundleUsageAsEL = showBundleUsageAsEL;
- }
-
- public BundleEntry[] getBundles() {
- return bundles;
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMapListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMapListener.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMapListener.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.vpe.editor.bundle;
-
-public interface BundleMapListener {
- public void bundleKeyChanged(String bundlePrefix, String key, String value);
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -25,6 +25,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.tld.TaglibData;
@@ -32,7 +33,6 @@
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.jboss.tools.vpe.resref.core.AbsoluteFolderReferenceList;
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsDialog.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsDialog.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsDialog.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.vpe.editor.dialog;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-
-public class ExternalizeStringsDialog extends WizardDialog {
-
- public ExternalizeStringsDialog(Shell parentShell, IWizard newWizard) {
- super(parentShell, newWizard);
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button finishButton = getButton(IDialogConstants.FINISH_ID);
- finishButton.setText(IDialogConstants.OK_LABEL);
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizard.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizard.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizard.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * 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.vpe.editor.dialog;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.common.model.ui.ModelUIImages;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-public class ExternalizeStringsWizard extends Wizard {
-
- public String ExternalizeStringsWizardPageName =
"ExternalizeStringsWizardPage"; //$NON-NLS-1$
- public String NewFileCreationPageName = "NewFileCreationPage"; //$NON-NLS-1$
-
- StructuredTextEditor editor = null;
- BundleMap bm = null;
- ExternalizeStringsWizardPage page1 = null;
- WizardNewFileCreationPage page2 = null;
-
- public ExternalizeStringsWizard(StructuredTextEditor editor, BundleMap bm) {
- super();
- setHelpAvailable(false);
- setWindowTitle(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
- this.editor = editor;
- this.bm = bm;
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page1 = new ExternalizeStringsWizardPage(
- ExternalizeStringsWizardPageName, editor, bm);
- page2 = new WizardNewFileCreationPage(NewFileCreationPageName,
- (IStructuredSelection) editor.getSelectionProvider().getSelection()) {
- protected InputStream getInitialContents() {
- return new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
- }
- };
- page2.setTitle(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
- page2.setDescription(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
- page2.setImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
- addPage(page1);
- addPage(page2);
- }
-
- @Override
- public boolean canFinish() {
- return (!page1.isNewFile() && page1.isPageComplete())
- || (page1.isNewFile() && page2.isPageComplete());
- }
-
- @Override
- public boolean performFinish() {
- IFile bundleFile = null;
- if (page1.isNewFile()) {
- bundleFile = page2.createNewFile();
- } else {
- bundleFile = page1.getBundleFile();
- }
- /*
- * Exit when the file is null
- */
- if (bundleFile == null) {
- return false;
- }
- /*
- * Add "key=value" to the bundle if file is not new,
- * If it is new, it got input by getInitialContent()
- */
- if (bundleFile.exists() && !page1.isNewFile()) {
- InputStream is = new ByteArrayInputStream(page1.getKeyValuePair().getBytes());
- try {
- bundleFile.appendContents(is, false, true, null);
- is.close();
- is = null;
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- /*
- * Replace text in the editor
- */
- page1.replaceText();
-
- return true;
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,899 +0,0 @@
-/*******************************************************************************
- * 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.vpe.editor.dialog;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.document.NodeImpl;
-import org.eclipse.wst.xml.core.internal.document.TextImpl;
-import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.ui.ModelUIImages;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
-import org.jboss.tools.jst.jsp.jspeditor.SourceEditorPageContext;
-import org.jboss.tools.jst.web.project.WebProject;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
-import org.jboss.tools.vpe.editor.bundle.BundleMap.BundleEntry;
-import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
-import org.jboss.tools.vpe.editor.util.Constants;
-import org.jboss.tools.vpe.editor.util.FaceletUtil;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ExternalizeStringsWizardPage extends WizardPage {
-
- private final char[] REPLACED_CHARACTERS = new char[] {'~', '!',
'@', '#',
- '$', '%', '^', '&', '*', '(',
')', '-', '+', '=', '{', '}', '[',
']', ':', ';', ',', '.', '?',
'\\', '/'};
- private final char[] LINE_DELEMITERS = new char[] {'\r', '\n',
'\t'};
- private final int DIALOG_WIDTH = 450;
- private final int DIALOG_HEIGHT = 650;
- private StructuredTextEditor editor;
- private Text propsKey;
- private Text propsValue;
- private Button newFile;
- private Label propsFileLabel;
- private Text propsFile;
- private Label rbListLabel;
- private Combo rbCombo;
- private BundleMap bm;
- private Group propsFilesGroup;
- private Status propsKeyStatus;
- private Status propsValueStatus;
- private Status duplicateKeyStatus;
- private Table tagsTable;
-
-
- public ExternalizeStringsWizardPage(String pageName, StructuredTextEditor editor,
BundleMap bm) {
- /*
- * Setting dialog Title, Description, Image.
- */
- super(pageName,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
- ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_DEFAULT));
- setDescription(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION);
- setPageComplete(false);
- this.editor = editor;
- if (bm != null) {
- this.bm = bm;
- } else {
- /*
- * When BundleMap is null create it manually
- * with all necessary initialization
- */
- this.bm = createBundleMap(editor);
- }
- propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- duplicateKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
-
- public void createControl(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(1, false));
-
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = DIALOG_WIDTH;
- gd.heightHint = DIALOG_HEIGHT;
- composite.setLayoutData(gd);
-
- /*
- * Create properties string group
- */
- Group propsStringGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
- propsStringGroup.setLayout(new GridLayout(3, false));
- propsStringGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
- propsStringGroup.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
-
- /*
- * Create Properties Key label
- */
- Label propsKeyLabel = new Label(propsStringGroup, SWT.NONE);
- propsKeyLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- propsKeyLabel.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY);
- /*
- * Create Properties Key value
- */
- propsKey = new Text(propsStringGroup, SWT.BORDER);
- propsKey.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- propsKey.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY);
-
- /*
- * Create Properties Value label
- */
- Label propsValueLabel = new Label(propsStringGroup, SWT.NONE);
- propsValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- propsValueLabel.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE);
- /*
- * Create Properties Value value
- */
- propsValue = new Text(propsStringGroup, SWT.BORDER);
- propsValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
- propsValue.setText(Constants.EMPTY);
- propsValue.setEditable(false);
-
- /*
- * Create New File Checkbox
- */
- newFile = new Button(composite, SWT.CHECK);
- newFile.setLayoutData(new GridData(SWT.LEFT, SWT.NONE, false, false, 1, 1));
- newFile.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE);
-
- /*
- * Create properties string group
- */
- propsFilesGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
- propsFilesGroup.setLayout(new GridLayout(3, false));
- gd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
- gd.heightHint = 300;
- propsFilesGroup.setLayoutData(gd);
- propsFilesGroup.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP);
-
- /*
- * Create Resource Bundles List label
- */
- rbListLabel = new Label(propsFilesGroup, SWT.NONE);
- rbListLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false, 1, 1));
- rbListLabel.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST);
- /*
- * Create Resource Bundles combobox
- */
- rbCombo = new Combo(propsFilesGroup, SWT.NONE);
- rbCombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
-
- /*
- * Create Properties File label
- */
- propsFileLabel = new Label(propsFilesGroup, SWT.NONE);
- propsFileLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false,false, 1, 1));
- propsFileLabel.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE);
- /*
- * Create Properties File path field
- */
- propsFile = new Text(propsFilesGroup, SWT.BORDER);
- propsFile.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true,false, 2, 1));
- propsFile.setText(Constants.EMPTY);
- propsFile.setEditable(false);
- /*
- * Create properties file table of content
- */
- tagsTable = new Table(propsFilesGroup, SWT.BORDER);
- TableLayout layout = new TableLayout();
- tagsTable.setLayout(layout);
- tagsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
- tagsTable.setHeaderVisible(true);
- tagsTable.setLinesVisible(true);
-
- ColumnLayoutData columnLayoutData;
- TableColumn propNameColumn = new TableColumn(tagsTable, SWT.NONE);
- propNameColumn.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME);
- columnLayoutData = new ColumnWeightData(200, true);
- layout.addColumnData(columnLayoutData);
- TableColumn propValueColumn = new TableColumn(tagsTable, SWT.NONE);
-
propValueColumn.setText(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE);
- columnLayoutData = new ColumnWeightData(200, true);
- layout.addColumnData(columnLayoutData);
-
- /*
- * Initialize all fields with real values.
- */
- initializeFieldsAndAddLIsteners();
-
- /*
- * Wizard Page control should be initialized.
- */
- setControl(composite);
- }
-
- /**
- * Initialize dialog's controls.
- * Fill in appropriate text and make validation.
- */
- private void initializeFieldsAndAddLIsteners() {
- ISelection sel = editor.getSelectionProvider().getSelection();
- if (isSelectionCorrect(sel)) {
- String text = Constants.EMPTY;
- String stringToUpdate = Constants.EMPTY;
- TextSelection textSelection = null;
- IStructuredSelection structuredSelection = (IStructuredSelection) sel;
- textSelection = (TextSelection) sel;
- text = textSelection.getText();
- Object selectedElement = structuredSelection.getFirstElement();
- /*
- * When selected text is empty
- * parse selected element and find a string to replace..
- */
- if ((text.trim().length() == 0)) {
- if (selectedElement instanceof org.w3c.dom.Text) {
- /*
- * ..it could be a plain text
- */
- org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
- if (textNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = textNode.getNodeValue();
- editor.getSelectionProvider().setSelection(new
StructuredSelection(stringToUpdate));
- }
- } else if (selectedElement instanceof Attr) {
- /*
- * ..or an attribute's value
- */
- Attr attrNode = (Attr) selectedElement;
- if (attrNode.getNodeValue().trim().length() > 0) {
- stringToUpdate = attrNode.getNodeValue();
- editor.getSelectionProvider().setSelection(new
StructuredSelection(stringToUpdate));
- }
- }
- if ((stringToUpdate.trim().length() > 0)) {
- text = stringToUpdate;
- }
- }
- /*
- * Update text string field.
- * Trim the text to remove line breaks and caret returns.
- * Replace line delimiters white space
- */
- for (char ch : LINE_DELEMITERS) {
- text = text.trim().replace(ch, ' ');
- }
- propsValue.setText(text);
- propsKey.setText(generatePropertyKey(text));
- /*
- * Initialize bundle messages field
- */
- if (bm == null) {
- VpePlugin.getDefault().logWarning(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING);
- } else {
- BundleEntry[] bundles = bm.getBundles();
- Set<String> uriSet = new HashSet<String>();
- for (BundleEntry bundleEntry : bundles) {
- if (!uriSet.contains(bundleEntry.uri)) {
- uriSet.add(bundleEntry.uri);
- rbCombo.add(bundleEntry.uri);
- }
- }
- /*
- * Select the first bundle if there is any in the list
- */
- if (rbCombo.getItemCount() > 0) {
- rbCombo.select(0);
- setResourceBundlePath(rbCombo.getText());
- }
- }
- /*
- * Check the initial key value
- * If there is the error - add sequence number to the key
- */
- updateDuplicateKeyStatus();
- while (!duplicateKeyStatus.isOK()) {
- int index = propsKey.getText().lastIndexOf('_');
- String newKey = Constants.EMPTY;
- if (index != -1) {
- /*
- * String sequence at the end should be checked.
- * If it is a sequence number - it should be increased by 1.
- * If not - new number should be added.
- */
- String numberString = propsKey.getText().substring(index + 1);
- int number;
- try {
- number = Integer.parseInt(numberString);
- number++;
- newKey = propsKey.getText().substring(0, index + 1) + number;
- } catch (NumberFormatException e) {
- newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
- }
- } else {
- /*
- * If the string has no sequence number - add it.
- */
- newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
- }
- /*
- * Set the new key text
- */
- propsKey.setText(newKey);
- updateDuplicateKeyStatus();
- }
- /*
- *
https://jira.jboss.org/browse/JBIDE-6945
- * Set the greeting message only.
- * All the validation will take place in the fields' listeners
- * after user enters some new values.
- */
- setMessage(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME,
- IMessageProvider.INFORMATION);
-
- /*
- * Add selection listeners to the fields
- */
- propsKey.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateStatus();
- }
- });
- propsValue.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateStatus();
- }
- });
- newFile.addSelectionListener( new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- boolean selected = ((Button)e.getSource()).getSelection();
- if (selected) {
- enableBundleGroup(false);
- } else {
- enableBundleGroup(true);
- }
- updateStatus();
- }
- });
- rbCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setResourceBundlePath(rbCombo.getText());
- updateDuplicateKeyStatus();
- updateStatus();
- }
- });
- } else {
- VpePlugin.getDefault().logWarning(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
- }
- }
-
- /**
- * Checks user has selected a correct string.
- *
- * @param selection the current selection
- * @return <code>true</code> if correct
- */
- private boolean isSelectionCorrect(ISelection selection) {
- if ((selection instanceof TextSelection)
- && (selection instanceof IStructuredSelection)
- && (((IStructuredSelection) selection).size() == 1)) {
- return true;
- }
- return false;
- }
-
- /**
- * Checks keys in the selected resource bundle.
- *
- * @param key the key name
- * @return <code>true</code> if there is a key with the specified name
- */
- private boolean isDuplicatedKey(String key) {
- boolean isDupliacted = false;
- if ((tagsTable.getItemCount() > 0) && (null != key) && !isNewFile())
{
- TableItem[] items = tagsTable.getItems();
- for (TableItem tableItem : items) {
- if (key.equalsIgnoreCase(tableItem.getText(0))) {
- isDupliacted = true;
- break;
- }
- }
- }
- return isDupliacted;
- }
-
- /**
- * Update resource bundle table according to the selected file:
- * it fills key and value columns.
- *
- * @param file the resource bundle file
- */
- private void updateTable(IFile file) {
- if ((file != null) && file.exists()) {
- try {
- /*
- * Read the file content
- */
- String encoding = FileUtil.getEncoding(file);
- BufferedReader in = new BufferedReader(new InputStreamReader(
- file.getContents(), encoding));
- Properties properties = new Properties();
- properties.load(in);
- in.close();
- in = null;
- /*
- * Clear the table
- */
- tagsTable.removeAll();
- /*
- * Fill in new values
- */
- int k = 0;
- Set<String> keys = properties.stringPropertyNames();
- List<String> keysList = new ArrayList<String>(keys);
- Collections.sort(keysList);
- for (String key : keysList) {
- TableItem tableItem = null;
- tableItem = new TableItem(tagsTable, SWT.BORDER, k);
- k++;
- tableItem.setText(new String[] {key, properties.getProperty(key)});
- }
- } catch (CoreException e) {
- VpePlugin.getDefault().logError(
- "Could not load file content for '" + file + "'", e);
//$NON-NLS-1$ //$NON-NLS-2$
- } catch (IOException e) {
- VpePlugin.getDefault().logError(
- "Could not read file: '" + file + "'", e); //$NON-NLS-1$
//$NON-NLS-2$
- }
- } else {
- VpePlugin.getDefault().logError(
- "Bundle File'" + file + "' does not exist!");
//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Enables or disables resource bundle information
- *
- * @param enabled shows the status
- */
- private void enableBundleGroup(boolean enabled) {
- propsFilesGroup.setEnabled(enabled);
- propsFileLabel.setEnabled(enabled);
- propsFile.setEnabled(enabled);
- rbListLabel.setEnabled(enabled);
- rbCombo.setEnabled(enabled);
- tagsTable.setEnabled(enabled);
- }
-
- /**
- * Gets <code>key=value</code> pair
- *
- * @return a pair <code>\nkey=value\n</code>
- */
- public String getKeyValuePair() {
- return "\n" + propsKey.getText() + Constants.EQUAL + propsValue.getText() +
"\n"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * 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 (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() {
- if (isDuplicatedKey(propsKey.getText())) {
- duplicateKeyStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS);
- } else {
- duplicateKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
- }
-
- private void updatePropertiesValueStatus() {
- String text = propsValue.getText();
- if ((text == null)
- || (Constants.EMPTY.equalsIgnoreCase(text.trim()))
- || (text.indexOf(Constants.GT) != -1)
- || (text.indexOf(Constants.LT) != -1)) {
- propsValueStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT);
- } else {
- propsValueStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
- }
-
- /**
- * Update properties key status.
- */
- private void updatePropertiesKeyStatus() {
- if ((propsKey.getText() == null)
- || (Constants.EMPTY.equalsIgnoreCase(propsKey.getText().trim()))) {
- propsKeyStatus = new Status(
- IStatus.ERROR,
- VpePlugin.PLUGIN_ID,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET);
- } else {
- propsKeyStatus = new Status(IStatus.OK, VpePlugin.PLUGIN_ID, Constants.EMPTY);
- }
- }
-
- /**
- * Update page status.
- */
- private void updateStatus() {
- /*
- * Update all statuses
- */
- updatePropertiesKeyStatus();
- updatePropertiesValueStatus();
- updateDuplicateKeyStatus();
- /*
- * Apply status to the dialog
- */
- applyStatus(this, new IStatus[] {propsKeyStatus, propsValueStatus,
duplicateKeyStatus});
- /*
- * Set page complete
- */
- setPageComplete(isPageComplete());
- }
-
- /**
- * Apply status to the dialog.
- *
- * @param page the page
- * @param statuses all the statuses
- */
- private void applyStatus(DialogPage page, IStatus[] statuses) {
- IStatus severeStatus = statuses[0];
- for (IStatus status : statuses) {
- severeStatus = severeStatus.getSeverity() >= status.getSeverity()
- ? severeStatus : status;
- }
-
- String message = severeStatus.getMessage();
- switch (severeStatus.getSeverity()) {
- case IStatus.OK:
- page.setMessage(null, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
-
- case IStatus.WARNING:
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
-
- case IStatus.INFO:
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
-
- default:
- if (message.length() == 0) {
- message = null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-
- @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)
- && (getMessage() == null)
- && ((rbCombo.getSelectionIndex() != -1) || isNewFile())) {
- isPageComplete = true;
- }
- return isPageComplete;
- }
-
- @Override
- public boolean canFlipToNextPage() {
- return isPageComplete() && (getNextPage() != null)
- && (newFile.getSelection() == true);
- }
-
- /**
- * Creates new bundle map if no one was specified
- * during initialization of the page.
- *
- * @param editor the source editor
- * @return the new bundle map
- */
- private BundleMap createBundleMap(StructuredTextEditor editor) {
- String uri = null;
- String prefix = null;
- int hash;
- Map<?, ?> map = null;
- BundleMap bm = new BundleMap();
- bm.init(editor);
-
- /*
- * Check JSF Nature
- */
- boolean hasJsfProjectNatureType = false;
- try {
- IEditorInput ei = editor.getEditorInput();
- if(ei instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)ei).getFile().getProject();
- if (project.exists() && project.isOpen()) {
- if (project.hasNature(WebProject.JSF_NATURE_ID)) {
- hasJsfProjectNatureType = true;
- }
- }
- }
- } catch (CoreException e) {
- VpePlugin.getPluginLog().logError(e);
- }
- /*
- * Get Bundles from faces-config.xml
- */
- if (hasJsfProjectNatureType
- && (editor.getEditorInput() instanceof IFileEditorInput)) {
- IProject project = ((IFileEditorInput) editor.getEditorInput())
- .getFile().getProject();
- IModelNature modelNature = EclipseResourceUtil.getModelNature(project);
- if (modelNature != null) {
- XModel model = modelNature.getModel();
- List<Object> l = WebPromptingProvider.getInstance().getList(model,
- WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
- if (l != null && l.size() > 1 && (l.get(1) instanceof Map)) {
- map = (Map<?, ?>) l.get(1);
- if ((null != map) && (map.keySet().size() > 0)) {
- Iterator<?> it = map.keySet().iterator();
- while (it.hasNext()) {
- uri = it.next().toString();
- prefix = map.get(uri).toString();
- hash = (prefix + ":" + uri).hashCode(); //$NON-NLS-1$
- bm.addBundle(hash, prefix, uri, false);
- }
- }
- }
- }
- }
- ISourceEditingTextTools sourceEditingTextTools =
- (ISourceEditingTextTools) editor
- .getAdapter(ISourceEditingTextTools.class);
- IDOMSourceEditingTextTools domSourceEditingTextTools =
- (IDOMSourceEditingTextTools) sourceEditingTextTools;
- Document documentWithBundles = domSourceEditingTextTools.getDOMDocument();
-
- /*
- * When facelets are used -- get bundles from the template file
- */
- if (editor instanceof JSPTextEditor) {
- IVisualContext context = ((JSPTextEditor) editor).getPageContext();
- List<TaglibData> taglibs = null;
- if (context instanceof SourceEditorPageContext) {
- SourceEditorPageContext sourcePageContext = (SourceEditorPageContext) context;
- taglibs = sourcePageContext.getTagLibs();
- }
- if (null == taglibs) {
- VpePlugin.getDefault().logError(
- VpeUIMessages.CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT);
- } else {
- Element root =
FaceletUtil.findComponentElement(documentWithBundles.getDocumentElement());
- if ((root != null) && FaceletUtil.isFacelet(root, taglibs)
- && root.hasAttribute("template")) { //$NON-NLS-1$
- String filePath= root.getAttributeNode("template").getNodeValue();
//$NON-NLS-1$
- if (((JSPTextEditor) editor).getEditorInput() instanceof FileEditorInput) {
- FileEditorInput fei = (FileEditorInput) ((JSPTextEditor) editor).getEditorInput();
- IFile templateFile = (IFile)
fei.getFile().getProject().getFolder("WebContent").findMember(filePath);
//$NON-NLS-1$
- Document document = VpeCreatorUtil.getDocumentForRead(templateFile);
- if (null != document) {
- /*
- * Change the document where to look bundles
- */
- documentWithBundles = document;
- }
- }
- }
- }
- }
- /*
- * Add bundles from <f:loadBundle> tags on the current page
- */
- NodeList list = documentWithBundles.getElementsByTagName("f:loadBundle");
//$NON-NLS-1$
- for (int i = 0; i < list.getLength(); i++) {
- Element node = (Element) list.item(i);
- uri = node.getAttribute("basename"); //$NON-NLS-1$
- prefix = node.getAttribute("var"); //$NON-NLS-1$
- hash = node.hashCode();
- bm.addBundle(hash, prefix, uri, false);
- }
- return bm;
- }
-
- /**
- * 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
- * from the bundles list.
- *
- * @param bundleName the resource bundle name
- */
- private void setResourceBundlePath(String bundleName) {
- IFile bundleFile = bm.getBundleFile(bundleName);
- String bundlePath = Constants.EMPTY;
- if (bundleFile != null) {
- bundlePath = bundleFile.getFullPath().toString();
- updateTable(bundleFile);
- } else {
- VpePlugin.getDefault().logError(
- "Could not get Bundle File for resource '" //$NON-NLS-1$
- + bundleName + "'"); //$NON-NLS-1$
- }
- propsFile.setText(bundlePath);
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.i18n;
-
-import java.util.Locale;
-
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.common.model.XModel;
-
-/**
- * This interface is intended for creation extensions of {@code localeProvider}
- * extension point.
- *
- * @author yradtsevich
- */
-public interface ILocaleProvider {
- /**
- * Returns the locale for given {@code editor}. Implementations
- * may return {@code null} if they can not determine the locale.
- */
- Locale getLocale(StructuredTextEditor editor);
-
- /**
- * Shows the string representation of the locale
- * returned by #getLocale(StructuredTextEditor) method.
- *
- * @return the string representation of the locale
- */
- String getLocaleString();
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.i18n;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.vpe.VpePlugin;
-
-/**
- * Aggregates extensions of all {@code localeProvider} extension points.
- * This class is a singleton.
- * <P>
- * Typical use of this class:
- * <code>MainLocaleProvider.getInstance().getLocale(editor)</code>
- *
- * @author yradtsevich
- */
-public class MainLocaleProvider implements ILocaleProvider {
- private static final String ELEMENT_NATURE = "nature"; //$NON-NLS-1$
- private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
- private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
- private static final String ELEMENT_LOCALE_PROVIDER
- = "localeProvider"; //$NON-NLS-1$
- private Map<String, ? extends List<IExtension>> natureToExtensions;
- private Map<IExtension, ILocaleProvider> extensionToProvider
- = new HashMap<IExtension, ILocaleProvider>();
- private IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint(VpePlugin.EXTESION_POINT_LOCALE_PROVIDER);
- private static MainLocaleProvider instance;
-
- private String localeString = ""; //$NON-NLS-1$
-
- private MainLocaleProvider() {
- // private constructor
- initNatureExtensionsMap();
- }
-
- /**
- * Returns a shared instance of {@link MainLocaleProvider}.
- */
- public static MainLocaleProvider getInstance() {
- if (instance == null) {
- instance = new MainLocaleProvider();
- }
- return instance;
- }
-
- /**
- * Tries to determine the locale of the {@code editor} using
- * {@code localeProvider} extensions. Returns the default
- * system locale if nothing found (never returns {@code null}).
- */
- public Locale getLocale(StructuredTextEditor editor) {
- IEditorInput editorInput = editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)editorInput)
- .getFile().getProject();
-
- try {
- if(project.isAccessible()) {
- String[] natures = project.getDescription().getNatureIds();
- for (String natureId : natures) {
- for (ILocaleProvider provider : getProviders(natureId)) {
- Locale locale = provider.getLocale(editor);
- if (locale != null) {
- localeString = provider.getLocaleString();
- return locale;
- }
- }
- }
- }
- } catch (CoreException e) {
- VpePlugin.getPluginLog().logError(
- MessageFormat.format("Error in getting locale for
{0}.",((IFileEditorInput)editorInput)
- .getFile().getLocation().toOSString()), e); //$NON-NLS-1$
- }
- }
-
- return Locale.getDefault();
- }
-
- private void initNatureExtensionsMap() {
- Map<String, ArrayList<IExtension>> natureExtensionsMap
- = new HashMap<String, ArrayList<IExtension>>();
-
- IExtension[] extensions
- = extensionPoint.getExtensions();
-
- for (IExtension extension : extensions) {
- IConfigurationElement[] elements
- = extension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (ELEMENT_NATURE.equals(element.getName())) {
- String natureId = element.getAttribute(ATTRIBUTE_ID);
- ArrayList<IExtension> extensionList
- = natureExtensionsMap.get(natureId);
-
- if (extensionList == null) {
- extensionList = new ArrayList<IExtension>();
- natureExtensionsMap.put(natureId, extensionList);
- }
-
- extensionList.add(extension);
- }
- }
- }
-
- for (ArrayList<IExtension> configurationsList
- : natureExtensionsMap.values()) {
- configurationsList.trimToSize();
- }
-
- this.natureToExtensions = natureExtensionsMap;
- }
-
- /**
- * Returns all available instances of {@link ILocaleProvider} for given
- * {@code natureId}. It loads extensions using lazy initialization.
- */
- private List<ILocaleProvider> getProviders(String natureId) {
- List<IExtension> extensions = natureToExtensions.get(natureId);
- if (extensions == null) {
- return Collections.emptyList();
- }
-
- List<ILocaleProvider> providers
- = new ArrayList<ILocaleProvider>(extensions.size());
-
- for (IExtension extension : extensions) {
- ILocaleProvider provider
- = extensionToProvider.get(extension);
-
- if (provider == null) {
- provider = createLocaleProvider(extension);
- }
- if (provider != null) {
- providers.add(provider);
- }
- }
-
- return providers;
- }
-
- private ILocaleProvider createLocaleProvider(IExtension extension) {
- ILocaleProvider provider = null;
- try {
- for (IConfigurationElement element
- : extension.getConfigurationElements()) {
- if (ELEMENT_LOCALE_PROVIDER.equals(element.getName())) {
- provider = (ILocaleProvider) element
- .createExecutableExtension(ATTRIBUTE_CLASS);
- extensionToProvider.put(extension, provider);
- break;
- }
- }
- } catch (InvalidRegistryObjectException e) {
- VpePlugin.getPluginLog().logError(
- "The extension registry object " //$NON-NLS-1$
- + "is no longer valid.", e); //$NON-NLS-1$
- } catch (CoreException e) {
- VpePlugin.getPluginLog().logError(
- "CoreException occured.", e); //$NON-NLS-1$
- }
- return provider;
- }
-
- public String getLocaleString() {
- return localeString;
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/ExternalizeStringsContributionItem.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/ExternalizeStringsContributionItem.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/ExternalizeStringsContributionItem.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.vpe.editor.menu;
-
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.swt.widgets.Menu;
-import org.jboss.tools.vpe.editor.menu.action.ExternalizeStringsAction;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-public class ExternalizeStringsContributionItem extends ActionContributionItem {
-
- /**
- * Instantiates a new externalize strings contribution item.
- * Default constructor is used to create
- * source editor context menu from plugin.xml
- */
- public ExternalizeStringsContributionItem() {
- super(new ExternalizeStringsAction());
- }
-
- @Override
- public void fill(Menu parent, int index) {
- /*
- * Simply sets the title
- */
- getAction().setText(VpeUIMessages.EXTERNALIZE_STRINGS);
- super.fill(parent, index);
- }
-
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ExternalizeStringsAction.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ExternalizeStringsAction.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ExternalizeStringsAction.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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.vpe.editor.menu.action;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.vpe.editor.dialog.ExternalizeStringsDialog;
-import org.jboss.tools.vpe.editor.dialog.ExternalizeStringsWizard;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-public class ExternalizeStringsAction extends Action {
-
- private JSPMultiPageEditor editor;
-
- public ExternalizeStringsAction() {
- super();
- editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- }
-
- @Override
- public void run() {
- ISelection sel = editor.getSelectionProvider().getSelection();
-
- if ((sel instanceof TextSelection)
- && (sel instanceof IStructuredSelection)
- && (((IStructuredSelection) sel).size() == 1)) {
- /*
- * Pass null for Bundle Map that it will be created by the page itself.
- */
- ExternalizeStringsDialog dlg = new ExternalizeStringsDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- new ExternalizeStringsWizard(editor.getSourceEditor(), null));
- dlg.open();
- } else {
- MessageDialog.openWarning(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION);
- }
- }
-
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -64,11 +64,11 @@
import org.eclipse.ui.part.EditorPart;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsDialog;
+import org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizard;
import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.editor.dialog.ExternalizeStringsDialog;
-import org.jboss.tools.vpe.editor.dialog.ExternalizeStringsWizard;
import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaResizeListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaTooltipListener;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -16,11 +16,11 @@
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.VpePreviewDomBuilder;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -17,7 +17,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
import org.mozilla.interfaces.nsIDOMDocument;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.expression;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.w3c.dom.Node;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -22,7 +22,7 @@
import org.jboss.tools.common.el.core.ELReferenceList;
import org.jboss.tools.common.el.core.GlobalELReferenceList;
import org.jboss.tools.common.resref.core.ResourceReference;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -46,27 +46,21 @@
* @return
*/
public static Element findComponentElement(Element root) {
-
if(root==null) {
-
return null;
}
NodeList children = root.getChildNodes();
-
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
-
Element trimmedElement = findComponentElement((Element) child);
if (trimmedElement != null)
return trimmedElement;
-
}
}
-
- if (componentElements.contains(root.getLocalName()))
+ if (componentElements.contains(root.getLocalName())) {
return root;
-
+ }
return null;
}
@@ -76,13 +70,9 @@
* @return
*/
public static Element getRootFaceletElement(Document document) {
-
Element root = document.getDocumentElement();
-
Element component = findComponentElement(root);
-
return component != null ? component : root;
-
}
@@ -106,9 +96,7 @@
// IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
// if (iEditorInput instanceof IFileEditorInput) {
// IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
-//
// IFile iFile = iFileEditorInput.getFile();
-//
// IProject project = iFile.getProject();
// IModelNature nature = EclipseResourceUtil.getModelNature(project);
// if (nature != null) {
@@ -118,14 +106,12 @@
// webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
// if (param != null) {
// String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
-//
// if (value.length() != 0 && iFile.getName().endsWith(value)) {
// isFacelet = true;
// }
// }
// }
// }
-
return isFacelet;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -11,7 +11,7 @@
package org.jboss.tools.vpe.editor.util;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
/**
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -160,31 +160,6 @@
public static String COULD_NOT_SET_TABLE_SELECTION;
public static String CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT;
public static String LIST_IS_EMPTY;
- public static String EXTERNALIZE_STRINGS_DIALOG_TITLE;
- public static String EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION;
- public static String EXTERNALIZE_STRINGS_DIALOG_TEXT_STRING;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE;
- public static String EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP;
- public static String EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR;
- public static String EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING;
- public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION;
- public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT;
- public static String EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE;
- public static String EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY;
- public static String EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET;
- public static String EXTERNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET;
- public static String EXTERNALIZE_STRINGS_DIALOG_NEW_FILE;
- public static String EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY;
- public static String EXTERNALIZE_STRINGS_DIALOG_DEFAULT_VALUE;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME;
- public static String EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE;
- public static String EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS;
- public static String EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME;
- public static String EXTERNALIZE_STRINGS_DIALOG_SELECT_RESOURCE_BUNDLE;
public static String COULD_NOT_OPEN_VPE_RESOURCES_DIALOG;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2010-09-30
14:27:08 UTC (rev 25332)
@@ -115,7 +115,6 @@
HIDE_TEXT_FORMATTING = Hide text formatting bar
SHOW_RESOURCE_BUNDLES_USAGE_AS_EL=Show resource bundles usage as EL expressions
SHOW_BUNDLES_AS_EL=Show bundle's messages as EL expressions
-EXTERNALIZE_STRINGS=Externalize strings
SHOW_BUNDLES_AS_MESSAGES=Show bundle's messages explicitly
ASK_TAG_ATTRIBUTES_ON_TAG_INSERT=Ask for tag attributes during tag insert
INFORM_WHEN_PROJECT_MIGHT_NOT_BE_CONFIGURED_PROPERLY_FOR_VPE=Inform when a project might
not be configured properly for Visual Page Editor
@@ -150,33 +149,6 @@
COULD_NOT_SET_TABLE_SELECTION=Could not set table selection.
LIST_IS_EMPTY=List is empty
-# Externalize Strings Dialog
-EXTERNALIZE_STRINGS_DIALOG_TITLE=Externalize Strings
-EXTERNALIZE_STRINGS_DIALOG_DESCRIPTION=Externalize your strings via properties file
-EXTERNALIZE_STRINGS_DIALOG_TEXT_STRING=Text string:
-EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY=Property key:
-EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE=Property value:
-EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_FILE=Properties file:
-EXTERNALIZE_STRINGS_DIALOG_RESOURCE_BUNDLE_LIST=Select resource bundle:
-EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP=Externalize strings
-EXTERNALIZE_STRINGS_DIALOG_PROPS_FILES_GROUP=Handle properties file
-EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR=Could not initialize externalization
dialog!
-EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING=Could not initialize resource bundles!
-EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION=Wrong selection! Please select correct
string.
-EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT=Wrong selected text. Please select correct
string.
-EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE=- Please select bundle -
-EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY=Selected text is empty
-EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET=Key must be set
-EXTERNALIZE_STRINGS_DIALOG_VALUE_MUST_BE_SET=Value must be set
-EXTERNALIZE_STRINGS_DIALOG_NEW_FILE=Create a new properties file (See details on the next
page)
-EXTERNALIZE_STRINGS_DIALOG_DEFAULT_KEY=key
-EXTERNALIZE_STRINGS_DIALOG_DEFAULT_VALUE=value
-EXTERNALIZE_STRINGS_DIALOG_PROPERTY_NAME=Property name
-EXTERNALIZE_STRINGS_DIALOG_PROPERTY_VALUE=Property value
-EXTERNALIZE_STRINGS_DIALOG_KEY_ALREADY_EXISTS=Such a key already exists
-EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME=Please specify the property key
-EXTERNALIZE_STRINGS_DIALOG_SELECT_RESOURCE_BUNDLE=Please select the resource bundle
-
# Other messages
CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT=Cannot load taglibs from PageContext!
COULD_NOT_OPEN_VPE_RESOURCES_DIALOG=Could not open Vpe Resources Dialog!
\ No newline at end of file
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-09-30
14:13:11 UTC (rev 25331)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-09-30
14:27:08 UTC (rev 25332)
@@ -19,8 +19,8 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -49,7 +49,7 @@
@Override
protected void closeUnuseDialogs() {
try {
- SWTBotShell dlgShell = bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
+ SWTBotShell dlgShell = bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE);
dlgShell.setFocus();
dlgShell.close();
} catch (WidgetNotFoundException e) {
@@ -81,28 +81,28 @@
* Get toolbar button
*/
assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check properties key and value fields
*/
SWTBotText defKeyText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull("Cannot find 'Property Key' text field", defKeyText);
//$NON-NLS-1$
assertText("User",defKeyText); //$NON-NLS-1$
SWTBotText defValueText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
assertText("User", defValueText); //$NON-NLS-1$
SWTBotCheckBox checkBox = bot.checkBox();
assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
- + VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
+ + JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
checkBox);
/*
* Check that "Next" button is disabled
@@ -172,19 +172,19 @@
* Get toolbar button
*/
assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check generated property key
*/
SWTBotText defKeyText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull("Cannot find 'Property Key' text field", defKeyText);
//$NON-NLS-1$
assertText("User_1",defKeyText); //$NON-NLS-1$
@@ -209,29 +209,29 @@
* Get toolbar button
*/
assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check properties key and value fields
*/
SWTBotText defKeyText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull("Cannot find 'Property Key' text field", defKeyText);
//$NON-NLS-1$
assertText("User",defKeyText); //$NON-NLS-1$
SWTBotText defValueText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
assertText("User", defValueText); //$NON-NLS-1$
SWTBotCheckBox checkBox = bot.checkBox();
assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
- + VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
+ + JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
checkBox);
/*
* Check that "Next" button is disabled
@@ -297,18 +297,18 @@
* Get toolbar button
*/
assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Enable next page and check it
*/
SWTBotCheckBox checkBox = bot.checkBox();
assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
- + VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
+ + JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'",
//$NON-NLS-1$
checkBox);
checkBox.select();
assertTrue("Checkbox should be checked.", //$NON-NLS-1$
@@ -340,6 +340,7 @@
SWTBotEditor editor2 = SWTTestExt.eclipse.openFile(
JBT_TEST_PROJECT_NAME, "WebContent", "pages", //$NON-NLS-1$
//$NON-NLS-2$
"externalize.properties"); //$NON-NLS-1$
+// bot.sleep(10000);
editor2.toTextEditor().selectLine(1);
String line = editor2.toTextEditor().getSelection();
assertEquals("Created file is incorrect", "Input=Input", line);
//$NON-NLS-1$ //$NON-NLS-2$
@@ -367,7 +368,7 @@
* Check that the toolbar buttion is disabled
*/
assertFalse("Toolbar buttion should be disabled", bot //$NON-NLS-1$
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
/*
* Select some text
@@ -381,24 +382,24 @@
* Activate the dialog
*/
assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS)
+ .toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS)
.isEnabled());
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check that the property value text is empty
*/
SWTBotText defValueText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
assertText("Say Hello!", defValueText); //$NON-NLS-1$
/*
* Close the dialog
*/
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
isUnusedDialogOpened = false;
/*
* Type some text outside the tag
@@ -412,27 +413,27 @@
/*
* Activate the dialog
*/
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check that the property key and value text
*/
SWTBotText defKeyText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defKeyText);
assertText(COMPLEX_KEY_RESULT, defKeyText);
defValueText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
assertText(COMPLEX_VALUE_RESULT, defValueText);
/*
* Close the dialog
*/
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
isUnusedDialogOpened = false;
/*
* Check selection in the attribute's value
@@ -441,22 +442,22 @@
/*
* Activate the dialog
*/
- bot.toolbarButtonWithTooltip(VpeUIMessages.EXTERNALIZE_STRINGS).click();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ bot.toolbarButtonWithTooltip(JstUIMessages.EXTERNALIZE_STRINGS).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
isUnusedDialogOpened = true;
/*
* Check that the property value text is empty
*/
defValueText = bot.textWithLabelInGroup(
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
- VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
assertText("true", defValueText); //$NON-NLS-1$
/*
* Close the dialog
*/
- bot.shell(VpeUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).close();
isUnusedDialogOpened = false;
}
}