Author: sdeboy
Date: Sun Jun 6 04:56:37 2010
New Revision: 951816
URL: http://svn.apache.org/viewvc?rev=951816&view=rev
Log:
Adding new 'ignore all loggers' context menut to logger tree - will add all top level loggers to the 'ignore' list (helpful if users want to quickly view events for specific loggers without building expressions)
Modified:
logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java?rev=951816&r1=951815&r2=951816&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java Sun Jun 6 04:56:37 2010
@@ -127,6 +127,7 @@ final class LoggerNameTreePanel extends
new SmallToggleButton();
private final Set hiddenSet = new HashSet();
private final Action hideAction;
+ private final Action hideAllAction;
private final LogPanelPreferenceModel preferenceModel;
private final JList ignoreList = new JList();
@@ -279,6 +280,7 @@ final class LoggerNameTreePanel extends
collapseAction = createCollapseAction();
focusOnAction = createFocusOnAction();
hideAction = createIgnoreAction();
+ hideAllAction = createIgnoreAllAction();
clearIgnoreListAction = createClearIgnoreListAction();
popupMenu = new LoggerTreePopupMenu();
@@ -944,6 +946,50 @@ final class LoggerNameTreePanel extends
return action;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return
+ */
+ private Action createIgnoreAllAction()
+ {
+ Action action =
+ new AbstractAction(
+ "Ignore all loggers", new ImageIcon(ChainsawIcons.ICON_COLLAPSE))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ //add all top level loggers as hidden loggers
+ final DefaultMutableTreeNode root =
+ (DefaultMutableTreeNode) logTreeModel.getRoot();
+ Enumeration topLevelLoggersEnumeration = root.breadthFirstEnumeration();
+ //first element is root node - don't add it to set
+ topLevelLoggersEnumeration.nextElement();
+ Set topLevelLoggersSet = new HashSet();
+ while (topLevelLoggersEnumeration.hasMoreElements()) {
+ String thisLogger = topLevelLoggersEnumeration.nextElement().toString();
+ System.out.println("logger: " + thisLogger);
+ topLevelLoggersSet.add(thisLogger);
+ }
+ if (topLevelLoggersSet.size() > 0) {
+ ignore(topLevelLoggersSet);
+ }
+
+ logTreeModel.nodeChanged(root);
+ ignoreLoggerButton.setSelected(false);
+ focusOnAction.setEnabled(false);
+ popupMenu.hideCheck.setSelected(false);
+ fireChangeEvent();
+ }
+ };
+
+ action.putValue(
+ Action.SHORT_DESCRIPTION,
+ "Adds all loggers to your Ignore list (unhide loggers you want to see in the view)");
+
+ return action;
+ }
+
/**
* DOCUMENT ME!
*
@@ -1142,6 +1188,7 @@ final class LoggerNameTreePanel extends
}
// need to ensure the button doens't update itself with the text, looks stupid otherwise
+ hideAllAction.putValue(Action.NAME, "Ignore all loggers");
focusOnLoggerButton.setText(null);
ignoreLoggerButton.setText(null);
}
@@ -1177,6 +1224,8 @@ final class LoggerNameTreePanel extends
hideAction.setEnabled(
(path != null) && (node != null) && (node.getParent() != null)
&& !isFocusOnSelected());
+ //only enable on root node
+ hideAllAction.setEnabled(node != null && (node.getParent() == null));
if (!focusOnAction.isEnabled())
{
@@ -1486,6 +1535,8 @@ final class LoggerNameTreePanel extends
addSeparator();
add(clearIgnoreListAction);
+ addSeparator();
+ add(hideAllAction);
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.