You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2004/01/19 08:11:42 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/chainsaw LogPanel.java
sdeboy 2004/01/18 23:11:42
Modified: src/java/org/apache/log4j/chainsaw LogPanel.java
Log:
hide/show detai panel logic updated
Revision Changes Path
1.51 +44 -33 logging-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java
Index: LogPanel.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- LogPanel.java 18 Jan 2004 05:03:08 -0000 1.50
+++ LogPanel.java 19 Jan 2004 07:11:42 -0000 1.51
@@ -189,6 +189,7 @@
final DockablePanel externalPanel;
final Action dockingAction;
final JSortTable table;
+ private final double DEFAULT_SPLIT_LOCATION = .5;
private final LogPanelPreferenceModel preferenceModel = new LogPanelPreferenceModel();
private final LogPanelPreferencePanel preferencesPanel = new LogPanelPreferencePanel(preferenceModel);
private final ColorPanel colorPanel;
@@ -200,6 +201,9 @@
final Map colorDisplayMap = new HashMap();
final Map columnNameKeywordMap = new HashMap();
final JMenuItem menuItemFocusOn = new JMenuItem("Focus on");
+ private double lastSplitLocation = DEFAULT_SPLIT_LOCATION;
+ private int previousSplitLocation;
+ private int dividerSize;
// final ColorDisplaySelector colorDisplaySelector;
ScrollToBottom scrollToBottom;
@@ -266,25 +270,14 @@
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean newValue = ((Boolean) evt.getNewValue()).booleanValue();
-
- // if (newValue) {
- // lowerPanel.setDividerLocation(400);
- // }
- detailPanel.setVisible(newValue);
- lowerPanel.setOneTouchExpandable(newValue);
- }
- });
-
- detailPanel.addPropertyChangeListener("visible",
- new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- lowerPanel.setDividerLocation(0.5d);
- lowerPanel.validate();
+ if (newValue) {
+ showDetailPane();
+ } else {
+ hideDetailPane();
+ }
}
});
- detailPanel.setPreferredSize(new Dimension(320, 160));
-
preferenceModel.addPropertyChangeListener("logTreePanelVisible",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
@@ -545,7 +538,7 @@
public void propertyChange(PropertyChangeEvent evt) {
Rule rule = ruleMediator.getRefinementRule();
- // TODO need to work out how to suspend the DocumentChangeListener reFilter temporarily while this bit updates
+ // TODO need to work out how to suspend the DocumentChangeListener reFilter temporarily while this bit updates
if ((rule != null) && rule instanceof RefinementFocusRule) {
RefinementFocusRule refineRule = (RefinementFocusRule) ruleMediator.getRefinementRule();
filterText.setText(refineRule.getExpression());
@@ -564,8 +557,7 @@
upperPanel.add(upperRightPanel, BorderLayout.EAST);
- eventsAndStatusPanel = new JPanel();
- eventsAndStatusPanel.setLayout(new BorderLayout());
+ eventsAndStatusPanel = new JPanel(new BorderLayout());
final JScrollPane eventsPane = new JScrollPane(table);
@@ -696,13 +688,19 @@
lowerPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
eventsAndStatusPanel, detailPanel);
- lowerPanel.setDividerSize(5);
+
+ lowerPanel.setDividerLocation(lastSplitLocation);
+ lowerPanel.setOneTouchExpandable(true);
+ dividerSize = lowerPanel.getDividerSize() + 5;
lowerPanel.setResizeWeight(0.5);
lowerPanel.setBorder(null);
lowerPanel.setContinuousLayout(true);
- detailPanel.setVisible(getPreferenceModel().isDetailPaneVisible());
- lowerPanel.setOneTouchExpandable(getPreferenceModel().isDetailPaneVisible());
+ if (getPreferenceModel().isDetailPaneVisible()) {
+ showDetailPane();
+ } else {
+ hideDetailPane();
+ }
nameTreeAndMainPanelSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
nameTreeAndMainPanelSplit.add(logTreePanel);
@@ -997,12 +995,6 @@
menuItemToggleDetails.setIcon(new ImageIcon(ChainsawIcons.INFO));
- /**
- * We set this to true first, because the Split pane hasn't been laid
- * out yet, and isDetailPaneVisible() will therefore return false.
- */
- menuItemToggleDetails.getModel().setSelected(true);
-
final Action clearFocusAction = new AbstractAction("Clear focus") {
public void actionPerformed(ActionEvent e) {
filterText.setText(null);
@@ -1120,6 +1112,29 @@
detailDialog.pack();
}
+ private void showDetailPane() {
+ lowerPanel.setDividerSize(dividerSize);
+ lowerPanel.setDividerLocation(lastSplitLocation);
+ lowerPanel.setLastDividerLocation(previousSplitLocation);
+ detailPanel.setVisible(true);
+ }
+
+ private void hideDetailPane() {
+ int currentSize = lowerPanel.getHeight() - dividerSize;
+ if (currentSize > 0) {
+ lastSplitLocation = (double)lowerPanel.getDividerLocation() / currentSize;
+ //if hiding when details are minimized or maximized, use last location
+ if (lastSplitLocation == 1.0 || lastSplitLocation == 0.0) {
+ previousSplitLocation = lowerPanel.getLastDividerLocation();
+ //lastSplitLocation = (double)lowerPanel.getLastDividerLocation() / currentSize;
+ lowerPanel.setLastDividerLocation(lowerPanel.getLastDividerLocation());
+ }
+ }
+
+ lowerPanel.setDividerSize(0);
+ detailPanel.setVisible(false);
+ }
+
private JToolBar createDockwindowToolbar() {
final JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
@@ -1539,8 +1554,6 @@
getPreferenceModel().setDetailPaneVisible(event.asBoolean(
"detailPaneVisible"));
- lowerPanel.setDividerLocation(0.5d);
-
logTreePanel.ignore(event.getSettingsStartingWith("Logger.Ignore."));
File f = new File(SettingsManager.getInstance().getSettingsDirectory() +
@@ -1583,8 +1596,6 @@
TableColumn column = (TableColumn) columnNameMap.get(element);
if (column != null) {
- System.out.println("Moving column " + element + " from index " +
- column.getModelIndex() + " to index " + index++);
sortedColumnList.add(column);
table.removeColumn(column);
}
@@ -1610,7 +1621,7 @@
int width = Integer.parseInt(element);
if (index > (columnModel.getColumnCount() - 1)) {
- System.out.println(
+ LogLog.warn(
"loadsettings - failed attempt to set width for index " +
index + ", width " + element);
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org