summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authorAndreas Abraham <aabraham@iaik.tugraz.at>2018-04-17 17:45:47 +0200
committerAndreas Abraham <aabraham@iaik.tugraz.at>2018-04-17 17:45:47 +0200
commit8006f3eb6e46f4b81bf31e06049712b148c32665 (patch)
tree13f0e19f5ddd1125bbaa025cf6555c578479d7a7 /pdf-over-gui
parente47182fcf3bddb3b3f427b149ecb003366d5971d (diff)
downloadpdf-over-8006f3eb6e46f4b81bf31e06049712b148c32665.tar.gz
pdf-over-8006f3eb6e46f4b81bf31e06049712b148c32665.tar.bz2
pdf-over-8006f3eb6e46f4b81bf31e06049712b148c32665.zip
bugfix in infobox
Diffstat (limited to 'pdf-over-gui')
-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() {