use of javax.swing.tree.DefaultMutableTreeNode in project zaproxy by zaproxy.
the class PopupMenuItemAlert method getNumberOfSelectedAlerts.
/**
* Gets the number of selected alerts in the Alerts tree.
* <p>
* If multiple alert nodes are selected it returns the corresponding number of alerts. If just a middle alert node (that is,
* the nodes that show the alert name) is selected it returns only one selected alert when {@link #isMultiSelect() multiple
* selection} is not supported, otherwise it returns the number of child nodes (which is one alert per node).
*
* @return the number of selected nodes
*/
private int getNumberOfSelectedAlerts() {
JTree treeAlert = this.extAlert.getAlertPanel().getTreeAlert();
int count = treeAlert.getSelectionCount();
if (count == 0) {
return 0;
}
if (count == 1) {
DefaultMutableTreeNode alertNode = (DefaultMutableTreeNode) treeAlert.getSelectionPath().getLastPathComponent();
if (alertNode.getChildCount() == 0 || !isMultiSelect()) {
return 1;
}
return alertNode.getChildCount();
}
count = 0;
TreePath[] paths = treeAlert.getSelectionPaths();
for (int i = 0; i < paths.length; i++) {
TreePath nodePath = paths[i];
int childCount = ((DefaultMutableTreeNode) nodePath.getLastPathComponent()).getChildCount();
count += childCount != 0 ? childCount : (treeAlert.isPathSelected(nodePath.getParentPath()) ? 0 : 1);
}
return count;
}
use of javax.swing.tree.DefaultMutableTreeNode in project binnavi by google.
the class CDatabaseNodeTest method testUnloaded.
@Test
public void testUnloaded() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final CDatabaseNode node = new CDatabaseNode(m_tree, new DefaultMutableTreeNode(), m_database);
m_database.load();
node.dispose();
assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")).isEmpty());
}
use of javax.swing.tree.DefaultMutableTreeNode in project binnavi by google.
the class CDatabaseNodeTest method testListenersRemoved.
@Test
public void testListenersRemoved() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final CDatabaseNode node = new CDatabaseNode(m_tree, new DefaultMutableTreeNode(), m_database);
node.dispose();
assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")).isEmpty());
}
use of javax.swing.tree.DefaultMutableTreeNode in project binnavi by google.
the class CDatabaseNodeTest method testConstructor.
@Test
public void testConstructor() {
final CDatabaseNode node = new CDatabaseNode(m_tree, new DefaultMutableTreeNode(), m_database);
assertEquals(m_database, node.getObject());
assertNotNull(node.getComponent());
}
use of javax.swing.tree.DefaultMutableTreeNode in project binnavi by google.
the class CDatabaseNodeTest method testLoaded.
@Test
public void testLoaded() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
m_database.load();
final CDatabaseNode node = new CDatabaseNode(m_tree, new DefaultMutableTreeNode(), m_database);
node.dispose();
assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")).isEmpty());
}
Aggregations