Author: yradtsevich
Date: 2012-06-04 15:08:18 -0400 (Mon, 04 Jun 2012)
New Revision: 41692
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/CocoaUIEnhancer.java
Log:
https://issues.jboss.org/browse/JBIDE-12091 : Wrong properties of Mac Os menu -
"SWT" instead of "BrowserSim"
- applied patch created by Ilya Buziuk with some minor changes
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2012-06-04
18:37:20 UTC (rev 41691)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2012-06-04
19:08:18 UTC (rev 41692)
@@ -89,6 +89,12 @@
private ResizableSkinSizeAdvisor sizeAdvisor;
public static void main(String[] args) {
+ //CocoaUIEnhancer handles connection between the About, Preferences and Quit menus in
MAC OS X
+ CocoaUIEnhancer cocoaUIEnhancer = null;
+ if (PlatformUtil.OS_MACOSX.equals(PlatformUtil.getOs())) {
+ cocoaUIEnhancer = new CocoaUIEnhancer(Messages.BrowserSim_BROWSER_SIM);
+ cocoaUIEnhancer.initializeMacOSMenuBar();
+ }
String homeUrl;
if (args.length > 0) {
String lastArg = args[args.length - 1];
@@ -118,8 +124,8 @@
// set event handlers for Mac OS X Menu-bar
- if (PlatformUtil.OS_MACOSX.equals(PlatformUtil.getOs())) {
- browserSim.addMacOsMenuApplicationHandler();
+ if (cocoaUIEnhancer != null) {
+ browserSim.addMacOsMenuApplicationHandler(cocoaUIEnhancer);
}
@@ -785,8 +791,7 @@
}
- private void addMacOsMenuApplicationHandler() {
- CocoaUIEnhancer enhancer = new CocoaUIEnhancer(Messages.BrowserSim_BROWSER_SIM);
+ private void addMacOsMenuApplicationHandler(CocoaUIEnhancer enhancer) {
Listener quitListener = new Listener() {
@Override
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/CocoaUIEnhancer.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/CocoaUIEnhancer.java 2012-06-04
18:37:20 UTC (rev 41691)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/CocoaUIEnhancer.java 2012-06-04
19:08:18 UTC (rev 41692)
@@ -1,3 +1,11 @@
+/*******************************************************************************
+ * 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
+ *
+ * Initial implementation:
+ *
http://www.transparentech.com/opensource/cocoauienhancer
+ ******************************************************************************/
package org.jboss.tools.vpe.browsersim.ui;
import java.lang.reflect.InvocationTargetException;
@@ -3,5 +11,4 @@
import java.lang.reflect.Method;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.C;
@@ -53,6 +60,13 @@
public CocoaUIEnhancer( String appName ) {
this.appName = appName;
}
+ /**
+ * Must be invoked before a Display is created!
+ */
+ public void initializeMacOSMenuBar(){
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
appName);//$NON-NLS-1$
+
+ }
/**
* Hook the given Listener to the Mac OS X application Quit menu and the IActions to
the About
@@ -167,9 +181,8 @@
invoke( nsmenuCls, appMenu, "itemAtIndex", new Object[] {
wrapPointer( kAboutMenuItem ) } );
/* yradtsevich: The following lines in the original source are
- * replaced by the call of System.getProperty, which does the same job.
+ * replaced by the call of initializeMacOSMenuBar(), which does the same job.
* See
https://issues.jboss.org/browse/JBIDE-11048 */
- System.setProperty("com.apple.mrj.application.apple.menu.about.name",
appName);//$NON-NLS-1$
// if ( appName != null ) {
// Object nsStr = invoke( nsstringCls, "stringWith", new Object[] {
"About " + appName } );
// invoke( nsmenuitemCls, aboutMenuItem, "setTitle", new Object[] {
nsStr } );