use of javax.swing.tree.TreePath in project binnavi by google.
the class CNodeExpander method expandNode.
/**
* Expands the project tree node that represents the given object.
*
* @param tree The project tree.
* @param object Object whose node is expanded.
*/
public static void expandNode(final JTree tree, final Object object) {
tree.expandPath(new TreePath(findNode(tree, object).getPath()));
tree.validate();
}
use of javax.swing.tree.TreePath in project binnavi by google.
the class TypeEditorPanel method getSelectedMembers.
@Override
public ImmutableList<TypeMember> getSelectedMembers() {
final Builder<TypeMember> builder = ImmutableList.<TypeMember>builder();
final TreePath[] paths = typesTree.getSelectionPaths();
if (paths != null) {
for (final TreePath path : typesTree.getSelectionPaths()) {
final Object node = path.getLastPathComponent();
if (node instanceof TypeMemberTreeNode) {
builder.add(((TypeMemberTreeNode) node).getTypeMember());
}
}
}
return builder.build();
}
use of javax.swing.tree.TreePath in project binnavi by google.
the class JCriteriumTreeModel method nodeStructureChanged.
@Override
public void nodeStructureChanged(final TreeNode node) {
final Set<ICriterium> criteriumSet = new HashSet<ICriterium>();
final Enumeration<TreePath> expandedPaths = m_jtree.getExpandedDescendants(new TreePath(getRoot()));
if (expandedPaths != null) {
while (expandedPaths.hasMoreElements()) {
final TreePath path = expandedPaths.nextElement();
final JCriteriumTreeNode expandedNode = (JCriteriumTreeNode) path.getLastPathComponent();
criteriumSet.add(expandedNode.getCriterium());
}
}
super.nodeStructureChanged(node);
final Enumeration<?> nodes = ((JCriteriumTreeNode) getRoot()).breadthFirstEnumeration();
while (nodes.hasMoreElements()) {
final JCriteriumTreeNode nextNode = (JCriteriumTreeNode) nodes.nextElement();
if (criteriumSet.contains(nextNode.getCriterium())) {
m_jtree.expandPath(new TreePath(nextNode.getPath()));
}
}
}
use of javax.swing.tree.TreePath in project binnavi by google.
the class CCriteriumFunctions method appendCriterium.
/**
* Appends a criterium to the criterium tree. The criterium is selected through the given combo
* box.
*
* @param jtree Visible criteria tree.
* @param ctree Backs the visible criteria tree.
* @param conditionBox Provides the criterium to add.
*/
public static void appendCriterium(final JCriteriumTree jtree, final CCriteriumTree ctree, final CConditionBox conditionBox) {
final TreePath path = jtree.getSelectionPath();
if (path != null) {
final JCriteriumTreeNode criteriumTreeNode = (JCriteriumTreeNode) path.getLastPathComponent();
final CCriteriumTreeNode parent = CCriteriumFunctions.findNode(ctree.getRoot(), criteriumTreeNode.getCriterium());
final CCriteriumWrapper selectedItem = (CCriteriumWrapper) conditionBox.getSelectedItem();
if (selectedItem != null) {
final ICriterium criterium = selectedItem.getObject().createCriterium();
if (criterium != null) {
appendCriterium(ctree, parent, criterium);
}
}
}
}
use of javax.swing.tree.TreePath in project zaproxy by zaproxy.
the class AlertPanel method setLinkWithSitesTreeSelection.
/**
* Sets whether the "Alerts" tree is filtered, or not based on a selected "Sites" tree node.
* <p>
* If {@code enabled} is {@code true} only the alerts of the selected "Sites" tree node will be shown.
* </p>
* <p>
* Calling this method removes the filter "Just in Scope", if enabled, as they are mutually exclusive.
* </p>
*
* @param enabled {@code true} if the "Alerts" tree should be filtered based on the "Sites" tree selection, {@code false}
* otherwise.
* @see ExtensionAlert#setShowJustInScope(boolean)
*/
public void setLinkWithSitesTreeSelection(boolean enabled) {
linkWithSitesTreeButton.setSelected(enabled);
if (enabled) {
extension.setShowJustInScope(false);
final JTree sitesTree = view.getSiteTreePanel().getTreeSite();
final TreePath selectionPath = sitesTree.getSelectionPath();
getTreeAlert().setModel(getLinkWithSitesTreeModel());
if (selectionPath != null) {
recreateLinkWithSitesTreeModel((SiteNode) selectionPath.getLastPathComponent());
}
sitesTree.addTreeSelectionListener(getLinkWithSitesTreeSelectionListener());
} else {
extension.setMainTreeModel();
((AlertNode) getLinkWithSitesTreeModel().getRoot()).removeAllChildren();
view.getSiteTreePanel().getTreeSite().removeTreeSelectionListener(getLinkWithSitesTreeSelectionListener());
}
}
Aggregations