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
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);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]