public boolean shouldSelectCell(EventObject e) { boolean rv = false; // only mouse events if (e instanceof MouseEvent) { MouseEvent me = (MouseEvent) e; TreePath path = tree.getPathForLocation(me.getX(), me.getY()); CategoryNode node = (CategoryNode) path.getLastPathComponent(); rv = node.isLeaf() /*|| !inCheckBoxHitRegion(me)*/; } return rv; }
@Override public void mousePressed(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path != null) { DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent(); MixedCheckBox checkBox = (MixedCheckBox) currentNode.getUserObject(); // ignore clicks on checkbox's label - enables to select it without changing the state if (e.getX() - tree.getPathBounds(path).getX() > unlabeledMixedCheckBoxWidth) { return; } switch (checkBox.getStatus()) { case CHECKED: resolveNewCheckBoxState(currentNode, UNCHECKED, MIXED); break; case UNCHECKED: resolveNewCheckBoxState(currentNode, CHECKED, MIXED); break; case MIXED: resolveNewCheckBoxState(currentNode, CHECKED, null); break; default: throw new IllegalStateException("The status (" + checkBox.getStatus() + ") is not implemented."); } tree.treeDidChange(); } }
private CheckBoxTree createCheckBoxTree() { final CheckBoxTree resultCheckBoxTree = new CheckBoxTree(initBenchmarkHierarchy(true)); resultCheckBoxTree.addTreeSelectionListener(e -> { TreePath treeSelectionPath = e.getNewLeadSelectionPath(); if (treeSelectionPath != null) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treeSelectionPath.getLastPathComponent(); MixedCheckBox checkBox = (MixedCheckBox) treeNode.getUserObject(); detailTextArea.setText(checkBox.getDetail()); detailTextArea.setCaretPosition(0); renameNodeButton.setEnabled(checkBox.getBenchmarkResult() instanceof PlannerBenchmarkResult || checkBox.getBenchmarkResult() instanceof SolverBenchmarkResult); } }); resultCheckBoxTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { // Enable button if checked singleBenchmarkResults exist generateReportButton.setEnabled(!resultCheckBoxTree.getSelectedSingleBenchmarkNodes().isEmpty()); } }); checkBoxTree = resultCheckBoxTree; return resultCheckBoxTree; }
Object node = path.getLastPathComponent(); Object parentNode = parent.getLastPathComponent(); Object node = temp.getLastPathComponent(); Object peekNode = peekPath.getLastPathComponent(); int childCount = model.getChildCount(node); selectionModel = new CheckTreeSelectionModel(tree.getModel()); TreePath path = tree.getPathForLocation(me.getX(), me.getY()); if(me.getX()/1.2>tree.getPathBounds(path).x+hotspot)
.getLastPathComponent())) lastSelected = e.getPath().getLastPathComponent(); Object o = tpath.getLastPathComponent(); Object po = null; String elementName = ""; if (parentTpath != null) { po = parentTpath.getLastPathComponent(); Class parentClassName = po.getClass(); try { pNames = DEF_JOIN; if (parentName.equalsIgnoreCase("Join")) { Object parentJoin = parentTpath.getLastPathComponent(); int indexOfChild = tree.getModel().getIndexOfChild( parentJoin, o); switch (indexOfChild) {
nodesCheckingState = new HashMap<TreePath, CheckedNode>(); checkedPaths = new HashSet<TreePath>(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)getModel().getRoot(); if (node == null) { return; nodesCheckingState.put(tp, cn); for (int i = 0 ; i < node.getChildCount() ; i++) { addSubtreeToCheckingStateTracking((DefaultMutableTreeNode) tp.pathByAddingChild(node.getChildAt(i)).getLastPathComponent()); TreePath tp = selfPointer.getPathForLocation(arg0.getX(), arg0.getY()); if (tp == null) { return; DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) parentPath.getLastPathComponent(); parentCheckedNode.allChildrenSelected = true; parentCheckedNode.isSelected = false; CheckedNode cn = nodesCheckingState.get(tp); cn.isSelected = check; DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent(); for (int i = 0 ; i < node.getChildCount() ; i++) { checkSubTree(tp.pathByAddingChild(node.getChildAt(i)), check);
public Object getParentObject() { TreePath tPath = tree.getSelectionPath(); if ((tPath != null) && (tPath.getParentPath() != null)) { return tPath.getParentPath().getLastPathComponent(); } return null; }
private RrdNode getSelectedRrdNode() { TreePath path = mainTree.getSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object obj = node.getUserObject(); if (obj instanceof RrdNode) { return (RrdNode) obj; } } return null; }
protected void arrowButtonDownAction(ActionEvent evt) { TreePath tpath = tree.getSelectionPath(); if (tpath != null) { Object current = tpath.getLastPathComponent(); Object child = tree.getModel().getChild(current, 0); if (child != null) { Object[] treeObjs = new Object[30]; int objCnt = 2; while (parentpath != null) { Object po = parentpath.getLastPathComponent(); treeObjs[objCnt] = po; objCnt += 1;
(DefaultMutableTreeNode)dest.getLastPathComponent(); TreePath path = tree.getPathForRow(selRows[0]); DefaultMutableTreeNode firstNode = (DefaultMutableTreeNode)path.getLastPathComponent(); if(firstNode.getChildCount() > 0 && target.getLevel() < firstNode.getLevel()) { TreePath path = tree.getPathForRow(selRows[0]); DefaultMutableTreeNode first = (DefaultMutableTreeNode)path.getLastPathComponent(); int childCount = first.getChildCount(); path = tree.getPathForRow(selRows[i]); DefaultMutableTreeNode next = (DefaultMutableTreeNode)path.getLastPathComponent(); if(first.isNodeChild(next)) { new ArrayList<DefaultMutableTreeNode>(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)paths[0].getLastPathComponent(); DefaultMutableTreeNode copy = copy(node); copies.add(copy); for(int i = 1; i < paths.length; i++) { DefaultMutableTreeNode next = (DefaultMutableTreeNode)paths[i].getLastPathComponent(); TreePath dest = dl.getPath(); DefaultMutableTreeNode parent =
private X509Certificate getSelectedCertificate() { TreePath[] selections = jtrHierarchy.getSelectionPaths(); if (selections == null) { return null; } return (X509Certificate) ((DefaultMutableTreeNode) selections[0].getLastPathComponent()).getUserObject(); }
@Override public String getToolTipText(MouseEvent e) { if (getRowForLocation(e.getX(), e.getY()) == -1) { return null; } TreePath curPath = getPathForLocation(e.getX(), e.getY()); if (curPath.getLastPathComponent() instanceof ASTTreeNode) { return ((ASTTreeNode) curPath.getLastPathComponent()).getToolTipText(); } else { return super.getToolTipText(e); } }
/** * Fix compatibility issue with right click on Linux. * @param e Mouse event */ private void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } DefaultMutableTreeNode currentTableNode = (DefaultMutableTreeNode) path.getLastPathComponent(); if (currentTableNode.getUserObject() instanceof AbstractNodeModel) { AbstractNodeModel currentTableModel = (AbstractNodeModel) currentTableNode.getUserObject(); if (currentTableModel.isPopupDisplayable()) { currentTableModel.showPopup(currentTableNode, path, e); } } } }
@Override public void actionPerformed(ActionEvent e) { if (checkBoxTree.getSelectionPath() != null) { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) checkBoxTree.getSelectionPath().getLastPathComponent(); MixedCheckBox mixedCheckBox = (MixedCheckBox) selectedNode.getUserObject(); if (mixedCheckBox.getBenchmarkResult() instanceof PlannerBenchmarkResult || mixedCheckBox.getBenchmarkResult() instanceof SolverBenchmarkResult) { RenameNodeDialog renameNodeDialog = new RenameNodeDialog(selectedNode); renameNodeDialog.pack(); renameNodeDialog.setLocationRelativeTo(BenchmarkAggregatorFrame.this); renameNodeDialog.setVisible(true); } } } }
public void mouseClicked (MouseEvent ev) { if (ev.getClickCount () != 2) return; TreePath path = tree.getPathForLocation (ev.getX (), ev.getY ()); if (path == null) return; Object node = path.getLastPathComponent (); LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel (); model.show (node); }
TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { Object parent = parentpath.getLastPathComponent(); if (parent instanceof MondrianGuiDef.Join) { int indexOfChild = tree.getModel().getIndexOfChild( parent, value); switch (indexOfChild) {
protected void addAnnotations(ActionEvent evt) { TreePath tpath = null; tpath = getTreePath(evt); Object path = tree.getSelectionPath().getLastPathComponent(); refreshTree(tree.getSelectionPath());
private RrdNode getSelectedRrdNode() { TreePath path = mainTree.getSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object obj = node.getUserObject(); if (obj instanceof RrdNode) { return (RrdNode) obj; } } return null; }
TreePath tpath = tree.getSelectionPath(); if (tpath != null) { Object value = tpath.getLastPathComponent(); TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { Object parent = parentpath.getLastPathComponent(); if (parent instanceof MondrianGuiDef.Hierarchy) { ((MondrianGuiDef.Hierarchy) parent).relation = relationObj; } else if (parent instanceof MondrianGuiDef.Join) { int indexOfChild = tree.getModel().getIndexOfChild(parent, value); switch (indexOfChild) { case 0:
@Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); tree.setSelectionPath(path); JPopupMenu menu = new ASTNodePopupMenu(model, (Node) path.getLastPathComponent()); menu.show(tree, e.getX(), e.getY()); } } });