List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * //from ww w. j a v a2 s .c o m */ private void delColObj() { if (checkForChanges()) { DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null) { if (node.getUserObject() instanceof Container) { Container cn = (Container) node.getUserObject(); CollectionObject co = cn.getCollectionObject(); if (cn != null) { cn.getCollectionObjects().clear(); co.setContainer(null); model.nodeChanged(node); } } else { CollectionObject co = (CollectionObject) node.getUserObject(); colObjIdHash.remove(co.getId()); model.removeNodeFromParent(node); } } } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * // ww w .ja v a 2 s . c o m */ protected void updateUIControls() { addBtn.setEnabled(false); delBtn.setEnabled(false); if (tree.getSelectionModel().getSelectionPath() != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionModel().getSelectionPath() .getLastPathComponent(); Object nodeObj = node.getUserObject(); //System.out.println(nodeObj.getClass().getSimpleName()); if (nodeObj instanceof FormRow) { addBtn.setEnabled(true); delBtn.setEnabled(true); } else if (nodeObj instanceof FormViewDef) { addBtn.setEnabled(true); delBtn.setEnabled(true); } else if (nodeObj instanceof FormCell) { addBtn.setEnabled(true); delBtn.setEnabled(true); } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param e/*from w w w . j a v a2 s .co m*/ */ private void mousePressedOnTree(final MouseEvent e) { Point pnt = e.getLocationOnScreen(); int i = 0; for (Rectangle r : treeRenderer.getHitRects()) { //System.out.println(pnt+" "+r+" "+r.contains(pnt)); if (r.contains(pnt)) { DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null) { if (node.getUserObject() instanceof Container) { Container cn = (Container) node.getUserObject(); if (cn != null) { if (!isViewMode) // Edit Mode { if (cn.getCollectionObject() != null) { if (i == 0) { editColObj(cn.getCollectionObject()); } else { delColObj(); } } else { if (i == 0) { addColObjToContainer(true, true); } else { addColObjToContainer(false, true); } } } else if (cn.getCollectionObject() != null && i == 0) { viewColObj(); } } } else if (node.getUserObject() instanceof CollectionObject) { if (isViewMode) { if (i == 0) { viewColObj(); } } else { if (i == 0) { editColObj(); } } } } break; } i++; } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param doAddBySearch/* www. j a v a 2s . co m*/ * @param doAssociate */ private void addColObjToContainer(final boolean doAddBySearch, final boolean doAssociate) { if (checkForChanges()) { DefaultMutableTreeNode parentNode = getSelectedTreeNode(); if (parentNode != null) { Container container = (Container) parentNode.getUserObject(); CollectionObject co = doAddBySearch ? (CollectionObject) searchForDataObj(CollectionObject.class) : editColObj(null); if (co != null) { if (doAssociate) { co.setContainer(container); container.getCollectionObjects().add(co); saveObjs(co, container); model.nodeChanged(parentNode); } else { addColObjAsChild(parentNode, co); } } } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * //w w w. jav a 2 s .com */ private void addContainer(final boolean doSearch) { if (checkForChanges()) { DefaultMutableTreeNode parentNode = getSelectedTreeNode(); if (parentNode != null) { Container parentContainer = (Container) parentNode.getUserObject(); Container newContainer = doSearch ? (Container) searchForDataObj(Container.class) : createContainer(parentContainer); if (newContainer != null) { if (doSearch) { // check here to see if they are already parented. newContainer.setParent(parentContainer); parentContainer.getChildren().add(newContainer); saveObjs(newContainer, parentContainer); } DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(); newNode.setUserObject(newContainer); if (newContainer.getId() != null) { containerIdHash.add(newContainer.getId()); } int inx = parentNode.getChildCount(); model.insertNodeInto(newNode, parentNode, inx); model.nodesWereInserted(parentNode, new int[] { inx }); model.nodeChanged(parentNode); model.reload(); tree.restoreTree(); expandToNode(newNode); // invokedLater } } } }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java
/** * This method iterate all the classifications of a form and add * the corresponding branch of the cs tree to the root node * * @param currForm the Form that needs to be attached to the root node * @param currCSMap a Map to find a tree node given a cscsi id, this tree * node is used as a master copy for each protocol to create its own * cs tree//from w ww .j a va 2 s .c o m * @param treeNodeMap a Map used to avoid copy the orginal node more than one * time. For each given Webnode id, this Map returns the corresponding * copy of that node that exist in the copy * @param newNode the form node to be added to the cs tree * @param rootNode the tree node for the branch to attach to * @param idGen the id genator used to get unique id when copy a node from * original tree */ private void copyCSTree(Form currForm, Map currCSMap, Map treeNodeMap, DefaultMutableTreeNode newNode, DefaultMutableTreeNode rootNode, TreeIdGenerator idGen) { //if the cs map does not exist for any reason, simplely add the new to the root if (currCSMap == null) rootNode.add(newNode); else { Iterator csIter = currForm.getClassifications().iterator(); while (csIter.hasNext()) { String cscsiId = ((ClassSchemeItem) csIter.next()).getCsCsiIdseq(); DefaultMutableTreeNode origTreeNode = (DefaultMutableTreeNode) currCSMap.get(cscsiId); WebNode origWebNode = (WebNode) origTreeNode.getUserObject(); DefaultMutableTreeNode treeNodeCopy = (DefaultMutableTreeNode) treeNodeMap.get(origWebNode.getId()); if (treeNodeCopy == null) { treeNodeCopy = new DefaultMutableTreeNode(origWebNode.copy(idGen.getNewId())); treeNodeMap.put(origWebNode.getId(), treeNodeCopy); } treeNodeCopy.add(newNode); DefaultMutableTreeNode pTreeNode = origTreeNode; DefaultMutableTreeNode cTreeNode = treeNodeCopy; //copy this branch of the cs tree all the way until one parent node is //found in the new tree while (pTreeNode.getParent() != null) { DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) pTreeNode.getParent(); WebNode pWebNode = (WebNode) parentTreeNode.getUserObject(); DefaultMutableTreeNode pNodeCopy = (DefaultMutableTreeNode) treeNodeMap.get(pWebNode.getId()); if (pNodeCopy == null) { pNodeCopy = new DefaultMutableTreeNode(pWebNode.copy(idGen.getNewId())); treeNodeMap.put(pWebNode.getId(), pNodeCopy); pNodeCopy.add(cTreeNode); pTreeNode = parentTreeNode; cTreeNode = pNodeCopy; } else { // when one parent node is found in the new tree, attach the copy pNodeCopy.add(cTreeNode); return; } } rootNode.add(cTreeNode); } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param node/*from ww w. ja v a 2s . co m*/ * @param containersToBeDeleted * @param colObjsToBeUpdated */ private void recursePrune(final DefaultMutableTreeNode node, final ArrayList<Container> containersToBeDeleted, final ArrayList<CollectionObject> colObjsToBeUpdated) { if (node.getUserObject() instanceof Container) { Container cn = (Container) node.getUserObject(); if (cn.getId() != null) { containersToBeDeleted.add(cn); containerIdHash.remove(cn.getId()); CollectionObject co = cn.getCollectionObject(); if (co != null) { cn.getCollectionObjects().clear(); co.setContainer(null); colObjsToBeUpdated.add(cn.getCollectionObject()); colObjIdHash.remove(co.getId()); } for (int i = 0; i < node.getChildCount(); i++) { recursePrune((DefaultMutableTreeNode) node.getChildAt(i), containersToBeDeleted, colObjsToBeUpdated); } cn.getChildren().clear(); for (CollectionObject coKid : cn.getCollectionObjectKids()) { coKid.setContainerOwner(null); colObjsToBeUpdated.add(coKid); colObjIdHash.remove(coKid.getId()); } cn.getCollectionObjectKids().clear(); } } else { CollectionObject co = (CollectionObject) node.getUserObject(); co.setContainer(null); co.setContainerOwner(null); colObjsToBeUpdated.add(co); colObjIdHash.remove(co.getId()); } node.setUserObject(null); model.removeNodeFromParent(node); }
From source file:it.isislab.dmason.tools.batch.BatchWizard.java
private int getTotTests() { int tot = 1;/* ww w . j a va2 s .c om*/ for (int i = 0; i < simParams.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) simParams.getChildAt(i); if (child.getUserObject() instanceof ParamFixed) tot *= 1; if (child.getUserObject() instanceof ParamRange) { ParamRange p = ((ParamRange) child.getUserObject()); tot *= (((p.getEnd().contains(".") ? Double.parseDouble(p.getEnd()) : Integer.parseInt(p.getEnd())) - (p.getStart().contains(".") ? Double.parseDouble(p.getStart()) : Integer.parseInt(p.getStart()))) / (p.getIncrement().contains(".") ? Double.parseDouble(p.getIncrement()) : Integer.parseInt(p.getIncrement()))) + 1; } if (child.getUserObject() instanceof ParamDistribution) { ParamDistribution p = ((ParamDistribution) child.getUserObject()); tot *= p.getNumberOfValues(); } if (child.getUserObject() instanceof ParamList) { ParamList p = ((ParamList) child.getUserObject()); tot *= p.getValues().size(); } } for (int i = 0; i < generalParams.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) generalParams.getChildAt(i); if (child.getUserObject() instanceof ParamFixed) tot *= 1; if (child.getUserObject() instanceof ParamRange) { ParamRange p = ((ParamRange) child.getUserObject()); tot *= (((p.getEnd().contains(".") ? Double.parseDouble(p.getEnd()) : Integer.parseInt(p.getEnd())) - (p.getStart().contains(".") ? Double.parseDouble(p.getStart()) : Integer.parseInt(p.getStart()))) / (p.getIncrement().contains(".") ? Double.parseDouble(p.getIncrement()) : Integer.parseInt(p.getIncrement()))) + 1; } if (child.getUserObject() instanceof ParamDistribution) { ParamDistribution p = ((ParamDistribution) child.getUserObject()); tot *= p.getNumberOfValues(); } if (child.getUserObject() instanceof ParamList) { ParamList p = ((ParamList) child.getUserObject()); tot *= p.getValues().size(); } } return tot; }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
private int calculateNumberOfGenes() { int count = 0; final DefaultMutableTreeNode root = (DefaultMutableTreeNode) chromosomeTree.getRoot(); @SuppressWarnings("rawtypes") final Enumeration nodes = root.breadthFirstEnumeration(); nodes.nextElement();// w ww. ja v a2 s. c om while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterOrGene userObj = (ParameterOrGene) node.getUserObject(); if (userObj.isGene()) count++; } return count; }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
private List<GeneInfo> getSelectedGenes() { if (genes == null) { genes = new ArrayList<GeneInfo>(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) chromosomeTree.getRoot(); @SuppressWarnings("rawtypes") final Enumeration nodes = root.preorderEnumeration(); nodes.nextElement();/*w w w. j av a 2 s . c om*/ while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterOrGene userObj = (ParameterOrGene) node.getUserObject(); if (userObj.isGene()) { convertGeneName(userObj); genes.add(userObj.getGeneInfo()); } } } return genes; }