Refine search
@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; }
@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); } } } }
nodesCheckingState.put(tp, cn); for (int i = 0 ; i < node.getChildCount() ; i++) { addSubtreeToCheckingStateTracking((DefaultMutableTreeNode) tp.pathByAddingChild(node.getChildAt(i)).getLastPathComponent()); boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; Object obj = node.getUserObject(); TreePath tp = new TreePath(node.getPath()); CheckedNode cn = nodesCheckingState.get(tp); 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);
/** * 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); } } } }
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { // The children are lazy loaded LOGGER.debug( "path = " + event.getPath() + ", last object is a " + event.getPath().getLastPathComponent().getClass().getName()); DefaultMutableTreeNode theTreeNode = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); Node theNode = (Node) theTreeNode.getUserObject(); theNode.setChildren(); logNode(theTreeNode, "will Expand"); }
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); final Object userObject = node.getUserObject(); if (userObject instanceof MongoDatabase) { return ((MongoDatabase) userObject).getName();
return (DefaultMutableTreeNode)(path.getLastPathComponent()); Object obj = node.getUserObject(); if (obj instanceof IconData) obj = ((IconData)obj).getObject(); Object obj = node.getUserObject(); setText(obj.toString()); if (flag==null) // No flag return false; Object obj = flag.getUserObject(); if (!(obj instanceof Boolean)) return false; // Already expanded
/** * Scroll to the error specified by the given tree path, or do nothing * if no error is specified. * * @param treePath the tree path to scroll to. */ private void scrollToError(final TreePath treePath) { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); if (treeNode == null || !(treeNode.getUserObject() instanceof ResultTreeNode)) { return; } final ResultTreeNode nodeInfo = (ResultTreeNode) treeNode.getUserObject(); if (nodeInfo.getFile() == null || nodeInfo.getProblem() == null) { return; // no problem here :-) } final VirtualFile virtualFile = nodeInfo.getFile().getVirtualFile(); if (virtualFile == null || !virtualFile.exists()) { return; } final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); final FileEditor[] editor = fileEditorManager.openFile( virtualFile, true); if (editor.length > 0 && editor[0] instanceof TextEditor) { final LogicalPosition problemPos = new LogicalPosition( Math.max(lineFor(nodeInfo) - 1, 0), Math.max(columnFor(nodeInfo), 0)); final Editor textEditor = ((TextEditor) editor[0]).getEditor(); textEditor.getCaretModel().moveToLogicalPosition(problemPos); textEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } }
static Object getUserObject( TreePath path ) { if( path == null ) { return null; } DefaultMutableTreeNode tn = (DefaultMutableTreeNode)path.getLastPathComponent(); return tn.getUserObject(); }
TreePath[] nodes = tre.getSelectionPaths (); for (int i = 0; i < nodes.length; i ++) { TreePath treePath = nodes[i]; DefaultMutableTreeNode node =(DefaultMutableTreeNode)treePath.getLastPathComponent (); <UserObject> Obj = (<UserObject>) node.getUserObject (); String text=Obj.textvalue }
public void valueForPathChanged(TreePath path, Object newValue) { DefaultMutableTreeNode aNode = (DefaultMutableTreeNode)path.getLastPathComponent(); Category catNode = (Category) aNode.getUserObject(); catNode.setCategory((String) newValue); catNode.updateFromDatabase(); nodeChanged(aNode); }
private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed TreePath[] paths = source.getSelectionPaths(); for (TreePath tp : paths) { Object value = tp.getLastPathComponent(); if (((DefaultMutableTreeNode) value).getUserObject() instanceof Requirement) { Requirement requirement = (Requirement) ((DefaultMutableTreeNode) value).getUserObject(); if (!requirements.contains(requirement)) { ((DefaultListModel) selection.getModel()).addElement(requirement); } } } }//GEN-LAST:event_addActionPerformed
private X509Certificate getSelectedCertificate() { TreePath[] selections = jtrHierarchy.getSelectionPaths(); if (selections == null) { return null; } return (X509Certificate) ((DefaultMutableTreeNode) selections[0].getLastPathComponent()).getUserObject(); }
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; }
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; }
private List<AcquireImageInfo> getSelectedImages(PublishTree tree) { return Arrays.stream(tree.getModel().getCheckingPaths()) .map(o1 -> DefaultMutableTreeNode.class.cast(o1.getLastPathComponent())) .filter(o2 -> AcquireImageInfo.class.isInstance(o2.getUserObject())) .map(o3 -> AcquireImageInfo.class.cast(o3.getUserObject())).collect(Collectors.toList()); }
@Override public String convert(TreePath treePath) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); final Object userObject = node.getUserObject(); if (userObject instanceof Job) { return ((Job) userObject).getName(); } return "<empty>"; } });
public ElementGroup getSelectedGroup() { DefaultMutableTreeNode node = (DefaultMutableTreeNode)rulesTree.getSelectionPath().getLastPathComponent(); RuleTreeUserObject n = (RuleTreeUserObject)node.getUserObject(); if(n.group != null) return n.group; else return null; }
private void updateState() { TreePath path = tree.getSelectionPath(); if(path == null) { removeLibraryAction.setEnabled(false); moveLibraryDownAction.setEnabled(false); moveLibraryUpAction.setEnabled(false); return; } Object o = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject(); removeLibraryAction.setEnabled(o instanceof Entry); moveLibraryDownAction.setEnabled(o instanceof Entry); moveLibraryUpAction.setEnabled(o instanceof Entry); }