Revision: 18271
          http://sourceforge.net/p/jmol/code/18271
Author:   hansonr
Date:     2013-05-31 16:15:23 +0000 (Fri, 31 May 2013)
Log Message:
-----------
fix for exit not saving window size

Modified Paths:
--------------
    trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java

Modified: trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java
===================================================================
--- trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java    
2013-05-31 16:05:58 UTC (rev 18270)
+++ trunk/Jmol/src/org/openscience/jmol/app/jmolpanel/JmolPanel.java    
2013-05-31 16:15:23 UTC (rev 18271)
@@ -581,38 +581,24 @@
 
     @Override
     public void windowClosing(WindowEvent e) {
-      doClose();
+      doClose(false);
     }
   }
 
-  protected boolean doClose() {
+  protected boolean doClose(boolean saveSize) {
     if (numWindows == 1 && viewer.getAtomCount() > 0 && 
JOptionPane.showConfirmDialog(frame, GT._("Exit Jmol?"),
         "Exit", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != 
JOptionPane.YES_OPTION)
       return false;
-    dispose(frame);
+    dispose(frame, saveSize);
     return true;
   }
 
-  void dispose(JFrame f) {
+  void dispose(JFrame f, boolean saveSize) {
     // Save window positions and status in the history
     if (webExport != null)
       WebExport.cleanUp();
-    if (historyFile != null) {
-      if (frame != null) {
-        jmolApp.border.x = frame.getWidth() - display.dimSize.width;
-        jmolApp.border.y = frame.getHeight() - display.dimSize.height;
-        historyFile.addWindowInfo("Jmol", frame, jmolApp.border);
-      }
-      //historyFile.addWindowInfo(CONSOLE_WINDOW_NAME, consoleframe);
-      AppConsole console = (AppConsole) 
viewer.getProperty("DATA_API","getAppConsole", null);
-      if (console != null && console.jcd != null)
-        historyFile.addWindowInfo(SCRIPT_WINDOW_NAME, console.jcd, null);
-      Component c = (Component) 
viewer.getProperty("DATA_API","getScriptEditor", null);
-      if (c != null)
-        historyFile.addWindowInfo(EDITOR_WINDOW_NAME, c, null);
-      if (historyFile.getProperty("clearHistory", "false").equals("true"))
-        historyFile.clear();
-    }
+    if (saveSize)
+      saveWindowSizes();
     if (service != null) {
       service.close();
       service = null;
@@ -638,6 +624,27 @@
     }
   }
 
+  void saveWindowSizes() {
+    if (historyFile == null)
+      return;
+    if (frame != null) {
+      jmolApp.border.x = frame.getWidth() - display.dimSize.width;
+      jmolApp.border.y = frame.getHeight() - display.dimSize.height;
+      historyFile.addWindowInfo("Jmol", frame, jmolApp.border);
+    }
+    //historyFile.addWindowInfo(CONSOLE_WINDOW_NAME, consoleframe);
+    AppConsole console = (AppConsole) viewer.getProperty("DATA_API",
+        "getAppConsole", null);
+    if (console != null && console.jcd != null)
+      historyFile.addWindowInfo(SCRIPT_WINDOW_NAME, console.jcd, null);
+    Component c = (Component) viewer.getProperty("DATA_API", "getScriptEditor",
+        null);
+    if (c != null)
+      historyFile.addWindowInfo(EDITOR_WINDOW_NAME, c, null);
+    if (historyFile.getProperty("clearHistory", "false").equals("true"))
+      historyFile.clear();
+  }
+
 //  protected void setupNewFrame(JmolViewer viewer) {
 //    String state = viewer.getStateInfo();
 //    JFrame newFrame = new JFrame();
@@ -1013,7 +1020,7 @@
     }
 
     public void actionPerformed(ActionEvent e) {
-      if (!doClose()) {
+      if (!doClose(true)) {
         viewer.script("zap");
       }
     }
@@ -1252,6 +1259,7 @@
     }
 
     public void actionPerformed(ActionEvent e) {
+      saveWindowSizes();
       System.exit(0);
     }
   }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to