Java Code Examples for javax.swing.tree.DefaultMutableTreeNode#setUserObject()
The following examples show how to use
javax.swing.tree.DefaultMutableTreeNode#setUserObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassifyDataJPanel.java From opensim-gui with Apache License 2.0 | 6 votes |
public void setAmotion(AnnotatedMotion amotion) { this.amotion = amotion; DefaultMutableTreeNode root=new DefaultMutableTreeNode("Lab Frame"); treeModel = new ExperimentalDataTreeModel(root); jDataTree.setModel(treeModel); // Get "classified" labels and use them to populate jListAvailable final Vector<ExperimentalDataObject> classified = amotion.getClassified(); final ArrayStr labels = amotion.getColumnLabels(); int labelIndex=1; // Since time is 0 for(int i=0; i<classified.size(); i++){ DefaultMutableTreeNode nextChild=new DefaultMutableTreeNode(classified.get(i).toString()); nextChild.setUserObject(classified.get(i)); treeModel.appendChild(nextChild, root); labelIndex+= classified.get(i).getObjectType().getNumberOfColumns(); } displayer=MotionControlJPanel.getInstance().getMasterMotion().getDisplayer(amotion); // get existing rotations double[] rots = amotion.getCurrentRotations(); XSpinner.setValue(rots[0]); YSpinner.setValue(rots[1]); ZSpinner.setValue(rots[2]); }
Example 2
Source File: InspectorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
void setupTreeNode(DefaultMutableTreeNode node, DiagnosticsNode diagnosticsNode, boolean expandChildren) { node.setUserObject(diagnosticsNode); node.setAllowsChildren(diagnosticsNode.hasChildren()); final InspectorInstanceRef valueRef = diagnosticsNode.getValueRef(); // Properties do not have unique values so should not go in the valueToTreeNode map. if (valueRef.getId() != null && !diagnosticsNode.isProperty()) { valueToTreeNode.put(valueRef, node); } if (parentTree != null) { parentTree.maybeUpdateValueUI(valueRef); } if (diagnosticsNode.hasChildren() || !diagnosticsNode.getInlineProperties().isEmpty()) { if (diagnosticsNode.childrenReady() || !diagnosticsNode.hasChildren()) { final CompletableFuture<ArrayList<DiagnosticsNode>> childrenFuture = diagnosticsNode.getChildren(); assert (childrenFuture.isDone()); setupChildren(diagnosticsNode, node, childrenFuture.getNow(null), expandChildren); } else { node.removeAllChildren(); node.add(new DefaultMutableTreeNode("Loading...")); } } }
Example 3
Source File: PackagesBrowserPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
public void setMagicEdition(MagicEdition ed) { DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot(); root.setUserObject(ed); root.removeAllChildren(); Arrays.asList(Packaging.TYPE.values()).forEach(t->{ List<Packaging> pks = provider.get(ed, t); logger.trace("loading " + ed + " " + pks); if(!pks.isEmpty()) { DefaultMutableTreeNode dir = new DefaultMutableTreeNode(t); pks.forEach(p->dir.add(new DefaultMutableTreeNode(p))); root.add(dir); } }); model.reload(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } if(view) panelDraw.setImg(null); }
Example 4
Source File: ServicePanel.java From megan-ce with GNU General Public License v3.0 | 6 votes |
/** * updates fonts used in tree */ public void updateFonts() { final Set<String> openFiles = getCurrentlyOpenRemoteFiles(); for (int i = 0; i < fileTree.getRowCount(); i++) { DefaultMutableTreeNode v = (DefaultMutableTreeNode) fileTree.getPathForRow(i).getLastPathComponent(); String file = leaf2file.get(v); if (file != null) { if (openFiles.contains(service.getServerAndFileName(file))) { int pos = file.lastIndexOf(File.separator); if (pos == -1) v.setUserObject(file); else v.setUserObject(file.substring(pos + 1)); } else { String user = v.getUserObject().toString(); if (!user.startsWith("<html>")) v.setUserObject("<html><b>" + user + "</b></html>"); } } } }
Example 5
Source File: XSheet.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 6
Source File: XSheet.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 7
Source File: XSheet.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 8
Source File: XSheet.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 9
Source File: XSheet.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 10
Source File: XSheet.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 11
Source File: XSheet.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Update the label of the supplied MBean tree node. */ // Call on EDT private void updateNotificationsNodeLabel( DefaultMutableTreeNode node, String label) { synchronized (mbeansTab.getTree()) { invalidate(); XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject(); XNodeInfo newUserObject = new XNodeInfo( oldUserObject.getType(), oldUserObject.getData(), label, oldUserObject.getToolTipText()); node.setUserObject(newUserObject); DefaultTreeModel model = (DefaultTreeModel) mbeansTab.getTree().getModel(); model.nodeChanged(node); validate(); repaint(); } }
Example 12
Source File: CheckBoxStatusUpdateListener.java From java-swing-tips with MIT License | 6 votes |
private void updateParentUserObject(DefaultMutableTreeNode parent) { // Java 9: Collections.list(parent.children()).stream() List<Status> list = Collections.list((Enumeration<?>) parent.children()).stream() .filter(DefaultMutableTreeNode.class::isInstance) .map(DefaultMutableTreeNode.class::cast) .map(DefaultMutableTreeNode::getUserObject) .filter(CheckBoxNode.class::isInstance) .map(CheckBoxNode.class::cast) .map(CheckBoxNode::getStatus) .collect(Collectors.toList()); Object o = parent.getUserObject(); if (o instanceof CheckBoxNode) { String label = ((CheckBoxNode) o).getLabel(); if (list.stream().allMatch(s -> s == Status.DESELECTED)) { parent.setUserObject(new CheckBoxNode(label, Status.DESELECTED)); } else if (list.stream().allMatch(s -> s == Status.SELECTED)) { parent.setUserObject(new CheckBoxNode(label, Status.SELECTED)); } else { parent.setUserObject(new CheckBoxNode(label, Status.INDETERMINATE)); } } }
Example 13
Source File: TreeGuiView.java From niftyeditor with Apache License 2.0 | 6 votes |
public void initView(GUI gui) { this.jTree2.addMouseListener(new PopUpShowListener(new EditingPopUp())); this.jTree2.addTreeSelectionListener(new ElementSelectionListener()); jTree2.setCellRenderer(new NiftyTreeRender()); DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.jTree2.getModel().getRoot(); root.removeAllChildren(); root.setUserObject(gui); for (GScreen screen : gui.getScreens()) { DefaultMutableTreeNode screenNode = new DefaultMutableTreeNode(screen); addRecursive(screen, screenNode); root.add(screenNode); } for (int row = 0; row < jTree2.getRowCount(); row++) { jTree2.expandRow(row); } this.jTree2.updateUI(); }
Example 14
Source File: CheckBoxStatusUpdateListener.java From java-swing-tips with MIT License | 6 votes |
private void updateParentUserObject(DefaultMutableTreeNode parent) { // Java 9: Collections.list(parent.children()).stream() List<Status> list = Collections.list((Enumeration<?>) parent.children()).stream() .filter(DefaultMutableTreeNode.class::isInstance) .map(DefaultMutableTreeNode.class::cast) .map(DefaultMutableTreeNode::getUserObject) .filter(CheckBoxNode.class::isInstance) .map(CheckBoxNode.class::cast) .map(CheckBoxNode::getStatus) .collect(Collectors.toList()); Object o = parent.getUserObject(); if (o instanceof CheckBoxNode) { String label = ((CheckBoxNode) o).getLabel(); if (list.stream().allMatch(s -> s == Status.DESELECTED)) { parent.setUserObject(new CheckBoxNode(label, Status.DESELECTED)); } else if (list.stream().allMatch(s -> s == Status.SELECTED)) { parent.setUserObject(new CheckBoxNode(label, Status.SELECTED)); } else { parent.setUserObject(new CheckBoxNode(label, Status.INDETERMINATE)); } } }
Example 15
Source File: TreeTestBase.java From jenetics with Apache License 2.0 | 5 votes |
@Test public void inequality() { final T tree = newTree(5, new Random(123)); final DefaultMutableTreeNode stree = newSwingTree(5, new Random(123)); stree.setUserObject(39393); Assert.assertFalse(equals(tree, stree)); }
Example 16
Source File: SampleTreeAnalysisMode.java From ET_Redux with Apache License 2.0 | 5 votes |
private void populateSampleDateModel( Vector<String> activeFractionIDs, AliquotInterface aliquot, ValueModel SAM, DefaultMutableTreeNode SAMnode) { DefaultMutableTreeNode sampleDateValue = new DefaultMutableTreeNode(// ((SampleDateModel) SAM).ShowCustomDateNode()); SAMnode.add(sampleDateValue); DefaultMutableTreeNode sampleDateMSWD = new DefaultMutableTreeNode(// ((SampleDateModel) SAM).ShowCustomMSWDwithN()); SAMnode.add(sampleDateMSWD); if (((SampleDateModel) SAM).getMethodName().contains("LowerIntercept")) { SAMnode.add(new DefaultMutableTreeNode("See Upper Intercept Fractions")); } else { DefaultMutableTreeNode sampleDateFractions = new DefaultMutableTreeNode("Fractions"); SAMnode.add(sampleDateFractions); // create checkbox for each fraction set to whether it is in list for (String fracID : activeFractionIDs) { DefaultMutableTreeNode fractionNode = new DefaultMutableTreeNode(fracID); fractionNode.setUserObject( // new CheckBoxNode( ((SampleDateModel) SAM).showFractionIdWithDateAndUnct(((ReduxAliquotInterface) aliquot).getAliquotFractionByName(fracID)), ((SampleDateModel) SAM).includesFractionByName(fracID), true)); sampleDateFractions.add(fractionNode); } } }
Example 17
Source File: AqlCodeEditor.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
@Override protected DefaultMutableTreeNode makeTree(List<String> set) { DefaultMutableTreeNode root = new DefaultMutableTreeNode(); AqlTyping G = aqlStatic.env.typing; for (String k : set) { Exp<?> e = aqlStatic.env.prog.exps.get(k); if (e == null) { // System.out.println(k + " " + s); Util.anomaly(); } if (e.kind().equals(Kind.COMMENT)) { continue; } String k0 = k; if (G.prog.exps.containsKey(k)) { Kind kk = G.prog.exps.get(k).kind(); if (outline_types) { k0 = AqlDisplay.doLookup(outline_prefix_kind, k, kk, G); } else { k0 = outline_prefix_kind ? kk + k : k; } } DefaultMutableTreeNode n = new DefaultMutableTreeNode(); n.setUserObject(new TreeLabel(k0, k)); asTree(n, e); root.add(n); } return root; }
Example 18
Source File: PascalDisk.java From DiskBrowser with GNU General Public License v3.0 | 4 votes |
public PascalDisk (Disk disk) // ---------------------------------------------------------------------------------// { super (disk); sectorTypesList.add (diskBootSector); sectorTypesList.add (catalogSector); sectorTypesList.add (dataSector); sectorTypesList.add (codeSector); sectorTypesList.add (textSector); sectorTypesList.add (infoSector); sectorTypesList.add (grafSector); sectorTypesList.add (fotoSector); sectorTypesList.add (badSector); List<DiskAddress> blocks = disk.getDiskAddressList (0, 1); // B0, B1 this.bootSector = new BootSector (disk, disk.readBlocks (blocks), "Pascal"); for (int i = 0; i < 2; i++) if (!disk.isBlockEmpty (i)) { sectorTypes[i] = diskBootSector; freeBlocks.set (i, false); } for (int i = 2; i < disk.getTotalBlocks (); i++) freeBlocks.set (i, true); byte[] buffer = disk.readBlock (2); byte[] data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE); volumeEntry = new VolumeEntry (this, data); DefaultMutableTreeNode root = getCatalogTreeRoot (); DefaultMutableTreeNode volumeNode = new DefaultMutableTreeNode (volumeEntry); root.add (volumeNode); List<DiskAddress> sectors = new ArrayList<> (); int max = Math.min (volumeEntry.lastBlock, disk.getTotalBlocks ()); for (int i = 2; i < max; i++) { DiskAddress da = disk.getDiskAddress (i); if (!disk.isBlockEmpty (da)) sectorTypes[i] = catalogSector; sectors.add (da); freeBlocks.set (i, false); } diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors); // read the catalog List<DiskAddress> addresses = new ArrayList<> (); for (int i = 2; i < max; i++) addresses.add (disk.getDiskAddress (i)); buffer = disk.readBlocks (addresses); // loop through each catalog entry (what if there are deleted files?) for (int i = 1; i <= volumeEntry.totalFiles; i++) { int ptr = i * CATALOG_ENTRY_SIZE; data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, ptr, data, 0, CATALOG_ENTRY_SIZE); FileEntry fileEntry = new FileEntry (this, data); fileEntries.add (fileEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry); fileEntry.setNode (node); if (fileEntry.fileType == 2) { node.setAllowsChildren (true); fileEntry.getDataSource (); // build segments } else node.setAllowsChildren (false); volumeNode.add (node); for (int j = fileEntry.firstBlock; j < fileEntry.lastBlock; j++) freeBlocks.set (j, false); } volumeNode.setUserObject (getCatalog ()); makeNodeVisible (volumeNode.getFirstLeaf ()); }
Example 19
Source File: CalculationTreeEditor.java From swing_library with MIT License | 4 votes |
public Object getCellEditorValue() { System.out.println("getCellEditorValue"); Double i = (Double) emptyNodeEditor.getCellEditorValue(); ValueNode vn = new ValueNode(i); editedNode.setUserObject(new ValueNode(i)); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) editedNode .getParent(); int index = parent.getIndex(editedNode); if (editedNode.getUserObject() instanceof MultiEmptyNode) { DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) editedNode .getParent(); DefaultMutableTreeNode newMultiEmpty = new DefaultMutableTreeNode(); newMultiEmpty.setUserObject(new MultiEmptyNode()); parentNode.add(newMultiEmpty); } else if (parent.getUserObject() instanceof BinaryOperator) { System.out.println("parent user object is BinaryOperator"); // inserting into the actual object model BinaryOperator bo = (BinaryOperator) parent.getUserObject(); if (index == 0) { System.out.println("setting first operand type = " + vn.getClass()); bo.setFirstOperand(vn); } else if (index == 1) { System.out.println("setting second operand type = " + vn.getClass()); bo.setSecondOperand(vn); } } else if (parent.getUserObject() instanceof FunctionInput) { System.out.println("parent user object is FunctionInput"); FunctionInput fi = (FunctionInput) parent.getUserObject(); fi.setValue(vn); } // this System.out.println("<<< get cell editor value >>>>"); System.out.println("editedNode.getUserObject() = " + editedNode.getUserObject()); calculationPanel.updateCalculationText(); return editedNode.getUserObject(); }
Example 20
Source File: ProjectLogicImpl.java From sakai with Educational Community License v2.0 | 4 votes |
/** * This is a helper function for addChildrenNodes. It will add the child nodes to the parent node and create the NodeModel. * * @param childNode * @param parentNode * @param realmMap * @param userId * @return */ private boolean addChildNodeToTree(HierarchyNodeSerialized childNode, DefaultMutableTreeNode parentNode, String userId, List<ListOptionSerialized> blankRestrictedTools, boolean onlyAccessNodes, boolean shoppingPeriodTool){ boolean added = false; if(!doesChildExist(childNode.id, parentNode)){ //just create a blank child since the user should already have all the nodes with information in the db String realm = ""; String role = ""; boolean selected = false; Date startDate = null; Date endDate = null; //you must copy to not pass changes to other nodes List<ListOptionSerialized> restrictedAuthTools = copyListOptions(blankRestrictedTools); List<ListOptionSerialized> restrictedPublicTools = copyListOptions(blankRestrictedTools); boolean shoppingPeriodAdmin = false; boolean directAccess = false; Date shoppingAdminModified = null; String shoppingAdminModifiedBy = null; Date modified = null; String modifiedBy = null; boolean accessAdmin = false; boolean shoppingPeriodRevokeInstructorEditable = false; boolean shoppingPeriodRevokeInstructorPublicOpt = false; boolean allowBecomeUser = false; boolean instructorEdited = false; DefaultMutableTreeNode child = new DelegatedAccessMutableTreeNode(); if(!shoppingPeriodTool && DelegatedAccessConstants.SHOPPING_PERIOD_USER.equals(userId)){ Set<String> perms = getPermsForUserNodes(userId, childNode.id); String[] realmRole = getAccessRealmRole(perms); realm = realmRole[0]; role = realmRole[1]; startDate = getShoppingStartDate(perms); endDate = getShoppingEndDate(perms); restrictedAuthTools = getRestrictedAuthToolSerializedList(perms, restrictedAuthTools); restrictedPublicTools = getRestrictedPublicToolSerializedList(perms, restrictedPublicTools); directAccess = getIsDirectAccess(perms); shoppingAdminModified = getPermDate(perms, DelegatedAccessConstants.NODE_PERM_SHOPPING_ADMIN_MODIFIED); shoppingAdminModifiedBy = getShoppingAdminModifiedBy(perms); modified = getPermDate(perms, DelegatedAccessConstants.NODE_PERM_MODIFIED); modifiedBy = getModifiedBy(perms); accessAdmin = getIsAccessAdmin(perms); shoppingPeriodRevokeInstructorEditable = isShoppingPeriodRevokeInstructorEditable(perms); shoppingPeriodRevokeInstructorPublicOpt = isShoppingPeriodRevokeInstructorPublicOpt(perms); allowBecomeUser = isAllowBecomeUser(perms); instructorEdited = isInstructorEdited(perms); } NodeModel node = new NodeModel(childNode.id, childNode, directAccess, realm, role, ((NodeModel) parentNode.getUserObject()), restrictedAuthTools, restrictedPublicTools, startDate, endDate, false, shoppingPeriodAdmin, modifiedBy, modified, shoppingAdminModified, shoppingAdminModifiedBy, accessAdmin, shoppingPeriodRevokeInstructorEditable, shoppingPeriodRevokeInstructorPublicOpt, allowBecomeUser, instructorEdited); child.setUserObject(node); boolean shoppingAvailable = true; if(shoppingPeriodTool && node.isSiteNode() && !isShoppingPeriodOpenForSite(node.getNodeShoppingPeriodStartDate(), node.getNodeShoppingPeriodEndDate(), node.getNodeAccessRealmRole(), node.getNodeRestrictedAuthTools(), node.getNodeRestrictedPublicTools())){ //make sure this node is available shoppingAvailable = false; } if(shoppingAvailable && (!onlyAccessNodes || node.getNodeAccess())){ parentNode.add(child); added = true; } } return added; }