List of usage examples for javax.swing.tree DefaultMutableTreeNode children
Vector children
To view the source code for javax.swing.tree DefaultMutableTreeNode children.
Click Source Link
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private static int calculateNumberOfRuns(DefaultMutableTreeNode combinationRoot) { int result = 1; @SuppressWarnings("rawtypes") final Enumeration combinationElements = combinationRoot.children(); while (combinationElements.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) combinationElements.nextElement(); final ParameterInfo info = ((ParameterInATree) node.getUserObject()).info; if (info instanceof SubmodelInfo) result *= calculateNumberOfRuns(node); else/*w w w . j av a 2 s .c om*/ result *= info.getMultiplicity(); } return result; }
From source file:lcmc.gui.ClusterBrowser.java
/** Checks all fields in the application. */ void checkAccessOfEverything() { servicesInfo.checkResourceFieldsChanged(null, servicesInfo.getParametersFromXML()); servicesInfo.updateAdvancedPanels(); rscDefaultsInfo.updateAdvancedPanels(); Tools.getGUIData().updateGlobalItems(); for (final ServiceInfo si : getExistingServiceList(null)) { si.checkResourceFieldsChanged(null, si.getParametersFromXML()); si.updateAdvancedPanels();//from www .ja va 2 s. c o m } drbdGraph.getDrbdInfo().checkResourceFieldsChanged(null, drbdGraph.getDrbdInfo().getParametersFromXML()); drbdGraph.getDrbdInfo().updateAdvancedPanels(); for (final DrbdResourceInfo dri : getDrbdResHashValues()) { dri.checkResourceFieldsChanged(null, dri.getParametersFromXML()); dri.updateAdvancedPanels(); dri.updateAllVolumes(); } if (vmsNode != null) { @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> e = vmsNode.children(); while (e.hasMoreElements()) { final DefaultMutableTreeNode node = e.nextElement(); final VMSVirtualDomainInfo vmsvdi = (VMSVirtualDomainInfo) node.getUserObject(); vmsvdi.checkResourceFieldsChanged(null, vmsvdi.getParametersFromXML()); vmsvdi.updateAdvancedPanels(); @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> ce = node.children(); while (ce.hasMoreElements()) { final DefaultMutableTreeNode cnode = ce.nextElement(); final VMSHardwareInfo vmshi = (VMSHardwareInfo) cnode.getUserObject(); vmshi.checkResourceFieldsChanged(null, vmshi.getParametersFromXML()); vmshi.updateAdvancedPanels(); } } } for (final HbConnectionInfo hbci : crmGraph.getAllHbConnections()) { hbci.checkResourceFieldsChanged(null, hbci.getParametersFromXML()); hbci.updateAdvancedPanels(); } for (final Host clusterHost : getClusterHosts()) { final HostBrowser hostBrowser = clusterHost.getBrowser(); hostBrowser.getHostInfo().updateAdvancedPanels(); } }
From source file:com.pironet.tda.TDA.java
/** * navigate to monitor/*from w ww . j a v a 2 s.com*/ * * @param monitorLink the monitor link to navigate to */ private void navigateToMonitor(String monitorLink) { String monitor = monitorLink.substring(monitorLink.lastIndexOf('/') + 1); // find monitor node for this thread info DefaultMutableTreeNode dumpNode; if (monitorLink.indexOf("Dump No.") > 0) { dumpNode = getDumpRootNode( monitorLink.substring(monitorLink.indexOf('/') + 1, monitorLink.lastIndexOf('/')), (DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); } else { dumpNode = getDumpRootNode((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); } final Enumeration children = dumpNode.children(); DefaultMutableTreeNode monitorNode = null; DefaultMutableTreeNode monitorWithoutLocksNode = null; while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); if (child.getUserObject() instanceof TreeCategory) { if (((TreeCategory) child.getUserObject()).getName().startsWith("Monitors (")) { monitorNode = child; } else if (((TreeCategory) child.getUserObject()).getName().startsWith("Monitors without")) { monitorWithoutLocksNode = child; } } } // highlight chosen monitor JTree searchTree = (JTree) ((TreeCategory) monitorNode.getUserObject()).getCatComponent(this); TreePath searchPath = searchTree.getNextMatch(monitor, 0, Position.Bias.Forward); if ((searchPath == null) && (monitorWithoutLocksNode != null)) { searchTree = (JTree) ((TreeCategory) monitorWithoutLocksNode.getUserObject()).getCatComponent(this); searchPath = searchTree.getNextMatch(monitor, 0, Position.Bias.Forward); monitorNode = monitorWithoutLocksNode; } if (searchPath != null) { TreePath monitorPath = new TreePath(monitorNode.getPath()); tree.setSelectionPath(monitorPath); tree.scrollPathToVisible(monitorPath); displayCategory(monitorNode.getUserObject()); TreePath threadInMonitor = searchPath .pathByAddingChild(((DefaultMutableTreeNode) searchPath.getLastPathComponent()).getLastChild()); searchTree.setSelectionPath(threadInMonitor); searchTree.scrollPathToVisible(searchPath); searchTree.setSelectionPath(searchPath); } }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
private void saveParameterOrGene(final DefaultMutableTreeNode node, final ObjectFactory factory, final Object parent) { final ParameterOrGene userObj = (ParameterOrGene) node.getUserObject(); final ParameterInfo info = userObj.getInfo(); if (userObj.isGene()) { final GeneInfo geneInfo = userObj.getGeneInfo(); final eu.crisis_economics.abm.dashboard.generated.Gene gene = factory.createGene(); gene.setName(info.getName());/*from w ww . ja va 2 s . c o m*/ gene.setGeneType(geneInfo.getValueType()); if (GeneInfo.INTERVAL.equals(geneInfo.getValueType())) { gene.setInteger(geneInfo.isIntegerVals()); gene.setMin(geneInfo.isIntegerVals() ? new BigDecimal(geneInfo.getMinValue().longValue()) : new BigDecimal(geneInfo.getMinValue().doubleValue())); gene.setMax(geneInfo.isIntegerVals() ? new BigDecimal(geneInfo.getMaxValue().longValue()) : new BigDecimal(geneInfo.getMaxValue().doubleValue())); } else { final List<String> geneValues = gene.getGeneValueList(); for (final Object value : geneInfo.getValueRange()) geneValues.add(String.valueOf(value)); } if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getGeneList().add(gene); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getGeneList().add(gene); } } else if (info instanceof SubmodelInfo) { final SubmodelInfo sInfo = (SubmodelInfo) info; final SubmodelParameter parameter = factory.createSubmodelParameter(); parameter.setName(info.getName()); parameter.setType(sInfo.getActualType() == null ? "null" : sInfo.getActualType().getName()); if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getSubmodelParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getSubmodelParameterList().add(parameter); } if (node.getChildCount() > 0) { @SuppressWarnings("rawtypes") final Enumeration childNodes = node.children(); while (childNodes.hasMoreElements()) { final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childNodes.nextElement(); saveParameterOrGene(childNode, factory, parameter); } } } else { final Parameter parameter = factory.createParameter(); parameter.setName(info.getName()); parameter.setParameterType(ParameterType.CONSTANT); parameter.getContent().add(info.getValue().toString()); if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getParameterList().add(parameter); } } }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void savePSParameter(final DefaultMutableTreeNode node, final ObjectFactory factory, final Object parent, final int position) { final ParameterInATree userObj = (ParameterInATree) node.getUserObject(); final ParameterInfo info = userObj.info; if (info instanceof SubmodelInfo) { final SubmodelInfo sInfo = (SubmodelInfo) info; final SubmodelParameter parameter = factory.createSubmodelParameter(); parameter.setName(info.getName()); parameter.setType(sInfo.getActualType() == null ? "null" : sInfo.getActualType().getName()); parameter.setPosition(BigInteger.valueOf(position)); if (parent instanceof Combination) { final Combination combination = (Combination) parent; combination.getSubmodelParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getSubmodelParameterList().add(parameter); }//w w w. ja v a2 s . c om if (node.getChildCount() > 0) { @SuppressWarnings("rawtypes") final Enumeration childNodes = node.children(); int childPosition = 1; while (childNodes.hasMoreElements()) { final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childNodes.nextElement(); savePSParameter(childNode, factory, parameter, childPosition++); } } } else { final Parameter parameter = factory.createParameter(); parameter.setName(info.getName()); parameter.setPosition(BigInteger.valueOf(position)); switch (info.getDefinitionType()) { case ParameterInfo.CONST_DEF: parameter.setParameterType(ParameterType.CONSTANT); parameter.getContent().add(info.getValue().toString()); break; case ParameterInfo.LIST_DEF: parameter.setParameterType(ParameterType.LIST); savePSListParameter(info, parameter, factory); break; case ParameterInfo.INCR_DEF: parameter.setParameterType(ParameterType.INCREMENT); savePSIncrementParameter(info, parameter, factory); break; } if (parent instanceof Combination) { final Combination combination = (Combination) parent; combination.getParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getParameterList().add(parameter); } } }
From source file:lcmc.gui.resources.ServiceInfo.java
/** * Returns info object of all block devices on all hosts that have the * same names and other attributes./*from w w w . j a v a 2 s . c om*/ */ Info[] getCommonBlockDevInfos(final Info defaultValue, final String serviceName) { final List<Info> list = new ArrayList<Info>(); /* drbd resources */ @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> drbdResources = getBrowser().getDrbdNode().children(); if (defaultValue != null) { list.add(defaultValue); } while (drbdResources.hasMoreElements()) { final DefaultMutableTreeNode n = drbdResources.nextElement(); final DrbdResourceInfo drbdRes = (DrbdResourceInfo) n.getUserObject(); final DefaultMutableTreeNode drbdResNode = drbdRes.getNode(); if (drbdResNode != null) { @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> drbdVolumes = drbdResNode.children(); while (drbdVolumes.hasMoreElements()) { final DefaultMutableTreeNode vn = drbdVolumes.nextElement(); final CommonDeviceInterface drbdVol = (CommonDeviceInterface) vn.getUserObject(); list.add((Info) drbdVol); } } } /* block devices that are the same on all hosts */ @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> wids = getBrowser().getCommonBlockDevicesNode().children(); while (wids.hasMoreElements()) { final DefaultMutableTreeNode n = wids.nextElement(); final CommonDeviceInterface wid = (CommonDeviceInterface) n.getUserObject(); list.add((Info) wid); } return list.toArray(new Info[list.size()]); }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Removes the service without confirmation dialog. */ protected void removeMyselfNoConfirm(final Host dcHost, final boolean testOnly) { if (!testOnly) { if (!getService().isNew()) { setUpdated(true);/*from w w w . j a v a2 s. com*/ } getService().setRemoved(true); cleanup(); } final CloneInfo ci = getCloneInfo(); if (ci != null) { ci.removeMyselfNoConfirm(dcHost, testOnly); setCloneInfo(null); } final GroupInfo gi = groupInfo; if (getService().isNew() && gi == null) { if (!testOnly) { getService().setNew(false); getBrowser().getCRMGraph().killRemovedVertices(); } } else { final ClusterStatus cs = getBrowser().getClusterStatus(); if (gi == null) { removeConstraints(dcHost, testOnly); } if (!getResourceAgent().isGroup() && !getResourceAgent().isClone()) { String groupId = null; /* for pacemaker */ if (gi != null) { /* get group id only if there is only one resource in a * group. */ if (getService().isNew()) { if (!testOnly) { super.removeMyself(false); } } else { final String group = gi.getHeartbeatId(testOnly); final DefaultMutableTreeNode giNode = gi.getNode(); if (giNode != null) { @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> e = giNode.children(); while (e.hasMoreElements()) { final DefaultMutableTreeNode n = e.nextElement(); final ServiceInfo child = (ServiceInfo) n.getUserObject(); child.getService().setModified(true); child.getService().doneModifying(); } } if (cs.getGroupResources(group, testOnly).size() == 1) { if (!testOnly) { gi.getService().setRemoved(true); } gi.removeMyselfNoConfirmFromChild(dcHost, testOnly); groupId = group; gi.getService().doneRemoving(); } } gi.resetPopup(); } if (!getService().isNew()) { String cloneId = null; boolean master = false; if (ci != null) { cloneId = ci.getHeartbeatId(testOnly); master = ci.getService().isMaster(); } final boolean ret = CRM.removeResource(dcHost, getHeartbeatId(testOnly), groupId, cloneId, master, testOnly); cleanupResource(dcHost, testOnly); setUpdated(false); /* must be here, is not a clone anymore*/ if (!testOnly && !ret) { Tools.progressIndicatorFailed(dcHost.getName(), "removing failed"); } } } } if (!testOnly) { getBrowser().removeFromServiceInfoHash(this); infoPanel = null; getService().doneRemoving(); } }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Puts a resource up in a group. */ void upResource(final Host dcHost, final boolean testOnly) { final GroupInfo gi = groupInfo; final DefaultMutableTreeNode giNode = gi.getNode(); if (giNode == null) { return;/* www . j a va 2 s . co m*/ } final DefaultMutableTreeNode node = getNode(); if (node == null) { return; } final int index = giNode.getIndex(node); if (index > 0) { @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> e = giNode.children(); final List<String> newOrder = new ArrayList<String>(); while (e.hasMoreElements()) { final DefaultMutableTreeNode n = e.nextElement(); final ServiceInfo child = (ServiceInfo) n.getUserObject(); newOrder.add(child.getHeartbeatId(testOnly)); } final String el = newOrder.remove(index); newOrder.add(index - 1, el); if (!testOnly) { setUpdated(true); } gi.applyWhole(dcHost, false, newOrder, testOnly); } }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Puts a resource down in a group. */ void downResource(final Host dcHost, final boolean testOnly) { final GroupInfo gi = groupInfo; final DefaultMutableTreeNode giNode = gi.getNode(); if (giNode == null) { return;//from w ww . jav a2 s. co m } final DefaultMutableTreeNode node = getNode(); if (node == null) { return; } final int index = giNode.getIndex(node); if (index < giNode.getChildCount() - 1) { @SuppressWarnings("unchecked") final Enumeration<DefaultMutableTreeNode> e = giNode.children(); final List<String> newOrder = new ArrayList<String>(); while (e.hasMoreElements()) { final DefaultMutableTreeNode n = e.nextElement(); final ServiceInfo child = (ServiceInfo) n.getUserObject(); newOrder.add(child.getHeartbeatId(testOnly)); } final String el = newOrder.remove(index); newOrder.add(index + 1, el); if (!testOnly) { setUpdated(true); } gi.applyWhole(dcHost, false, newOrder, testOnly); } }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void saveSubTree(@SuppressWarnings("rawtypes") final Enumeration children, final List<Parameter> parameterList, final List<SubmodelParameter> submodelParameterList, final Set<ParameterInfo> invalids) throws IOException { final ObjectFactory factory = new ObjectFactory(); while (children.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement(); @SuppressWarnings("unchecked") final Pair<ParameterInfo, JComponent> userData = (Pair<ParameterInfo, JComponent>) node.getUserObject(); final ParameterInfo parameterInfo = userData.getFirst(); final JComponent valueContainer = userData.getSecond(); Parameter parameter = null; SubmodelParameter submodelParameter = null; if (parameterInfo instanceof ISubmodelGUIInfo) { final ISubmodelGUIInfo sgi = (ISubmodelGUIInfo) parameterInfo; if (sgi.getParent() != null) { final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); @SuppressWarnings("unchecked") final Pair<ParameterInfo, JComponent> parentUserData = (Pair<ParameterInfo, JComponent>) parentNode .getUserObject(); final SubmodelInfo parentParameterInfo = (SubmodelInfo) parentUserData.getFirst(); if (invalids.contains(parentParameterInfo) || !classEquals(parentParameterInfo.getActualType(), sgi.getParentValue())) { invalids.add(parameterInfo); continue; }// w w w . java 2 s . co m } } if (parameterInfo instanceof SubmodelInfo) { submodelParameter = factory.createSubmodelParameter(); submodelParameter.setName(parameterInfo.getName()); } else { parameter = factory.createParameter(); parameter.setName(parameterInfo.getName()); } if (parameterInfo.isBoolean()) { final JCheckBox checkBox = (JCheckBox) valueContainer; parameter.getContent().add(String.valueOf(checkBox.isSelected())); } else if (parameterInfo.isEnum()) { final JComboBox comboBox = (JComboBox) valueContainer; parameter.getContent().add(String.valueOf(comboBox.getSelectedItem())); } else if (parameterInfo instanceof MasonChooserParameterInfo) { final JComboBox comboBox = (JComboBox) valueContainer; parameter.getContent().add(String.valueOf(comboBox.getSelectedIndex())); } else if (parameterInfo instanceof SubmodelInfo) { final JComboBox comboBox = (JComboBox) ((JPanel) valueContainer).getComponent(0); final ClassElement selectedElement = (ClassElement) comboBox.getSelectedItem(); if (selectedElement.clazz == null) throw new IOException("No type is selected for parameter " + parameterInfo.getName().replaceAll("([A-Z])", " $1") + "."); submodelParameter.setType(selectedElement.clazz.getName()); saveSubTree(node.children(), submodelParameter.getParameterList(), submodelParameter.getSubmodelParameterList(), invalids); } else if (parameterInfo.isFile()) { final JTextField textField = (JTextField) valueContainer.getComponent(0); parameter.getContent().add(textField.getToolTipText()); } else if (parameterInfo instanceof MasonIntervalParameterInfo) { final JTextField textField = (JTextField) valueContainer.getComponent(0); parameter.getContent().add(textField.getText().trim()); } else { final JTextField textField = (JTextField) valueContainer; String text = String.valueOf(ParameterInfo.getValue(textField.getText(), parameterInfo.getType())); if ("String".equals(parameterInfo.getType()) && parameterInfo.getValue() == null) text = textField.getText().trim(); parameter.getContent().add(text); } if (parameter != null) parameterList.add(parameter); else if (submodelParameter != null) submodelParameterList.add(submodelParameter); } }