Author: mareshkau
Date: 2011-02-02 11:26:33 -0500 (Wed, 02 Feb 2011)
New Revision: 28930
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java
Log:
https://issues.jboss.org/browse/JBIDE-7003 refactoring of bundle map
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 2011-02-02
16:19:50 UTC (rev 28929)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/i18n/JsfLocaleProvider.java 2011-02-02
16:26:33 UTC (rev 28930)
@@ -40,7 +40,11 @@
*/
public Locale getLocale(ITextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
- return getLocale(editorInput);
+ IProject fileProject = null;
+ if (editorInput instanceof IFileEditorInput) {
+ fileProject=((IFileEditorInput)editorInput).getFile().getProject();
+ }
+ return getLocale(fileProject);
}
public String getLocaleString() {
@@ -48,10 +52,9 @@
}
@Override
- public Locale getLocale(IEditorInput editorInput) {
- if (editorInput instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)editorInput)
- .getFile().getProject();
+ public Locale getLocale(IProject project) {
+ if (project !=null) {
+
IModelNature modelNature = EclipseResourceUtil.getModelNature(project);
if (modelNature == null) {
return null;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2011-02-02
16:19:50 UTC (rev 28929)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2011-02-02
16:26:33 UTC (rev 28930)
@@ -74,20 +74,24 @@
IVpePreferencesPage.SHOW_RESOURCE_BUNDLES_USAGE_AS_EL);
XModelTreeListener modelListener = new ML();
- private IEditorInput editorInput =null;
private IProject project;
public void init(IEditorInput input){
- this.editorInput = input;
-
- if (getEditorInput() instanceof IFileEditorInput) {
- this.project = ((IFileEditorInput)getEditorInput()).getFile().getProject();
+ IProject fileProject=null;
+ if (input instanceof IFileEditorInput) {
+ fileProject=((IFileEditorInput)input).getFile().getProject();
+ }
+ init(fileProject);
+ }
+
+ public void init(IProject project){
+ if (project!=null) {
javaSources = getJavaProjectSrcLocations(project);
}
/*
* Initialize the locale with default value.
*/
- locale = MainLocaleProvider.getInstance().getLocale(getEditorInput());
+ locale = MainLocaleProvider.getInstance().getLocale(project);
refreshRegisteredBundles();
PreferenceModelUtilities.getPreferenceModel().addModelTreeListener(modelListener);
}
@@ -660,7 +664,7 @@
return bundles;
}
- private IEditorInput getEditorInput() {
- return editorInput;
- }
+// private IEditorInput getEditorInput() {
+// return editorInput;
+// }
}
Modified:
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/ILocaleProvider.java 2011-02-02
16:19:50 UTC (rev 28929)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ILocaleProvider.java 2011-02-02
16:26:33 UTC (rev 28930)
@@ -12,8 +12,7 @@
import java.util.Locale;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.core.resources.IProject;
/**
* This interface is intended for creation extensions of {@code localeProvider}
@@ -26,10 +25,8 @@
* Returns the locale for given {@code editor}. Implementations
* may return {@code null} if they can not determine the locale.
*/
- Locale getLocale(ITextEditor editor);
+ Locale getLocale(IProject project);
- Locale getLocale(IEditorInput editorInput);
-
/**
* Shows the string representation of the locale
* returned by #getLocale(StructuredTextEditor) method.
Modified:
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/i18n/MainLocaleProvider.java 2011-02-02
16:19:50 UTC (rev 28929)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/MainLocaleProvider.java 2011-02-02
16:26:33 UTC (rev 28930)
@@ -74,25 +74,14 @@
* {@code localeProvider} extensions. Returns the default
* system locale if nothing found (never returns {@code null}).
*/
- public Locale getLocale(ITextEditor editor) {
- return this.getLocale(editor.getEditorInput());
- }
- /**
- * 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(IEditorInput editorInput) {
- if (editorInput instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput)editorInput)
- .getFile().getProject();
-
+ public Locale getLocale(IProject project) {
+ if (project!=null) {
try {
if(project.isAccessible()) {
String[] natures = project.getDescription().getNatureIds();
for (String natureId : natures) {
for (ILocaleProvider provider : getProviders(natureId)) {
- Locale locale = provider.getLocale(editorInput);
+ Locale locale = provider.getLocale(project);
if (locale != null) {
localeString = provider.getLocaleString();
return locale;
@@ -102,8 +91,7 @@
}
} catch (CoreException e) {
JspEditorPlugin.getPluginLog().logError(
- MessageFormat.format("Error in getting locale for
{0}.",((IFileEditorInput)editorInput)
- .getFile().getLocation().toOSString()), e);
+ MessageFormat.format("Error in getting locale for
{0}.",project==null?"Couldn't find project":project.getName(), e));
}
}