From c901c0e5cc0a42bb9af0c868fe49412cc1e9058a Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:28:15 +0000 Subject: Save configuration (and window size) on close git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@337 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../src/main/java/at/asit/pdfover/gui/MainWindow.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'pdf-over-gui/src/main/java/at') 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 92688c82..b65a1f17 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 @@ -16,6 +16,7 @@ package at.asit.pdfover.gui; // Imports +import java.io.IOException; import java.io.InputStream; import java.util.EnumMap; import java.util.Map; @@ -25,6 +26,8 @@ import org.eclipse.swt.SWTError; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Rectangle; @@ -216,7 +219,20 @@ public class MainWindow { catch (SWTError e) { log.debug("Cannot get display", e); //$NON-NLS-1$ } - getShell().setText(Messages.getString("main.title")); //$NON-NLS-1$ + this.shell.setText(Messages.getString("main.title")); //$NON-NLS-1$ + + this.shell.addShellListener(new ShellAdapter() { + @Override + public void shellClosed(ShellEvent e) { + log.debug("Closing main window"); //$NON-NLS-1$ + MainWindow.this.stateMachine.getConfigManipulator().setMainWindowSize(getShell().getSize()); + try { + MainWindow.this.stateMachine.getConfigManipulator().saveCurrentConfiguration(); + } catch (IOException e1) { + log.error("Error saving configuration", e); //$NON-NLS-1$ + } + } + }); ImageData data = new ImageData(this.getClass().getResourceAsStream("/icons/icon.png"));//$NON-NLS-1$ Image shellicon = new Image(this.shell.getDisplay(), data); -- cgit v1.2.3