Revision: 6149
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6149&view=rev
Author: gerdwagner
Date: 2011-01-31 23:31:25 +0000 (Mon, 31 Jan 2011)
Log Message:
-----------
Message Panel right mouse menu "Save size 0"
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrame.java
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/mainframe/I18NStrings.properties
trunk/sql12/doc/src/main/resources/changes.txt
Added Paths:
-----------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/SplitPnResizeHandler.java
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrame.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrame.java 2011-01-27 22:17:41 UTC (rev 6148)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrame.java 2011-01-31 23:31:25 UTC (rev 6149)
@@ -84,14 +84,10 @@
private IDesktopContainer _desktop;
-
- private static final String PREFS_KEY_MESSAGEPANEL_HEIGHT = "squirrelSql_msgPanel_height";
-
-
- private boolean m_hasBeenVisible;
-
private JSplitPane _splitPn;
+ private SplitPnResizeHandler _splitPnResizeHandler;
+
/**
* Ctor.
*
@@ -332,7 +328,7 @@
// had not height = 0. If someone knows a better way
// please tell me I'll apreciate any advice.
// ger...@us...
- resizeSplitOnStartup();
+ _splitPnResizeHandler.resizeSplitOnStartup();
}
}
};
@@ -346,40 +342,11 @@
_splitPn.setResizeWeight(1);
_splitPn.setOneTouchExpandable(true);
+ _splitPnResizeHandler = new SplitPnResizeHandler(_splitPn, _msgPnl);
- //i18n[MainFrame.saveSize=Save size]
- String key = s_stringMgr.getString("MainFrame.saveSize");
- Action splitDividerLocAction = new AbstractAction(key)
- {
- public void actionPerformed(ActionEvent e)
- {
- int msgPanelHeight = _splitPn.getBottomComponent().getSize().height;
- Preferences.userRoot().putInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, msgPanelHeight);
- }
- };
- _msgPnl.addToMessagePanelPopup(splitDividerLocAction);
- //i18n[MainFrame.restoreSize=Restore saved size]
- key = s_stringMgr.getString("MainFrame.restoreSize");
-
- Action setSplitDividerLocAction = new AbstractAction(key)
- {
- public void actionPerformed(ActionEvent e)
- {
- int prefMsgPanelHeight = Preferences.userRoot().getInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, -1);
- if(-1 != prefMsgPanelHeight)
- {
- int divLoc = getDividerLocation(prefMsgPanelHeight, _splitPn);
- _splitPn.setDividerLocation(divLoc);
- }
- }
- };
- _msgPnl.addToMessagePanelPopup(setSplitDividerLocAction);
+ content.add(_splitPn, BorderLayout.CENTER);
-
-
- content.add(_splitPn, BorderLayout.CENTER);
-
_statusBar = new MainFrameStatusBar(_app);
final Font fn = _app.getFontInfoStore().getStatusBarFontInfo().createFont();
_statusBar.setFont(fn);
@@ -417,48 +384,6 @@
});
}
-
- public void resizeSplitOnStartup()
- {
-
- if(false == m_hasBeenVisible)
- {
- m_hasBeenVisible = true;
- final int prefMsgPanelHeight = Preferences.userRoot().getInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, -1);
-
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- if (-1 == prefMsgPanelHeight)
- {
- int divLoc = getDividerLocation(50, _splitPn);
- _splitPn.setDividerLocation(divLoc);
- }
- else
- {
- int divLoc = getDividerLocation(prefMsgPanelHeight, _splitPn);
- _splitPn.setDividerLocation(divLoc);
-
- }
- }
- });
-
- }
- }
-
- private int getDividerLocation(int wantedBottomComponentHeight, JSplitPane splitPn)
- {
- int splitBarSize =
- splitPn.getSize().height -
- splitPn.getBottomComponent().getSize().height -
- splitPn.getTopComponent().getSize().height - 1;
-
- int divLoc = splitPn.getSize().height - wantedBottomComponentHeight - splitBarSize;
- return divLoc;
- }
-
-
private void setupFromPreferences()
{
final SquirrelPreferences prefs = _app.getSquirrelPreferences();
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/SplitPnResizeHandler.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/SplitPnResizeHandler.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/gui/mainframe/SplitPnResizeHandler.java 2011-01-31 23:31:25 UTC (rev 6149)
@@ -0,0 +1,130 @@
+package net.sourceforge.squirrel_sql.client.gui.mainframe;
+
+import net.sourceforge.squirrel_sql.client.session.MessagePanel;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.util.prefs.Preferences;
+
+public class SplitPnResizeHandler
+{
+ private static final StringManager s_stringMgr =
+ StringManagerFactory.getStringManager(SplitPnResizeHandler.class);
+
+ private static final String PREFS_KEY_MESSAGEPANEL_HEIGHT = "squirrelSql_msgPanel_height";
+
+ private boolean m_hasBeenVisible;
+
+ private JSplitPane _splitPn;
+ private MessagePanel _msgPnl;
+
+ public SplitPnResizeHandler(JSplitPane splitPn, MessagePanel msgPnl)
+ {
+ _splitPn = splitPn;
+ _msgPnl = msgPnl;
+
+ String key;
+
+ //i18n[MainFrame.saveSize=Save size]
+ key = s_stringMgr.getString("MainFrame.saveSize");
+ Action saveSplitDividerLocAction = new AbstractAction(key)
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ int msgPanelHeight = _splitPn.getBottomComponent().getSize().height;
+ Preferences.userRoot().putInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, msgPanelHeight);
+ }
+ };
+ _msgPnl.addToMessagePanelPopup(saveSplitDividerLocAction);
+
+ //i18n[MainFrame.saveSize0=Save size 0]
+ key = s_stringMgr.getString("MainFrame.saveSize0");
+ Action save0SplitDividerLocAction = new AbstractAction(key)
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Preferences.userRoot().putInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, 0);
+ setUnexpanded();
+ }
+ };
+ _msgPnl.addToMessagePanelPopup(save0SplitDividerLocAction);
+
+
+ key = s_stringMgr.getString("MainFrame.restoreSize");
+ Action setSplitDividerLocAction = new AbstractAction(key)
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ int prefMsgPanelHeight = Preferences.userRoot().getInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, -1);
+ if(-1 != prefMsgPanelHeight)
+ {
+ if (0 == prefMsgPanelHeight)
+ {
+ setUnexpanded();
+ }
+ else
+ {
+ int divLoc = getDividerLocation(prefMsgPanelHeight, _splitPn);
+ _splitPn.setDividerLocation(divLoc);
+ }
+ }
+ }
+ };
+ _msgPnl.addToMessagePanelPopup(setSplitDividerLocAction);
+
+ }
+
+ private void setUnexpanded()
+ {
+ _splitPn.setDividerLocation(_splitPn.getMaximumDividerLocation() + 100);
+ }
+
+ void resizeSplitOnStartup()
+ {
+
+ if(false == m_hasBeenVisible)
+ {
+ m_hasBeenVisible = true;
+ final int prefMsgPanelHeight = Preferences.userRoot().getInt(PREFS_KEY_MESSAGEPANEL_HEIGHT, -1);
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if (-1 == prefMsgPanelHeight)
+ {
+ int divLoc = getDividerLocation(50, _splitPn);
+ _splitPn.setDividerLocation(divLoc);
+ }
+ else
+ {
+ if (0 == prefMsgPanelHeight)
+ {
+ setUnexpanded();
+ }
+ else
+ {
+ int divLoc = getDividerLocation(prefMsgPanelHeight, _splitPn);
+ _splitPn.setDividerLocation(divLoc);
+ }
+
+ }
+ }
+ });
+
+ }
+ }
+
+ private int getDividerLocation(int wantedBottomComponentHeight, JSplitPane splitPn)
+ {
+ int splitBarSize =
+ splitPn.getSize().height -
+ splitPn.getBottomComponent().getSize().height -
+ splitPn.getTopComponent().getSize().height - 1;
+
+ int divLoc = splitPn.getSize().height - wantedBottomComponentHeight - splitBarSize;
+ return divLoc;
+ }
+}
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/mainframe/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/mainframe/I18NStrings.properties 2011-01-27 22:17:41 UTC (rev 6148)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/gui/mainframe/I18NStrings.properties 2011-01-31 23:31:25 UTC (rev 6149)
@@ -20,6 +20,7 @@
MainFrame.errorOnClose=Couldn't close all sessions. Exit anyway?
MainFrame.restoreSize=Restore saved size
MainFrame.saveSize=Save size
+MainFrame.saveSize0=Save size 0
MainFrameStatusBar.gc=Garbage collection requested
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2011-01-27 22:17:41 UTC (rev 6148)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2011-01-31 23:31:25 UTC (rev 6149)
@@ -11,8 +11,10 @@
Display errors in result tab:
SQL execution errors are now additionally displayed in a temporary result tab.
- This new feature is switched on by default and can be switched off in
- Menu File --> New Session Properties --> Tab SQL --> Show SQL execution errors in result tab
+ - This new feature is switched on by default and can be switched off in
+ Menu File --> New Session Properties --> Tab SQL --> Show SQL execution errors in result tab.
+ - Along with this feature comes a new Message Panel right mouse menu "Save size 0" that allows
+ to hide the Message panel at application start up.
Bug-fixes:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|