summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2016-06-30 13:56:55 +0200
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2016-06-30 13:56:55 +0200
commitd6aa86ff603d7acaba3137cec1484d54bae3731b (patch)
tree35580c8387c6e2f37e669c1fb78ac343bceb73a1 /pdf-over-gui/src/main/java/at
parent2f2d383ee57fefab2f0a07d4be2169f4274b49fa (diff)
downloadpdf-over-d6aa86ff603d7acaba3137cec1484d54bae3731b.tar.gz
pdf-over-d6aa86ff603d7acaba3137cec1484d54bae3731b.tar.bz2
pdf-over-d6aa86ff603d7acaba3137cec1484d54bae3731b.zip
Clicking on Open in Open state opens the file dialog
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java52
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java14
4 files changed, 39 insertions, 38 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 78fab160..d3484889 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
@@ -318,8 +318,13 @@ public class MainWindow {
@Override
public void mouseUp(MouseEvent e) {
- MainWindow.this.stateMachine.jumpToState(new OpenState(
- MainWindow.this.stateMachine));
+ if (MainWindow.this.stateMachine.getStatus().getCurrentState() instanceof OpenState) {
+ ((OpenState) MainWindow.this.stateMachine.getStatus()
+ .getCurrentState()).openFileDialog();
+ } else {
+ MainWindow.this.stateMachine.jumpToState(new OpenState(
+ MainWindow.this.stateMachine));
+ }
}
});
this.buttonMap.put(Buttons.OPEN, this.btn_open);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
index a2f53e63..b48dbba8 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
@@ -44,7 +44,7 @@ public class MainWindowBehavior {
*/
public MainWindowBehavior() {
this.buttonsActive = new EnumMap<MainWindow.Buttons, Boolean>(MainWindow.Buttons.class);
- this.buttonsEnabled = new EnumMap<MainWindow.Buttons, Boolean>( MainWindow.Buttons.class);
+ this.buttonsEnabled = new EnumMap<MainWindow.Buttons, Boolean>(MainWindow.Buttons.class);
reset();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
index eede00a8..83a92a7b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
@@ -54,6 +54,26 @@ import at.asit.pdfover.gui.workflow.states.State;
public class DataSourceSelectComposite extends StateComposite {
/**
+ * Open the input document selection dialog
+ */
+ public void openFileDialog() {
+ FileDialog dialog = new FileDialog(
+ DataSourceSelectComposite.this.getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] { "*.pdf", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setFilterNames(new String[] {
+ Messages.getString("common.PDFExtension_Description"), //$NON-NLS-1$
+ Messages.getString("common.AllExtension_Description") }); //$NON-NLS-1$
+ String fileName = dialog.open();
+ File file = null;
+ if (fileName != null) {
+ file = new File(fileName);
+ if (file.exists()) {
+ DataSourceSelectComposite.this.setSelected(file);
+ }
+ }
+ }
+
+ /**
* Selection adapter for file browsing
*/
private final class FileBrowseDialogListener extends SelectionAdapter {
@@ -65,20 +85,7 @@ public class DataSourceSelectComposite extends StateComposite {
@Override
public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(
- DataSourceSelectComposite.this.getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] { "*.pdf", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
- dialog.setFilterNames(new String[] {
- Messages.getString("common.PDFExtension_Description"), //$NON-NLS-1$
- Messages.getString("common.AllExtension_Description") }); //$NON-NLS-1$
- String fileName = dialog.open();
- File file = null;
- if (fileName != null) {
- file = new File(fileName);
- if (file.exists()) {
- DataSourceSelectComposite.this.setSelected(file);
- }
- }
+ openFileDialog();
}
}
@@ -316,8 +323,6 @@ public class DataSourceSelectComposite extends StateComposite {
this.redrawDrop();
}
- private boolean press = false;
-
Composite drop_area;
FormData fd_lbl_drag;
@@ -336,21 +341,6 @@ public class DataSourceSelectComposite extends StateComposite {
// Disable the check that prevents subclassing of SWT components
}
- /**
- * @return the press
- */
- public boolean isPress() {
- return this.press;
- }
-
- /**
- * @param press
- * the press to set
- */
- public void setPress(boolean press) {
- this.press = press;
- }
-
/*
* (non-Javadoc)
*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
index 87792309..b77809ed 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
@@ -57,9 +57,6 @@ public class OpenState extends State {
@Override
public void run() {
-
-
-
Status status = getStateMachine().getStatus();
if (!(status.getPreviousState() instanceof PrepareConfigurationState) &&
!(status.getPreviousState() instanceof OpenState))
@@ -87,7 +84,15 @@ public class OpenState extends State {
log.debug("Got Datasource: " + getStateMachine().getStatus().getDocument().getAbsolutePath()); //$NON-NLS-1$
this.setNextState(new PositioningState(getStateMachine()));
}
-
+
+ /**
+ * Open the input document selection dialog
+ */
+ public void openFileDialog() {
+ if (this.selectionComposite != null)
+ this.selectionComposite.openFileDialog();
+ }
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
*/
@@ -105,6 +110,7 @@ public class OpenState extends State {
MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior();
behavior.reset();
behavior.setEnabled(Buttons.CONFIG, true);
+ behavior.setEnabled(Buttons.OPEN, true);
behavior.setActive(Buttons.OPEN, true);
}