From 9a5a6257994c0554ff27f3e5874a4555465f6153 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:29:58 +0000 Subject: Use reflection for mac workaround git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@349 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../main/java/at/asit/pdfover/gui/MainWindow.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index 85f223c6..2d06f9ef 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -18,6 +18,8 @@ package at.asit.pdfover.gui; // Imports import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.EnumMap; import java.util.Map; @@ -31,7 +33,6 @@ import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.internal.cocoa.NSWindow; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; @@ -50,6 +51,7 @@ import at.asit.pdfover.gui.controls.MainBarMiddleButton; import at.asit.pdfover.gui.controls.MainBarRectangleButton; import at.asit.pdfover.gui.controls.MainBarStartButton; import at.asit.pdfover.gui.utils.Messages; +import at.asit.pdfover.gui.utils.SWTLoader; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.states.BKUSelectionState; import at.asit.pdfover.gui.workflow.states.ConfigurationUIState; @@ -210,8 +212,22 @@ public class MainWindow { this.shell.setSize(this.stateMachine.getConfigProvider().getMainWindowSize()); if (System.getProperty("os.name").toLowerCase().contains("mac")) { //$NON-NLS-1$ //$NON-NLS-2$ // Workaround for SWT bug on Mac: disable full screen mode - NSWindow nswindow = this.shell.view.window(); - nswindow.setCollectionBehavior(0); + try { + Field field = Control.class.getDeclaredField("view"); //$NON-NLS-1$ + Object /*NSView*/ view = field.get(this.shell); + if (view != null) + { + Class c = Class.forName("org.eclipse.swt.internal.cocoa.NSView"); //$NON-NLS-1$ + Object nswindow = c.getDeclaredMethod("window").invoke(view); //$NON-NLS-1$ + c = Class.forName("org.eclipse.swt.internal.cocoa.NSWindow"); //$NON-NLS-1$ + Method setCollectionBehavior = c.getDeclaredMethod( + "setCollectionBehavior", //$NON-NLS-1$ + (SWTLoader.getArchBits() == 64) ? long.class : int.class); + setCollectionBehavior.invoke(nswindow, 0); + } + } catch (Exception e) { + log.error("Error disabling full screen mode", e); //$NON-NLS-1$ + } } try { Display display = Display.getCurrent(); -- cgit v1.2.3