remember position of the main windo
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 13 May 2008 12:47:34 +0000 (12:47 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 13 May 2008 12:47:34 +0000 (12:47 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@861 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/SwingInterface.java

index 65e1edd..53cd87e 100644 (file)
@@ -163,6 +163,18 @@ public class SwingInterface implements CoreListener, LoggingListener {
        /** The class name of the look and feel. */
        private String lookAndFeel;
 
+       /** X coordinate of the main window. */
+       private int mainWindowX = -1;
+
+       /** Y coordinate of the main window. */
+       private int mainWindowY = -1;
+
+       /** Width of the main window. */
+       private int mainWindowWidth = -1;
+
+       /** Height of the main window. */
+       private int mainWindowHeight = -1;
+
        /**
         * Creates a new swing interface.
         * 
@@ -202,6 +214,10 @@ public class SwingInterface implements CoreListener, LoggingListener {
                initDialogs();
                mainWindow = new MainWindow(this);
                mainWindow.setAdvancedMode(advancedMode);
+               if ((mainWindowX != -1) && (mainWindowY != -1) && (mainWindowWidth != -1) && (mainWindowHeight != -1)) {
+                       mainWindow.setLocation(mainWindowX, mainWindowY);
+                       mainWindow.setSize(mainWindowWidth, mainWindowHeight);
+               }
                logWindow = new LogWindow();
        }
 
@@ -406,6 +422,18 @@ public class SwingInterface implements CoreListener, LoggingListener {
                if (configProperties.containsKey("language")) {
                        I18n.setLocale(new Locale(configProperties.getProperty("language")));
                }
+               if (configProperties.containsKey("mainWindowX")) {
+                       mainWindowX = Integer.valueOf(configProperties.getProperty("mainWindowX"));
+               }
+               if (configProperties.containsKey("mainWindowY")) {
+                       mainWindowY = Integer.valueOf(configProperties.getProperty("mainWindowY"));
+               }
+               if (configProperties.containsKey("mainWindowWidth")) {
+                       mainWindowWidth = Integer.valueOf(configProperties.getProperty("mainWindowWidth"));
+               }
+               if (configProperties.containsKey("mainWindowHeight")) {
+                       mainWindowHeight = Integer.valueOf(configProperties.getProperty("mainWindowHeight"));
+               }
        }
 
        /**
@@ -437,6 +465,10 @@ public class SwingInterface implements CoreListener, LoggingListener {
                        configProperties.setProperty("lookAndFeel", lookAndFeel);
                }
                configProperties.setProperty("language", I18n.getLocale().getLanguage());
+               configProperties.setProperty("mainWindowX", String.valueOf(mainWindowX));
+               configProperties.setProperty("mainWindowY", String.valueOf(mainWindowY));
+               configProperties.setProperty("mainWindowWidth", String.valueOf(mainWindowWidth));
+               configProperties.setProperty("mainWindowHeight", String.valueOf(mainWindowHeight));
                FileOutputStream configOutputStream = null;
                try {
                        configOutputStream = new FileOutputStream(configFile);
@@ -626,6 +658,10 @@ public class SwingInterface implements CoreListener, LoggingListener {
        private void quit() {
                /* TODO - ask */
                core.stop();
+               mainWindowX = mainWindow.getX();
+               mainWindowY = mainWindow.getY();
+               mainWindowWidth = mainWindow.getWidth();
+               mainWindowHeight = mainWindow.getHeight();
                saveConfig();
                System.exit(0);
        }
@@ -671,7 +707,7 @@ public class SwingInterface implements CoreListener, LoggingListener {
                                        nodeDisconnect(node);
                                }
                        };
-// nodeDisconnectActions.add(nodeDisconnectAction);
+                       // nodeDisconnectActions.add(nodeDisconnectAction);
                        nodeDisconnectActionNodes.put(nodeDisconnectAction, node);
                        nodeNodeDisconnectActions.put(node, nodeDisconnectAction);
                }