From dev-return-51387-apmail-ant-dev-archive=ant.apache.org@ant.apache.org Thu Oct 02 05:00:14 2003 Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 35831 invoked from network); 2 Oct 2003 05:00:14 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Oct 2003 05:00:14 -0000 Received: (qmail 59243 invoked by uid 500); 2 Oct 2003 04:59:50 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 59197 invoked by uid 500); 2 Oct 2003 04:59:50 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 59184 invoked from network); 2 Oct 2003 04:59:50 -0000 Received: from unknown (HELO central.purematrix.com) (66.180.124.162) by daedalus.apache.org with SMTP; 2 Oct 2003 04:59:50 -0000 Received: from purematrix.com (slip-12-65-144-148.mis.prserv.net [12.65.144.148]) by central.purematrix.com (Postfix) with SMTP id 1CC2D3E4F; Wed, 1 Oct 2003 22:59:59 -0600 (MDT) Sender: jax@purematrix.com Message-ID: <3F7BAD77.FDE70E4@purematrix.com> Date: Wed, 01 Oct 2003 22:45:43 -0600 From: "Jack J. Woehr" Reply-To: jax@purematrix.com Organization: SoftWoehr Team Mentoring X-Mailer: Mozilla 4.78 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: Ant Developers List Subject: Antidote: Diff to make window size persistent Content-Type: multipart/mixed; boundary="------------5F540F4A049478A258A33567" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --------------5F540F4A049478A258A33567 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This diff makes window size persistent. It may not be the most important persistent property, but it sure is annoying to continually have to stretch the window to a size that allows the editor gadgets to render themselves in a reasonable fashion! -- Jack J. Woehr # You measure democracy by the freedom it Senior Consultant # gives its dissidents, not the freedom Purematrix, Inc. # it gives its assimilated conformists. www.purematrix.com # - Abbie Hoffman --------------5F540F4A049478A258A33567 Content-Type: text/plain; charset=us-ascii; name="antidote.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="antidote.diff" Index: org/apache/tools/ant/gui/Main.java =================================================================== RCS file: /home/cvspublic/ant-antidote/src/java/org/apache/tools/ant/gui/Main.java,v retrieving revision 1.9 diff -c -r1.9 Main.java *** org/apache/tools/ant/gui/Main.java 28 Sep 2003 13:03:00 -0000 1.9 --- org/apache/tools/ant/gui/Main.java 2 Oct 2003 04:56:08 -0000 *************** *** 100,106 **** f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AppContext context = new AppContext(f); f.setContext(context); ! /* Doing this in a block to limit scope of temps */ { String propertiesFileName = settings.getPropertiesFile(); --- 100,106 ---- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AppContext context = new AppContext(f); f.setContext(context); ! /* Doing this in a block to limit scope of temps */ { String propertiesFileName = settings.getPropertiesFile(); *************** *** 181,186 **** --- 181,187 ---- new AppStartupEvent(context)); f.pack(); + f.restorePersistentSize(); f.setVisible(true); // Send notice we are shutting down Index: org/apache/tools/ant/gui/MainFrame.java =================================================================== RCS file: /home/cvspublic/ant-antidote/src/java/org/apache/tools/ant/gui/MainFrame.java,v retrieving revision 1.4 diff -c -r1.4 MainFrame.java *** org/apache/tools/ant/gui/MainFrame.java 28 Sep 2003 13:02:59 -0000 1.4 --- org/apache/tools/ant/gui/MainFrame.java 2 Oct 2003 04:56:08 -0000 *************** *** 55,61 **** package org.apache.tools.ant.gui; import org.apache.tools.ant.gui.core.AppContext; ! //import org.apache.tools.ant.gui.core.ProjectManager; import org.apache.tools.ant.gui.event.ProjectClosedEvent; import org.apache.tools.ant.gui.event.ProjectSelectedEvent; --- 55,61 ---- package org.apache.tools.ant.gui; import org.apache.tools.ant.gui.core.AppContext; ! import org.apache.tools.ant.gui.core.PropertiesManager; import org.apache.tools.ant.gui.event.ProjectClosedEvent; import org.apache.tools.ant.gui.event.ProjectSelectedEvent; *************** *** 63,68 **** --- 63,69 ---- import org.apache.tools.ant.gui.acs.ACSProjectElement; import java.io.IOException; + import java.awt.Dimension; /** * The main frame for the application *************** *** 136,144 **** --- 137,182 ---- } /** + * Save the window size for the next session + */ + protected void persistSize () { + Dimension d = getSize(); + PropertiesManager pm = _context.getPropertiesManager(); + pm.setProperty("MainFrame.height", new Integer(new Double(d.getHeight()).intValue()).toString()); + pm.setProperty("MainFrame.width", new Integer(new Double(d.getWidth()).intValue()).toString()); + try { + _context.saveProperties(); + } + catch (java.io.FileNotFoundException e) { + // log it? + } + catch (java.io.IOException e) { + // log it? + } + } + + /** + * Restore the window size from the previous session + */ + protected void restorePersistentSize () { + PropertiesManager pm = _context.getPropertiesManager(); + try { + setSize(pm.get_int_property("MainFrame.width"), pm.get_int_property("MainFrame.height")); + } + catch (PropertiesManager.NoSuchPropertyException e) { + // Just means that it's never been saved to persistent properties yet. + } + + catch (PropertiesManager.InvalidIntPropertyException e) { + // Should never occur unless user edited file and messed it up. + } + } + + /** * Intercept the window close event */ protected void processWindowEvent(java.awt.event.WindowEvent windowEvent) { + persistSize(); // Save window size for next session if (windowEvent.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING) { if (exitForm(windowEvent)) { super.processWindowEvent(windowEvent); --------------5F540F4A049478A258A33567 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org --------------5F540F4A049478A258A33567--