Fixes to persistence of detail panel position, not updating look and feel if not set
Project: http://git-wip-us.apache.org/repos/asf/logging-chainsaw/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-chainsaw/commit/a3dda155 Tree: http://git-wip-us.apache.org/repos/asf/logging-chainsaw/tree/a3dda155 Diff: http://git-wip-us.apache.org/repos/asf/logging-chainsaw/diff/a3dda155 Branch: refs/heads/master Commit: a3dda1555bcc1febc0d55decbb3c77ebc88d4aeb Parents: 3449713 Author: Scott Deboy <[email protected]> Authored: Tue Oct 26 04:45:07 2010 +0000 Committer: Scott Deboy <[email protected]> Committed: Tue Oct 26 04:45:07 2010 +0000 ---------------------------------------------------------------------- .../org/apache/log4j/chainsaw/LogPanel.java | 49 +++++++++++--------- .../java/org/apache/log4j/chainsaw/LogUI.java | 11 +++-- 2 files changed, 32 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/a3dda155/src/main/java/org/apache/log4j/chainsaw/LogPanel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/chainsaw/LogPanel.java b/src/main/java/org/apache/log4j/chainsaw/LogPanel.java index d2bc5e3..189cac4 100644 --- a/src/main/java/org/apache/log4j/chainsaw/LogPanel.java +++ b/src/main/java/org/apache/log4j/chainsaw/LogPanel.java @@ -233,7 +233,6 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi private final RuleMediator tableRuleMediator = new RuleMediator(false); private final RuleMediator searchRuleMediator = new RuleMediator(true); private final EventDetailLayout detailLayout = new EventDetailLayout(); - private double lastDetailPanelSplitLocation = DEFAULT_DETAIL_SPLIT_LOCATION; private double lastLogTreePanelSplitLocation = DEFAULT_LOG_TREE_SPLIT_LOCATION; private Point currentPoint; private JTable currentTable; @@ -269,6 +268,7 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi private boolean searchResultsDisplayed; private ColorizedEventAndSearchMatchThumbnail colorizedEventAndSearchMatchThumbnail; private EventTimeDeltaMatchThumbnail eventTimeDeltaMatchThumbnail; + private boolean isDetailPanelVisible; /** * Creates a new LogPanel object. If a LogPanel with this identifier has @@ -2268,9 +2268,9 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi loadDefaultColumnSettings(event); } //ensure tablemodel cyclic flag is updated + //may be panel configs that don't have these values tableModel.setCyclic(preferenceModel.isCyclic()); searchModel.setCyclic(preferenceModel.isCyclic()); - //may be panel configs that don't have these values lowerPanel.setDividerLocation(lowerPanelDividerLocation); nameTreeAndMainPanelSplit.setDividerLocation(treeDividerLocation); detailLayout.setConversionPattern(conversionPattern); @@ -2296,9 +2296,12 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi } } } else { + //not setting lower panel divider location here - will do that after the UI is visible loadDefaultColumnSettings(event); } - + //ensure tablemodel cyclic flag is updated + tableModel.setCyclic(preferenceModel.isCyclic()); + searchModel.setCyclic(preferenceModel.isCyclic()); logTreePanel.ignore(preferenceModel.getHiddenLoggers()); logTreePanel.setHiddenExpression(preferenceModel.getHiddenExpression()); if (preferenceModel.getClearTableExpression() != null) { @@ -2347,12 +2350,13 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi FileWriter w = new FileWriter(xmlFile); s = stream.createObjectOutputStream(w); s.writeObject(preferenceModel); - if (lowerPanelDividerLocation == 0) { - //pick a reasonable default - s.writeInt((int) (lowerPanel.getSize().height * DEFAULT_DETAIL_SPLIT_LOCATION)); - } else { - s.writeInt(lowerPanelDividerLocation); - } + if (isDetailPanelVisible) { + //use current size + s.writeInt(lowerPanel.getDividerLocation()); + } else { + //use size when last hidden + s.writeInt(lowerPanelDividerLocation); + } s.writeInt(nameTreeAndMainPanelSplit.getDividerLocation()); s.writeObject(detailLayout.getConversionPattern()); s.writeObject(undockedFrame.getLocation()); @@ -2701,34 +2705,33 @@ public class LogPanel extends DockablePanel implements EventBatchListener, Profi * Display the detail pane, using the last known divider location */ private void showDetailPane() { - lowerPanel.setDividerSize(dividerSize); - if (lowerPanelDividerLocation != 0) { - lowerPanel.setDividerLocation(lowerPanelDividerLocation); + if (!isDetailPanelVisible) { + lowerPanel.setDividerSize(dividerSize); + if (lowerPanelDividerLocation == 0) { + lowerPanel.setDividerLocation(DEFAULT_DETAIL_SPLIT_LOCATION); + lowerPanelDividerLocation = lowerPanel.getDividerLocation(); } else { - lowerPanel.setDividerLocation(lastDetailPanelSplitLocation); + lowerPanel.setDividerLocation(lowerPanelDividerLocation); } detailPanel.setVisible(true); detailPanel.repaint(); lowerPanel.repaint(); + isDetailPanelVisible = true; + } } /** * Hide the detail pane, holding the current divider location for later use */ private void hideDetailPane() { - int currentSize = lowerPanel.getHeight() - lowerPanel.getDividerSize(); - - if (currentSize > 0) { - lastDetailPanelSplitLocation = - (double) lowerPanel.getDividerLocation() / currentSize; - } - if (lowerPanel.getDividerLocation() > 0) { - lowerPanelDividerLocation = lowerPanel.getDividerLocation(); - } - + //may be called not currently visible on initial setup to ensure panel is not visible..only update divider location if hiding when currently visible + if (isDetailPanelVisible) { + lowerPanelDividerLocation = lowerPanel.getDividerLocation(); + } lowerPanel.setDividerSize(0); detailPanel.setVisible(false); lowerPanel.repaint(); + isDetailPanelVisible = false; } /** http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/a3dda155/src/main/java/org/apache/log4j/chainsaw/LogUI.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java index e85a974..984a421 100644 --- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java +++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java @@ -286,8 +286,11 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener { { public void run() { - loadLookAndFeelUsingPluginClassLoader(model.getLookAndFeelClassName()); - createChainsawGUI(model, null); + String lookAndFeelClassName = model.getLookAndFeelClassName(); + if (lookAndFeelClassName != null && !(lookAndFeelClassName.trim().equals(""))) { + loadLookAndFeelUsingPluginClassLoader(lookAndFeelClassName); + } + createChainsawGUI(model, null); } }); } @@ -1040,12 +1043,10 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener { initializationLock.notifyAll(); } - - if ( noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) { - EventQueue.invokeLater(new Runnable() { + SwingHelper.invokeOnEDT(new Runnable() { public void run() { showReceiverConfigurationPanel(); }
