List of usage examples for javax.swing.tree TreePath getLastPathComponent
public Object getLastPathComponent()
From source file:view.CertificatePropertiesDialog.java
private void expandAll(JTree tree, TreePath path) { TreeNode node = (TreeNode) path.getLastPathComponent(); if (node.getChildCount() >= 0) { Enumeration enumeration = node.children(); while (enumeration.hasMoreElements()) { TreeNode n = (TreeNode) enumeration.nextElement(); TreePath p = path.pathByAddingChild(n); expandAll(tree, p);/* w ww . j a va 2 s.co m*/ } } tree.expandPath(path); }
From source file:view.WorkspacePanel.java
@Override public void onSignatureClick(SignatureValidation sv) { if (status != Status.SIGNING) { jtValidation.clearSelection();//ww w. ja v a 2 s. com if (!rightPanel.isVisible()) { cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL)); rightPanel.setVisible(true); jSplitPane1.setDividerSize(5); jSplitPane1.setDividerLocation(0.6); } else if (this.status == Status.SIGNING) { String msg = ""; Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") }; int opt = JOptionPane.showOptionDialog(null, msg, Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (opt == JOptionPane.YES_OPTION) { removeTempSignature(); cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL)); } else { return; } } for (int i = 0; i < jtValidation.getRowCount(); i++) { TreePath tp = jtValidation.getPathForRow(i); DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) tp.getLastPathComponent(); if (dmtn.getUserObject() instanceof SignatureValidation) { SignatureValidation sVal = (SignatureValidation) dmtn.getUserObject(); if (sv.equals(sVal)) { jtValidation.setSelectionRow(i); jtValidation.expandRow(i); } } } status = Status.READY; } }
From source file:vnreal.gui.mapping.MappingTreeSelectionListener.java
@SuppressWarnings("unchecked") @Override/*from ww w .j a v a 2 s . co m*/ public void valueChanged(TreeSelectionEvent e) { if (owner.getGraphPanel() == null) return; List<TreePath> linkProxies = new LinkedList<TreePath>(); for (TreePath path : e.getPaths()) if (path.getLastPathComponent() instanceof LinkProxy) linkProxies.add(path); // if we have a select and unselect of LinkProxies in one step ... if (linkProxies.size() == 2) { // ... ensure unselect comes before select if (e.isAddedPath(linkProxies.get(0))) Collections.reverse(linkProxies); } for (TreePath path : linkProxies) { Object obj = path.getLastPathComponent(); final boolean state = e.isAddedPath(path); if (state) { if (obj instanceof VirtualLinkProxy) { // Highlight one virtual link and its nodes as well several // substrate elements VirtualLinkProxy lp = (VirtualLinkProxy) obj; VirtualLink vl = lp.getLink(); backupVN.put(vl.getLayer(), ((LayerViewer<VirtualNode, VirtualLink>) owner.getGraphPanel() .getViewers().get(vl.getLayer())).getRenderContext().getVertexFillPaintTransformer()); backupVL.put(vl.getLayer(), ((LayerViewer<VirtualNode, VirtualLink>) owner.getGraphPanel() .getViewers().get(vl.getLayer())).getRenderContext().getEdgeDrawPaintTransformer()); highlightVN.addNodes(lp.getvNet().getEndpoints(vl)); highlightVL.addLink(vl); backupSN = ((LayerViewer<SubstrateNode, SubstrateLink>) owner.getGraphPanel().getViewers() .get(0)).getRenderContext().getVertexFillPaintTransformer(); backupSL = ((LayerViewer<SubstrateNode, SubstrateLink>) owner.getGraphPanel().getViewers() .get(0)).getRenderContext().getEdgeDrawPaintTransformer(); int max = lp.getChildCount() - 1; for (int i = 0; i <= max; i++) { MappingProxy child = (MappingProxy) lp.getChildAt(i); Mapping mp = child.getMapping(); if (mp.getResource().getOwner() instanceof SubstrateLink) { highlightSL.links.add((SubstrateLink) mp.getResource().getOwner()); } else if (mp.getResource().getOwner() instanceof SubstrateNode) { SubstrateNode sn = (SubstrateNode) mp.getResource().getOwner(); if (i == 0 || i == max) highlightSN.nodes.add(sn); else highlightSN.nodesHH.add(sn); } } for (Integer layer : backupVN.keySet()) setVNetVertexTransformer(layer, highlightVN); for (Integer layer : backupVL.keySet()) setVNetEdgeTransformer(layer, highlightVL); setSNetVertexTransformer(highlightSN); setSNetEdgeTransformer(highlightSL); } else if (obj instanceof SubstrateLinkProxy) { // Highlight one substrate link and its nodes as well // several virtual elements in different virtual networks SubstrateLinkProxy lp = (SubstrateLinkProxy) obj; SubstrateLink sl = lp.getLink(); backupSN = ((LayerViewer<SubstrateNode, SubstrateLink>) owner.getGraphPanel().getViewers() .get(0)).getRenderContext().getVertexFillPaintTransformer(); backupSL = ((LayerViewer<SubstrateNode, SubstrateLink>) owner.getGraphPanel().getViewers() .get(0)).getRenderContext().getEdgeDrawPaintTransformer(); highlightSL.links.add(sl); highlightSN.nodes.addAll(lp.getNet().getEndpoints(sl)); int max = lp.getChildCount() - 1; for (int i = 0; i <= max; i++) { MappingProxy child = (MappingProxy) lp.getChildAt(i); Mapping mp = child.getMapping(); if (mp.getDemand().getOwner() instanceof VirtualLink) { VirtualLink vl = (VirtualLink) mp.getDemand().getOwner(); backupVL.put(vl.getLayer(), ((LayerViewer<VirtualNode, VirtualLink>) owner.getGraphPanel().getViewers() .get(vl.getLayer())).getRenderContext().getEdgeDrawPaintTransformer()); highlightVL.addLink(vl); } else if (mp.getDemand().getOwner() instanceof VirtualNode) { VirtualNode vn = (VirtualNode) mp.getDemand().getOwner(); backupVN.put(vn.getLayer(), ((LayerViewer<VirtualNode, VirtualLink>) owner.getGraphPanel().getViewers() .get(vn.getLayer())).getRenderContext() .getVertexFillPaintTransformer()); highlightVN.addNode(vn); } } for (Integer layer : backupVN.keySet()) setVNetVertexTransformer(layer, highlightVN); for (Integer layer : backupVL.keySet()) setVNetEdgeTransformer(layer, highlightVL); setSNetVertexTransformer(highlightSN); setSNetEdgeTransformer(highlightSL); } } else { for (Integer layer : backupVN.keySet()) setVNetVertexTransformer(layer, backupVN.get(layer)); for (Integer layer : backupVL.keySet()) setVNetEdgeTransformer(layer, backupVL.get(layer)); backupVN.clear(); backupVL.clear(); highlightVN.vns.clear(); highlightVL.vls.clear(); highlightSN.nodes.clear(); highlightSN.nodesHH.clear(); highlightSL.links.clear(); setSNetVertexTransformer(backupSN); setSNetEdgeTransformer(backupSL); backupSN = null; backupSL = null; } } update(); }