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 ps...@apache.org on 2005/11/30 22:24:23 UTC
svn commit: r350052 -
/logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
Author: psmith
Date: Wed Nov 30 13:24:09 2005
New Revision: 350052
URL: http://svn.apache.org/viewcvs?rev=350052&view=rev
Log:
Fixed an exception on exit of Chainsaw. Since there are other plugins
that will be stopped that have nothing to do with ZeroConf stuff, this
check just ignores them if there is no matching menu item.
Modified:
logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
Modified: logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
URL: http://svn.apache.org/viewcvs/logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java?rev=350052&r1=350051&r2=350052&view=diff
==============================================================================
--- logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java (original)
+++ logging/chainsaw/trunk/zeroconf/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java Wed Nov 30 13:24:09 2005
@@ -152,8 +152,10 @@
}
// need to make sure that the menu item tracking this item has it's icon and enabled state updade
JMenuItem item = locateMatchingMenuItem(plugin.getName());
- item.setEnabled(true);
- item.setIcon(null);
+ if (item!=null) {
+ item.setEnabled(true);
+ item.setIcon(null);
+ }
discoveredDevices.fireContentsChanged();
}});
@@ -396,12 +398,20 @@
// this instance of the menu item needs to be disabled, and have an icon added
JMenuItem item = locateMatchingMenuItem(info.getName());
- item.setIcon(new ImageIcon(ChainsawIcons.ANIM_NET_CONNECT));
- item.setEnabled(false);
+ if (item!=null) {
+ item.setIcon(new ImageIcon(ChainsawIcons.ANIM_NET_CONNECT));
+ item.setEnabled(false);
+ }
// now notify the list model has changed, it needs redrawing of the receiver icon now it's connected
discoveredDevices.fireContentsChanged();
}
+ /**
+ * Finds the matching JMenuItem based on name, may return null if there is no match.
+ *
+ * @param name
+ * @return
+ */
private JMenuItem locateMatchingMenuItem(String name) {
Component[] menuComponents = connectToMenu.getMenuComponents();
for (int i = 0; i < menuComponents.length; i++) {
@@ -413,7 +423,7 @@
}
}
}
- throw new IllegalArgumentException("could not locate Menu Item matching name " + name);
+ return null;
}
public static void main(String[] args) throws InterruptedException {
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org