summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java33
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java6
2 files changed, 24 insertions, 15 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
index 6af68b78..8a6e3c92 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
@@ -15,12 +15,8 @@
*/
package at.asit.pdfover.gui.workflow;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
//Imports
import java.lang.reflect.Constructor;
-import java.nio.file.Files;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
@@ -28,7 +24,6 @@ import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.MainWindow;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
@@ -176,17 +171,27 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
}
private void createMainWindow() {
- this.display = Display.getDefault();
+ try {
+
+ this.display = Display.getDefault();
- this.mainWindow = new MainWindow(this);
- this.mainWindow.open();
+ this.mainWindow = new MainWindow(this);
+ this.mainWindow.open();
- this.shell = this.mainWindow.getShell();
+ this.shell = this.mainWindow.getShell();
- this.container = this.mainWindow.getContainer();
+ this.container = this.mainWindow.getContainer();
- this.shell.open();
- this.shell.layout();
+ this.shell.open();
+ this.shell.layout();
+ } catch (Exception e) {
+ log.warn("Main-Window creation FAILED. Reason: " + e.getMessage()); //$NON-NLS-1$
+ this.display = null;
+ this.mainWindow = null;
+ this.shell = null;
+ this.container = null;
+ throw e;
+ }
}
/**
@@ -194,7 +199,7 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
*
* @return Composite
*/
- public Composite getComposite() {
+ public synchronized Composite getComposite() {
// Main window will be built on first call
// returns SWT Composite container for states to draw their GUI
@@ -375,7 +380,7 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
* @see at.asit.pdfover.gui.workflow.GUIProvider#getMainShell()
*/
@Override
- public Shell getMainShell() {
+ public synchronized Shell getMainShell() {
if(this.shell == null) {
this.createMainWindow();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index 640f61da..8e4e2d13 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -465,7 +465,11 @@ public class PrepareConfigurationState extends State {
final String version = method.getResponseBodyAsString().trim();
if (!VersionComparator.before(Constants.APP_VERSION, version))
return;
-
+
+ // wait 500ms before invoke the GUI message, because GUI had to be started from
+ // main thread
+ try {Thread.sleep(500); } catch (InterruptedException e1) { }
+ // invoke GUI message in main thread
gui.getMainShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {