aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-04-10 14:06:32 (EDT)
committerOleg Besedin2012-04-10 14:07:01 (EDT)
commit7c7397b74eb4af6690d787dd4be9596a2230e555 (patch)
tree57f521da7d52e3a725ee471a1e1536abf6919b48
parent5945872a3e888ae30764cad1a4300b3166e6536b (diff)
downloadeclipse.platform.ui-7c7397b74eb4af6690d787dd4be9596a2230e555.zip
eclipse.platform.ui-7c7397b74eb4af6690d787dd4be9596a2230e555.tar.gz
eclipse.platform.ui-7c7397b74eb4af6690d787dd4be9596a2230e555.tar.bz2
Bug 364950 - Workbench is not mirrored correctly when using "nl" optionv20120410-1807
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java7
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java57
2 files changed, 44 insertions, 20 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
index b48e945..5b0b895 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
@@ -77,6 +77,7 @@ import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -218,10 +219,8 @@ public class E4Application implements IApplication {
appContext);
appModel.setContext(appContext);
- String rtlMode = getArgValue(E4Workbench.RTL_MODE, applicationContext,
- false);
- appModel.getTransientData().put(E4Workbench.RTL_MODE,
- "rtl".equals(rtlMode));
+ boolean isRtl = ((Window.getDefaultOrientation() & SWT.RIGHT_TO_LEFT) != 0);
+ appModel.getTransientData().put(E4Workbench.RTL_MODE, isRtl);
// for compatibility layer: set the application in the OSGi service
// context (see Workbench#getInstance())
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java
index ac7b457..01179ab 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -886,7 +886,30 @@ public class WorkbenchPlugin extends AbstractUIPlugin {
return checkCommandLineLocale(); //Use the default value if there is nothing specified
}
-
+
+ /**
+ * Check whether the workbench messages are in a Bidi language. This method
+ * will return <code>null</code> if it is unable to determine message
+ * properties.
+ */
+ private Boolean isBidiMessageText() {
+ // Check if the user installed the NLS packs for bidi
+ String message = WorkbenchMessages.Startup_Loading_Workbench;
+ if (message == null)
+ return null;
+
+ try {
+ // use qualified class name to avoid import statement
+ // and premature attempt to resolve class reference
+ boolean isBidi = com.ibm.icu.text.Bidi.requiresBidi(message.toCharArray(), 0,
+ message.length());
+ return new Boolean(isBidi);
+ } catch (NoClassDefFoundError e) {
+ // the ICU Base bundle used in place of ICU?
+ return null;
+ }
+ }
+
/**
* Check to see if the command line parameter for -nl
* has been set. If so imply the orientation from this
@@ -904,21 +927,23 @@ public class WorkbenchPlugin extends AbstractUIPlugin {
* @see SWT#RIGHT_TO_LEFT
*/
private int checkCommandLineLocale() {
-
- //Check if the user property is set. If not do not
- //rely on the vm.
- if(System.getProperty(NL_USER_PROPERTY) == null) {
- return SWT.NONE;
- }
-
- Locale locale = Locale.getDefault();
- String lang = locale.getLanguage();
-
- if ("iw".equals(lang) || "he".equals(lang) || "ar".equals(lang) || //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "fa".equals(lang) || "ur".equals(lang)) { //$NON-NLS-1$ //$NON-NLS-2$
- return SWT.RIGHT_TO_LEFT;
+ // Check if the user property is set. If not, do not rely on the VM.
+ if (System.getProperty(NL_USER_PROPERTY) == null) {
+ Boolean needRTL = isBidiMessageText();
+ if (needRTL != null && needRTL.booleanValue())
+ return SWT.RIGHT_TO_LEFT;
+ } else {
+ String lang = Locale.getDefault().getLanguage();
+ boolean bidiLangauage = "iw".equals(lang) || "he".equals(lang) || "ar".equals(lang) || //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "fa".equals(lang) || "ur".equals(lang); //$NON-NLS-1$ //$NON-NLS-2$
+ if (bidiLangauage) {
+ Boolean needRTL = isBidiMessageText();
+ if (needRTL == null)
+ return SWT.RIGHT_TO_LEFT;
+ if (needRTL.booleanValue())
+ return SWT.RIGHT_TO_LEFT;
+ }
}
-
return SWT.NONE;
}