Author: yradtsevich
Date: 2009-10-21 10:36:09 -0400 (Wed, 21 Oct 2009)
New Revision: 18208
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.classpath
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.project
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/.jsdtscope
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.jdt.core.prefs
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.component
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_de.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/User.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/META-INF/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/.faces-config.xml.jsfdia
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/classes/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/faces-config.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/jsf-tlds.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/standard.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/web.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VpeI18nTest_JBIDE4887.java
trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/
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
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/converter/OpenKeyHelper.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.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/bundle/BundleMap.java
Log:
issue JBIDE-4887: Internationalization doesn't work in VPE.
https://jira.jboss.org/jira/browse/JBIDE-4887
- created org.jboss.tools.vpe.localeProvider extension point
- created JSF extension for org.jboss.tools.vpe.localeProvider
- created JUnit tests for i18n
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/converter/OpenKeyHelper.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/converter/OpenKeyHelper.java 2009-10-21
14:31:01 UTC (rev 18207)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/converter/OpenKeyHelper.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -14,7 +14,6 @@
import java.util.Locale;
import org.eclipse.osgi.util.NLS;
-
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.FindObjectHelper;
@@ -71,7 +70,7 @@
return bundle.getChildByPath(key);
}
- public String getDeafultLocale(XModel model) {
+ public static String getDeafultLocale(XModel model) {
JSFProjectsRoot root = JSFProjectsTree.getProjectsRoot(model);
WebProjectNode conf = root == null ? null :
(WebProjectNode)root.getChildByPath(JSFProjectTreeConstants.CONFIGURATION);
XModelObject[] fs = conf == null ? new XModelObject[0] : conf.getTreeChildren();
@@ -83,5 +82,4 @@
Locale locale = Locale.getDefault();
return locale == null || locale.toString().length() == 0 ? null : locale.toString();
}
-
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/META-INF/MANIFEST.MF 2009-10-21 14:31:01
UTC (rev 18207)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/META-INF/MANIFEST.MF 2009-10-21 14:36:09
UTC (rev 18208)
@@ -15,12 +15,16 @@
org.eclipse.wst.sse.core,
org.eclipse.jst.jsp.core,
org.eclipse.wst.html.core,
- org.jboss.tools.vpe.html
+ org.jboss.tools.vpe.html,
+ org.jboss.tools.jsf;bundle-version="2.0.0",
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.jsf.vpe.jsf.template,
org.jboss.tools.jsf.vpe.jsf.template.selectitem,
org.jboss.tools.jsf.vpe.jsf.template.util,
org.jboss.tools.jsf.vpe.jsf.template.util.model
Bundle-Localization: plugin
-Import-Package: org.jboss.tools.jst.web.tld
+Import-Package: org.eclipse.wst.sse.ui,
+ org.jboss.tools.jst.web.tld
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml 2009-10-21 14:31:01 UTC (rev
18207)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/plugin.xml 2009-10-21 14:36:09 UTC (rev
18208)
@@ -7,4 +7,13 @@
name="JSF Reference Implementation"
path="templates/vpe-templates-jsf.xml"/>
</extension>
+ <extension
+ point="org.jboss.tools.vpe.localeProvider">
+ <localeProvider
+ class="org.jboss.tools.jsf.vpe.jsf.i18n.JsfLocaleProvider">
+ </localeProvider>
+ <nature
+ id="org.jboss.tools.jsf.jsfnature">
+ </nature>
+ </extension>
</plugin>
Added:
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
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.jsf.vpe.jsf.i18n;
+
+import java.util.Locale;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.model.XModel;
+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;
+
+/**
+ * Implementation of {@link ILocaleProvider} for JSF projects.
+ *
+ * @author yradtsevich
+ */
+public class JsfLocaleProvider implements ILocaleProvider {
+
+ /**
+ * Returns the locale for given {@code editor}, or {@code null} if it
+ * can not determine it.
+ */
+ public Locale getLocale(StructuredTextEditor editor) {
+ IEditorInput editorInput = editor.getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ IProject project = ((IFileEditorInput)editorInput)
+ .getFile().getProject();
+ XModel model = EclipseResourceUtil.getModelNature(project)
+ .getModel();
+ return new Locale(OpenKeyHelper.getDeafultLocale(model));
+ } else {
+ return null;
+ }
+ }
+}
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.classpath
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.classpath
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.classpath 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="JavaSource"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache
Tomcat v6.0">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_05">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output"
path="WebContent/WEB-INF/classes"/>
+</classpath>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.project
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.project
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.project 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>i18nTest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.jboss.tools.jsf.jsfnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/.jsdtscope
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/.jsdtscope
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/.jsdtscope 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.jdt.core.prefs 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,7 @@
+#Wed Oct 21 01:29:52 EEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.component
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.component 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="i18nTest">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes"
source-path="/JavaSource"/>
+<property name="context-root" value="i18nTest"/>
+<property name="java-output-path"/>
+</wb-module>
+</project-modules>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.common.project.facet.core.xml 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="Apache Tomcat v6.0"/>
+ <fixed facet="jst.web"/>
+ <fixed facet="jst.java"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.container
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.container 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.name
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/.settings/org.eclipse.wst.jsdt.ui.superType.name 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages.properties 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1 @@
+hello_message=Good afternoon\!
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_de.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_de.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_de.properties 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1 @@
+hello_message=Guten Tag\!
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/User.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/User.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/User.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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 demo;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+public class User {
+
+ private String name;
+
+ /**
+ * @return User Name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param User Name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/META-INF/MANIFEST.MF
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/META-INF/MANIFEST.MF 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/.faces-config.xml.jsfdia
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/.faces-config.xml.jsfdia
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/.faces-config.xml.jsfdia 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS model-entity="JSFProcess">
+ <PROCESS-ITEM NAME="rules:#pages#inputUserName.jsp"
+ PATH="/pages/inputUserName.jsp" SHAPE="32,17,0,0"
model-entity="JSFProcessGroup">
+ <PROCESS-ITEM ID="rules:#pages#inputUserName.jsp:0" NAME="item"
+ PATH="/pages/inputUserName.jsp" model-entity="JSFProcessItem">
+ <PROCESS-ITEM-OUTPUT ID="hello::#pages#hello.jsp"
NAME="output"
+ PATH="/pages/hello.jsp" TARGET="rules:#pages#hello.jsp"
+ TITLE="hello" model-entity="JSFProcessItemOutput"/>
+ </PROCESS-ITEM>
+ </PROCESS-ITEM>
+ <PROCESS-ITEM NAME="rules:#pages#hello.jsp"
PATH="/pages/hello.jsp"
+ SHAPE="240,33,0,0" model-entity="JSFProcessGroup"/>
+</PROCESS>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/faces-config.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/faces-config.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/faces-config.xml 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xi="http://www.w3.org/2001/XInclude"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+ <managed-bean>
+ <description>User Name Bean</description>
+ <managed-bean-name>user</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>name</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
+ <navigation-rule>
+ <from-view-id>/pages/inputUserName.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>hello</from-outcome>
+ <to-view-id>/pages/hello.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <application>
+ <locale-config>
+ <default-locale>de</default-locale>
+ </locale-config>
+ </application>
+ <factory/>
+ <lifecycle/>
+</faces-config>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/jsf-tlds.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/jsf-tlds.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/standard.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/lib/standard.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/web.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/web.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/WEB-INF/web.xml 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>i18nTest</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,13 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <body>
+ <f:view id="view-id">
+ <h:outputText value="#{Message.hello_message}1" />
+ #{Message.hello_message}2
+ </f:view>
+ </body>
+</html>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/jsfDefaultLocale.jsp.xml 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,18 @@
+<tests>
+ <test id="view-id">
+ <TABLE>
+ <TR>
+ <TD>
+ <DIV>
+ <SPAN CLASS="vpe-text">
+ Guten Tag!1
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Guten Tag!2
+ </SPAN>
+ </DIV>
+ </TD>
+ </TR>
+ </TABLE>
+ </test>
+</tests>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.properties 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,3 @@
+#
+#Wed Oct 21 01:29:48 EEST 2009
+classpath.external=
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/ant/build.xml 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,74 @@
+<project name="KickStart" default="deploy"
basedir="../">
+
+ <!-- Project settings -->
+ <property file="${basedir}/ant/build.properties" />
+
+ <property name="project.name" value="KickStart" />
+ <property name="web.content.dir" value="${basedir}/WebContent"
/>
+ <property name="web-inf.dir" value="${web.content.dir}/WEB-INF"
/>
+ <property name="build.dir" value="build" />
+ <property name="war.name"
value="${build.dir}/${project.name}.war" />
+
+ <!-- Define a folder for deployment -->
+ <property name="deploy.dir" value="deploy" />
+
+ <!-- Compile classpath -->
+ <path id="compile.classpath">
+ <fileset dir="${webinf.dir}/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${classpath}" />
+ <pathelement path="${classpath.external}" />
+ <pathelement path="${webinf.dir}/classes" />
+ </path>
+
+ <!-- Copy any resource or configuration files -->
+ <target name="copyResources">
+ <copy todir="${web-inf.dir}/classes" includeEmptyDirs="no">
+ <fileset dir="JavaSource">
+ <patternset>
+ <include name="**/*.*" />
+ <exclude name="**/*.java" />
+ </patternset>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Check timestamp on files -->
+ <target name="prepare">
+ <tstamp />
+ </target>
+
+ <!-- Remove classes directory for clean build -->
+ <target name="clean" description="Prepare for clean build">
+ <delete dir="${web-inf.dir}/classes" failonerror="false"/>
+ <mkdir dir="${web-inf.dir}/classes" />
+ </target>
+
+ <!-- Normal build of application -->
+ <target name="compile" depends="prepare, copyResources">
+ <javac srcdir="JavaSource" destdir="${web-inf.dir}/classes">
+ <classpath refid="compile.classpath" />
+ </javac>
+ </target>
+
+ <!-- Build Project -->
+ <target name="build" depends="prepare, compile" />
+
+ <!-- Rebuild Project -->
+ <target name="rebuild" depends="clean, prepare, compile" />
+
+ <!-- Build WAR -->
+ <target name="war" depends="build">
+ <mkdir dir="${build.dir}" />
+ <war warfile="${war.name}" basedir="${web.content.dir}"
webxml="${web-inf.dir}/web.xml">
+ <exclude name="WEB-INF/web.xml" />
+ </war>
+ </target>
+
+ <target name="deploy" depends="war">
+ <delete dir="${deploy.dir}/${project.name}"
failonerror="false"/>
+ <copy file="${war.name}" todir="${deploy.dir}" />
+ </target>
+
+</project>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-10-21
14:31:01 UTC (rev 18207)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -69,6 +69,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE924Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.VpeI18nTest_JBIDE4887;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1467Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1501Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1568Test;
@@ -96,11 +97,13 @@
public static final String IMPORT_JSF_20_PROJECT_NAME = "jsf2test";
//$NON-NLS-1$
public static final String IMPORT_CUSTOM_FACELETS_PROJECT =
"customFaceletsTestProject";//$NON-NLS-1$
public static final String IMPORT_JBIDE3247_PROJECT_NAME = "JBIDE3247";
//$NON-NLS-1$
+ public static final String IMPORT_I18N_PROJECT_NAME = "i18nTest";
//$NON-NLS-1$
public static Test suite() {
TestSuite suite = new TestSuite("Tests for Vpe Jsf components");
//$NON-NLS-1$
// $JUnit-BEGIN$
+ suite.addTestSuite(VpeI18nTest_JBIDE4887.class);
suite.addTestSuite(JsfComponentTest.class);
suite.addTestSuite(Jsf20ComponentContentTest.class);
suite.addTestSuite(JBIDE3519Test.class);
@@ -192,7 +195,12 @@
jbide3247TestProject.setImportProjectName(JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME);
jbide3247TestProject.setImportProjectPath(JsfTestPlugin.getPluginResourcePath());
projectToImport.add(jbide3247TestProject);
-
+
+ ImportBean i18nTestProject = new ImportBean();
+ i18nTestProject.setImportProjectName(JsfAllTests.IMPORT_I18N_PROJECT_NAME);
+ i18nTestProject.setImportProjectPath(JsfTestPlugin.getPluginResourcePath());
+ projectToImport.add(i18nTestProject);
+
return new VpeTestSetup(suite, projectToImport);
}
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VpeI18nTest_JBIDE4887.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VpeI18nTest_JBIDE4887.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VpeI18nTest_JBIDE4887.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+
+/**
+ * Tests for JIRA issue JBIDE-4887: Internationalization does not work in VPE
+ * (
https://jira.jboss.org/jira/browse/JBIDE-4887 )
+ *
+ * @author yradtsevich
+ */
+public class VpeI18nTest_JBIDE4887 extends ComponentContentTest {
+
+ public VpeI18nTest_JBIDE4887(String name) {
+ super(name);
+ setCheckWarning(false);
+ }
+
+ /**
+ * Tests if the default-locale described in faces-config.xml is
+ * taken into account during VPE rendering.
+ */
+ public void testJsfDefaultLocale() throws Throwable {
+ performContentTest("jsfDefaultLocale.jsp"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_I18N_PROJECT_NAME;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-10-21 14:31:01 UTC
(rev 18207)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-10-21 14:36:09 UTC
(rev 18208)
@@ -15,6 +15,7 @@
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 2009-10-21 14:31:01 UTC (rev 18207)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/plugin.xml 2009-10-21 14:36:09 UTC (rev 18208)
@@ -2,6 +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.eclipse.ui.startup" />
Added: trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd
(rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/schema/localeProvider.exsd 2009-10-21 14:36:09
UTC (rev 18208)
@@ -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/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 2009-10-21
14:31:01 UTC (rev 18207)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -30,6 +30,7 @@
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/bundle/BundleMap.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2009-10-21
14:31:01 UTC (rev 18207)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -52,6 +52,7 @@
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;
public class BundleMap {
@@ -220,9 +221,12 @@
return null;
}
}
+
ClassLoader classLoader = new URLClassLoader(urls,
ClassLoader.getSystemClassLoader());
- ResourceBundle bundle = ResourceBundle.getBundle(uri, Locale.getDefault(),
classLoader);
-
+
+ Locale locale = MainLocaleProvider.getInstance().getLocale(editor);
+ ResourceBundle bundle = ResourceBundle.getBundle(uri, locale, classLoader);
+
return bundle;
}
} catch (MissingResourceException ex) {
@@ -231,7 +235,7 @@
return null;
}
-
+
private static String[] getJavaProjectSrcLocations(IProject project) {
return EclipseResourceUtil.getJavaProjectSrcLocations(project);
}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/ILocaleProvider.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * 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);
+}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/i18n/MainLocaleProvider.java 2009-10-21
14:36:09 UTC (rev 18208)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.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 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 {
+ String[] natures = project.getDescription().getNatureIds();
+ for (String natureId : natures) {
+ for (ILocaleProvider provider : getProviders(natureId)) {
+ Locale locale = provider.getLocale(editor);
+ if (locale != null) {
+ return locale;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ VpePlugin.getPluginLog().logError(
+ "CoreException occured.", 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;
+ }
+}