summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2014-01-27 18:12:26 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2014-01-27 18:12:26 +0000
commit3219581f933a24fb2466da2eaca3c325b437ce44 (patch)
treeb329fa7893160f643ab7b8178d1583cc8577324a /pdf-over-gui
parent161af59764d0e4df632ace57c6de9d02ae7d3e5d (diff)
downloadmocca-3219581f933a24fb2466da2eaca3c325b437ce44.tar.gz
mocca-3219581f933a24fb2466da2eaca3c325b437ce44.tar.bz2
mocca-3219581f933a24fb2466da2eaca3c325b437ce44.zip
Hook up main SWT menu on OS X
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@480 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java40
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java2
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties3
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties3
4 files changed, 48 insertions, 0 deletions
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 e847fd0c..e68b4da4 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
@@ -39,17 +39,23 @@ import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.composites.StateComposite;
+import at.asit.pdfover.gui.controls.Dialog;
+import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
+import at.asit.pdfover.gui.controls.Dialog.ICON;
import at.asit.pdfover.gui.controls.MainBarButton;
import at.asit.pdfover.gui.controls.MainBarEndButton;
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.osx.CocoaUIEnhancer;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.utils.SWTLoader;
import at.asit.pdfover.gui.workflow.StateMachine;
@@ -198,6 +204,9 @@ public class MainWindow {
this.shell = new Shell();
getShell().setSize(this.stateMachine.getConfigProvider().getMainWindowSize());
if (System.getProperty("os.name").toLowerCase().contains("mac")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (System.getProperty("os.name").contains("OS X")) { //$NON-NLS-1$ //$NON-NLS-2$
+ hookupOSXMenu();
+ }
// Workaround for SWT bug on Mac: disable full screen mode
try {
Field field = Control.class.getDeclaredField("view"); //$NON-NLS-1$
@@ -376,6 +385,37 @@ public class MainWindow {
}
/**
+ * Hook up SWT menu under OS X
+ */
+ private void hookupOSXMenu() {
+ log.debug("Hooking up OS X menu"); //$NON-NLS-1$
+ CocoaUIEnhancer.hookApplicationMenu(getShell().getDisplay(), new Listener() {
+ @Override
+ public void handleEvent(Event arg0) {
+ MainWindow.this.stateMachine.exit();
+ }
+ }, new Listener() {
+ @Override
+ public void handleEvent(Event arg0) {
+ String version = getClass().getPackage()
+ .getImplementationVersion();
+ version = (version == null ? "" : " v" + version); //$NON-NLS-1$ //$NON-NLS-2$
+ String about = Constants.APP_NAME + version;
+ Dialog dialog = new Dialog(getShell(),
+ String.format(Messages.getString("main.about"), Constants.APP_NAME), //$NON-NLS-1$
+ about, BUTTONS.OK, ICON.INFORMATION);
+ dialog.open();
+ }
+ }, new Listener() {
+ @Override
+ public void handleEvent(Event arg0) {
+ if (MainWindow.this.stateMachine.getStatus().getBehavior().getEnabled(Buttons.CONFIG))
+ MainWindow.this.stateMachine.jumpToState(new ConfigurationUIState(MainWindow.this.stateMachine));
+ }
+ });
+ }
+
+ /**
* Update MainWindow to fit new status
*/
public void applyBehavior() {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
index 4651ddf5..2d839bc0 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
@@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindowBehavior;
+import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.composites.ConfigurationComposite;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
@@ -96,6 +97,7 @@ public class ConfigurationUIState extends State {
public void updateMainWindowBehavior() {
// Leave the state as it is
MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior();
+ behavior.setEnabled(Buttons.CONFIG, false);
behavior.setMainBarVisible(false);
}
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
index 0f2c5b2f..f109bfac 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
@@ -115,9 +115,12 @@ exception.PasswordTooLong=Given password is too long!
exception.PasswordTooShort=Given password is too short!
exception.PathNotDirectory=Path %s does not denote a directory!
exception.PathNotExist=Path %s does not exist!
+main.about=About %s
main.configuration=Configuration
main.done=Finish
+main.hide=Hide %s
main.position=Positioning
+main.quit=Quit %s
main.signature=Signing
mobileBKU.number=Number:
mobileBKU.password=Password:
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
index 34840eb8..103f89ae 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
@@ -115,9 +115,12 @@ exception.PasswordTooLong=Eingegebenes Passwort ist zu lange!
exception.PasswordTooShort=Eingegebenes Passwort ist zu kurz!
exception.PathNotDirectory=Pfad %s ist kein gültiger Ordner!
exception.PathNotExist=Pfad %s existiert nicht!
+main.about=Über %s
main.configuration=Konfiguration
main.done=Fertig
+main.hide=%s ausblenden
main.position=Positionierung
+main.quit=%s beenden
main.signature=Signatur
mobileBKU.number=Nummer:
mobileBKU.password=Passwort: