当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTreeModel.getRoot方法代码示例

本文整理汇总了Java中javax.swing.tree.DefaultTreeModel.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeModel.getRoot方法的具体用法?Java DefaultTreeModel.getRoot怎么用?Java DefaultTreeModel.getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.DefaultTreeModel的用法示例。


在下文中一共展示了DefaultTreeModel.getRoot方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refresh

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
private void refresh(DefaultTreeModel m,
                     ServerStatus.ModuleSummary[] modules) {
  final MutableTreeNode root = (MutableTreeNode) m.getRoot();
  totalPlayers = 0;

  while (root.getChildCount() > 0) {
    m.removeNodeFromParent((MutableTreeNode) root.getChildAt(0));
  }

  if (modules.length == 0) {
    final DefaultMutableTreeNode n = new DefaultMutableTreeNode(
      Resources.getString("Chat.no_connections")); //$NON-NLS-1$
    n.setAllowsChildren(false);
  }
  else {
    for (ServerStatus.ModuleSummary s : modules) {
      m.insertNodeInto(createNode(s), root, root.getChildCount());
    }
  }

  // append total number of players on server to root node
  root.setUserObject(
    Resources.getString(Resources.VASSAL) + " (" + totalPlayers + ")");
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:25,代码来源:ServerStatusView.java

示例2: SelecioneByDiagramaSelecionado

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public void SelecioneByDiagramaSelecionado() {
    DefaultTreeModel df = (DefaultTreeModel) tree.getModel();
    if (df.getRoot() instanceof TreeItem) {
        TreeItem root = (TreeItem) df.getRoot();
        TreePath pt = new TreePath(root);
        if (diagrama.getSelecionado() == null || !(diagrama.getSelecionado() instanceof Forma)) {
            return;
        }

        for (int i = 0; i < root.getChildCount(); i++) {
            TreeItem item = (TreeItem) root.getChildAt(i);
            if (item.getId() == diagrama.getSelecionado().getID()) {
                tree.setSelectionPath(pt.pathByAddingChild(item));
                break;
            }
        }
    }
    btnOK.setText("OK");
    btnFechar.setVisible(false);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:21,代码来源:EditorDeTipos.java

示例3: getSourceCode

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
 * Returns source code for the current value.
 * 
 * @return source code for the current value.
 */
@Override
public String getSourceCode() {
    DefaultTreeModel model = (DefaultTreeModel)getValue();
    
    // Nodes
    DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
    StringBuilder buf = new StringBuilder();
    String rootVarName = generateCode(root, null, 0, buf);

    // The model itself
    RADProperty prop = (RADProperty)this.property;
    RADComponent comp = prop.getRADComponent();
    CodeVariable var = comp.getCodeExpression().getVariable();
    String varName = (var == null) ? null : var.getName();
    String setter = prop.getPropertyDescriptor().getWriteMethod().getName();
    if (varName != null) {
        setter = varName + '.' + setter;
    }
    buf.append(setter).append("(new "); // NOI18N
    buf.append(DefaultTreeModel.class.getName()).append('(').append(rootVarName).append("));\n"); // NOI18N

    return buf.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:TreeModelEditor.java

示例4: getCodeValue

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
 * Returns textual representation of the tree model.
 * 
 * @return textual representation of the tree model.
 */
String getCodeValue() {
    Object value = getValue();
    if (value instanceof DefaultTreeModel) {
        DefaultTreeModel model = (DefaultTreeModel)value;
        Object root = model.getRoot();
        if (root instanceof DefaultMutableTreeNode) {
            DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)root;
            Object userObject = rootNode.getUserObject();
            if (userObject instanceof CodeUserObject) {
                CodeUserObject code = (CodeUserObject)userObject;
                return code.code;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TreeModelEditor.java

示例5: init

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public void init() {
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    for (String availableExchangeName : availableExchangeNames) {
        DefaultMutableTreeNode firstChild = new DefaultMutableTreeNode(availableExchangeName);
        Collection<CurrencyPair> currencyPairs = IdeaCurrencyApp.getInstance().getCurrencyPairs(availableExchangeName);
        for (CurrencyPair currencyPair : currencyPairs) {
            CheckedTreeNode secondChild = new CheckedTreeNode(currencyPair.toString());
            boolean selected = isSelected(availableExchangeName, currencyPair);
            secondChild.setChecked(selected);
            firstChild.add(secondChild);
            tree.expandPath(new TreePath(secondChild));
        }
        tree.expandPath(new TreePath(firstChild));
        root.add(firstChild);
    }
    model.reload();
    tree.treeDidChange();
    Util.expandAll(tree, new TreePath(root), true);
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:22,代码来源:IdeaCurrencyConfigUI.java

示例6: apply

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void apply() throws ConfigurationException {
    Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs = Sets.newHashSet();
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    Enumeration rootEnum = root.children();
    while (rootEnum.hasMoreElements()) {
        DefaultMutableTreeNode rootEnumObject = (DefaultMutableTreeNode) rootEnum.nextElement();
        String exchangeName = rootEnumObject.getUserObject().toString();
        Enumeration childEnum = rootEnumObject.children();
        Set<CurrencyPair> currencyPairs = Sets.newHashSet();
        while (childEnum.hasMoreElements()) {
            CheckedTreeNode childEnumObject = (CheckedTreeNode) childEnum.nextElement();
            if (childEnumObject.isChecked()) {
                currencyPairs.add(new CurrencyPair(childEnumObject.getUserObject().toString()));
            }
        }
        SelectedExchangeCurrencyPair selectedExchangeCurrencyPair = new SelectedExchangeCurrencyPair(exchangeName, currencyPairs);
        selectedExchangeCurrencyPairs.add(selectedExchangeCurrencyPair);
    }
    IdeaCurrencyConfig.getInstance().setSelectedExchangeCurrencyPairs(selectedExchangeCurrencyPairs);
    IdeaCurrencyConfig.getInstance().setReloadInterval(reloadIntervalSlider.getValue());
    IdeaCurrencyConfig.getInstance().setActive(activeCheckBox.isSelected());
    isModified = false;
    triggerConfigChange();
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:27,代码来源:IdeaCurrencyConfigUI.java

示例7: updateJTree

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public static JTree updateJTree(JTree tree, TreeArrayList<?> data, ExpandedPaths ep) {
    ArrayList<String> expanded_paths = null;
    TreePath[] paths = null;
    if(ep != null) {
        expanded_paths = ep.getExpandedPaths(tree);
        paths = tree.getSelectionPaths();
    }
    DefaultMutableTreeNode top = getDefaultMutableTreeNodeOfHashMap(data);
    DefaultTreeModel model = new DefaultTreeModel(top);
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    model.reload(root);
    tree.setModel(model);
    if(ep != null) {
        ep.expandPaths(tree, expanded_paths);
        tree.setSelectionPaths(paths);
    }
    return tree;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:19,代码来源:JTreeUtils.java

示例8: setLogModel

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public void setLogModel(Model value) {
	this.logModel = value;

	DefaultTreeModel model = (DefaultTreeModel) getModel();
	CircuitNode curRoot = (CircuitNode) model.getRoot();
	CircuitState state = logModel == null ? null : logModel.getCircuitState();
	if (state == null) {
		if (curRoot != null)
			model.setRoot(null);
		return;
	}
	if (curRoot == null || curRoot.circuitState != state) {
		curRoot = new CircuitNode(null, state, null);
		model.setRoot(curRoot);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:ComponentSelector.java

示例9: getOrCreateNode

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
 * Get or create the tree node for the given class node from the given
 * model.
 *
 * @param model
 *            The default tree model to use.
 * @param classNode
 *            The class node.
 * @return The tree node.
 */
public static ASMTreeNode getOrCreateNode(DefaultTreeModel model, ClassNode classNode) {
	ASMTreeNode root = (ASMTreeNode) model.getRoot();
	ArrayList<String> dirPath = new ArrayList<String>(Arrays.asList(classNode.name.split("/")));
	ASMTreeNode genClass = generateTreePath(root, dirPath, classNode, model);
	if (genClass == null) {
		dirPath = new ArrayList<String>(Arrays.asList(classNode.name.split("/")));
		genClass = getTreePath(root, dirPath);
	}
	return genClass;
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:21,代码来源:Swing.java

示例10: apply

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void apply() {
    List<CodeRoot> roots = new ArrayList<>();
    DefaultTreeModel treeModel = (DefaultTreeModel) templateTree.getModel();
    DefaultMutableTreeNode topNode = (DefaultMutableTreeNode) treeModel.getRoot();
    Enumeration rootEnum = topNode.children();
    // 获取所有root
    while (rootEnum.hasMoreElements()) {
        List<CodeGroup> groups = new ArrayList<>();
        DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) rootEnum.nextElement();
        Enumeration enumeration = rootNode.children();
        // 获取所有组
        while(enumeration.hasMoreElements()){
            List<CodeTemplate> templates = new ArrayList<>();
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
            Enumeration childEnum = node.children();
            // 获取所有模板
            while(childEnum.hasMoreElements()){
                DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childEnum.nextElement();
                CodeTemplate template = (CodeTemplate) childNode.getUserObject();
                if(templateEditor != null){
                    CodeTemplate tmp = templateEditor.getCodeTemplate();
                    if(template.getId().equals(tmp.getId())){
                        template = tmp;
                    }
                }
                templates.add(template);
            }
            CodeGroup group = (CodeGroup) node.getUserObject();
            group.setTemplates(templates);
            groups.add(group);
        }
        CodeRoot root = (CodeRoot) rootNode.getUserObject();
        root.setGroups(groups);
        roots.add(root);
    }
    settingManager.getTemplates().setRoots(roots);
    reset();
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:40,代码来源:TemplatesUI.java

示例11: buildTreeFromString

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
 * Builds a tree from a given forward slash delimited string.
 * 
 * @param model
 *          The tree model
 * @param str
 *          The string to build the tree from
 */
public static void buildTreeFromString(final DefaultTreeModel model, final String str) {
	// Fetch the root node
	GitTreeNode root = (GitTreeNode) model.getRoot();

	// Split the string around the delimiter
	String[] strings = str.split("/");

	// Create a node object to use for traversing down the tree as it
	// is being created
	GitTreeNode node = root;

	// Iterate of the string array
	for (String s : strings) {
		// Look for the index of a node at the current level that
		// has a value equal to the current string
		int index = childIndex(node, s);

		// Index less than 0, this is a new node not currently present on the tree
		if (index < 0) {
			// Add the new node
			GitTreeNode newChild = new GitTreeNode(s);
			node.insert(newChild, node.getChildCount());
			node = newChild;
		}
		// Else, existing node, skip to the next string
		else {
			node = (GitTreeNode) node.getChildAt(index);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:39,代码来源:TreeFormatter.java

示例12: getTreeNodeFromString

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
 * Finds the node in the tree from a given forward slash delimited string
 * path.
 * 
 * @param model
 *          - The tree model
 * @param path
 *          - The string to find the node from
 * @return The node
 */
public static GitTreeNode getTreeNodeFromString(DefaultTreeModel model, String path) {
	GitTreeNode node = (GitTreeNode) model.getRoot();
	if (node != null) {
	  String[] strings = path.split("/");
	  for (String s : strings) {
	    int index = childIndex(node, s);
	    if (index != -1) {
	      node = (GitTreeNode) node.getChildAt(index);
	    }
	  }
	}
	return node;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:24,代码来源:TreeFormatter.java

示例13: DoComandoExterno

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void DoComandoExterno(Controler.menuComandos c) {
    if (c == Controler.menuComandos.cmdPrint) {
        fmImpressao fm = controladorImpressao;
        fm.rdMostarAI.setSelected(mostarAreaImpressao);
        fm.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        fm.setLocationRelativeTo(this);
        fm.setDiagrama(Manager.diagramaAtual);
        fm.setVisible(true);
        Point res = fm.getTamanhoAreaImpressao();
        mostarAreaImpressao = fm.rdMostarAI.isSelected();
        Manager.setMostrarAreaImpressao(mostarAreaImpressao, res.x, res.y);
    }
    if (c == menuComandos.cmdTreeNavegador) {
        TreeItensDiagrama.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        TreeItensDiagrama.setModel(new DefaultTreeModel(Manager.diagramaAtual.getTreeNavegacao()));
        if (formPartes != null && formPartes.isVisible()) {
            formPartes.Popule(Manager.diagramaAtual.getTipo());
        }
    }
    if ((TabInspector.getSelectedIndex() == 1) && (c == menuComandos.cmdTreeNavegador || c == menuComandos.cmdTreeSelect)) {
        DefaultTreeModel df = (DefaultTreeModel) TreeItensDiagrama.getModel();
        if (df.getRoot() instanceof TreeItem) {
            TreeItem root = (TreeItem) df.getRoot();
            TreePath pt = new TreePath(root);
            if (Manager.diagramaAtual.getSelecionado() == null || !(Manager.diagramaAtual.getSelecionado() instanceof Forma)) {
                noTree = true;
                TreeItensDiagrama.setSelectionPath(pt);
                noTree = false;
            } else {
                boolean done = false;
                for (int i = 0; i < root.getChildCount(); i++) {
                    TreeItem item = (TreeItem) root.getChildAt(i);
                    if (item.getId() == Manager.diagramaAtual.getSelecionado().getID()) {
                        noTree = true;
                        TreeItensDiagrama.setSelectionPath(pt.pathByAddingChild(item));
                        noTree = false;
                        done = true;
                        break;
                    }
                }
                if (!done) {
                    noTree = true;
                    TreeItensDiagrama.setSelectionPath(pt);
                    noTree = false;
                }
            }
        }
    }
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:51,代码来源:FramePrincipal.java

示例14: initialize

import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/** Initialize. */
private void initialize(){
	
	this.rowCounter = 0;
	this.getEditableRowsVector().removeAllElements();
	
	DefaultTreeModel objectTree = this.dynForm.getObjectTree();
	DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) objectTree.getRoot();
	
	Vector<Object> rows = this.getChildNodeVector(rootNode, true);
	this.addAll(rows);
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:14,代码来源:DynTableDataVector.java


注:本文中的javax.swing.tree.DefaultTreeModel.getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。