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


Java MutableTreeNode.getChildCount方法代码示例

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


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

示例1: refresh

import javax.swing.tree.MutableTreeNode; //导入方法依赖的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: removeAllChildren

import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
protected void removeAllChildren(MutableTreeNode parentNode,
			     DefaultTreeModel tree)
   {
Enumeration<?> enm = parentNode.children();
MutableTreeNode[] toRemove =
    new MutableTreeNode[parentNode.getChildCount()];

int i = 0;
while(enm.hasMoreElements()) {
    toRemove[i++] =
	(MutableTreeNode)enm.nextElement();
}
for(i = 0; i < toRemove.length; i++) {
	tree.removeNodeFromParent(toRemove[i]);
	toRemove[i] = null;
}
toRemove = null;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:19,代码来源:UnitedNameTreeModel.java

示例3: findIndexFor

import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
private static int findIndexFor(MutableTreeNode child, MutableTreeNode parent) {
  int childCount = parent.getChildCount();
  if (childCount == 0) {
    return 0;
  }
  if (childCount == 1) {
    return NODE_COMPARATOR.compare(child, parent.getChildAt(0)) <= 0 ? 0 : 1;
  }
  return findIndexFor(child, parent, 0, childCount - 1);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ExternalSystemTasksTreeModel.java

示例4: insertNodeInto

import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
public void insertNodeInto(AbstractODKTreeNode newChild, MutableTreeNode parent, int index)
{
	if(index==-1) index = 0;
	
	log.debug("Inserting new child in parent node at index "+index);
	
	try{
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) newChild;
		
		ODKFieldInterface obj = (ODKFieldInterface) node.getUserObject();
		
		if(obj.getTridasClass() == TridasSample.class && parent!=sampleGroup)
		{
			super.insertNodeInto((MutableTreeNode) newChild, sampleGroup, sampleGroup.getChildCount());
			return;
		}
	} catch (Exception e)
	{
		log.debug("exception caught");
		
	}
	
	if(index<=parent.getChildCount()-1)
	{
		super.insertNodeInto((MutableTreeNode)newChild, parent, index);
	}
	else
	{
		super.insertNodeInto((MutableTreeNode)newChild, parent, parent.getChildCount());
	}
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:32,代码来源:ODKTreeModel.java

示例5: clipboardTreeElementAdded

import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
private void clipboardTreeElementAdded(ClipboardItem item) {
		if (logger.getEffectiveLevel().equals(Level.DEBUG))
			logger.debug("Adding clipboard item " + item.getName());

		DefaultTreeModel cTreeModel = (DefaultTreeModel) AIBenchJTreeManager.this.clipboardTree.getModel();
		MutableTreeNode cRootNode = (MutableTreeNode) cTreeModel.getRoot();
		for (ClipboardItem item2 : Core.getInstance().getClipboard().getRootItems()) {
			if (item2 == item) {
				DefaultMutableTreeNode newNode = this.createClipNode(item, null, false);
				
				if (newNode != null) {
					DefaultMutableTreeNode parentNode = null;
					if (Boolean.parseBoolean(Workbench.CONFIG.getProperty("clipboardtree.organizebyclass", "true"))) {
						parentNode = AIBenchJTreeManager.locateClassNode(AIBenchJTreeManager.this.clipboardTree, item.getUserData().getClass());//classNodes.get(item.getUserData().getClass());
						if (parentNode == null) {
							String name = item.getUserData().getClass().getSimpleName();
							
							Datatype datatypeAnnot = item.getUserData().getClass().getAnnotation(Datatype.class);
							if(datatypeAnnot!= null && !datatypeAnnot.clipboardClassName().equals("")) {
								name = datatypeAnnot.clipboardClassName();
							}
							
							parentNode = new ClassTreeNode(name, item.getUserData().getClass());
//							classNodes.put(item.getUserData().getClass(), classNode);
							
							// Alphabetic order
							int order = 0;
							while (order < cRootNode.getChildCount() && name.compareTo(cRootNode.getChildAt(order).toString()) > 0) {
								order++;
							}
							cTreeModel.insertNodeInto(parentNode, cRootNode, order);
						}
					} else {
						parentNode = (DefaultMutableTreeNode) cTreeModel.getRoot();
					}
					
					if (parentNode != null) {
						cTreeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
						
						clipboardTree.expandPath(new TreePath(newNode.getPath()));
						clipboardTree.scrollPathToVisible(new TreePath(newNode.getPath()));
						clipboardTree.setSelectionPath(new TreePath(newNode.getPath()));
					}
				}
				
				return;
			}
		}
	}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:50,代码来源:AIBenchJTreeManager.java

示例6: moveNode

import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
/**
 * Move a node to another node, used to respond to internal drag and drop
 * events corresponding to re-arrangements of this collection structure.
 * Behaviour depends on the relative depths (in t2reference terms where a
 * leaf node has depth 0) of the source and target nodes
 * <ol>
 * <li>If the target is the same depth as the source then this is
 * interpreted as a request to move the source to become a sibling of the
 * target positioned immediately after it in the target's parent's child
 * list.</li>
 * <li>If the target is a lower depth than the source then the target node
 * is re-written to be the node on the target's path to the root with the
 * same depth as the source and treated as above.</li>
 * <li>If the target is at a higher depth than the source by exactly one
 * then this is interpreted as a request to insert the source node at the
 * start of the target's child list.</li>
 * <li>If the target is at a higher depth by more than one the target node
 * is rewritten to be the first child of the target node. If the target node
 * has no children a new node is created, inserted into the target and set
 * as the target for this method, which is called recursively</li>
 * </ol>
 * This method is called before any nodes are modified, and causes the
 * modifications to take place.
 */
public synchronized void moveNode(MutableTreeNode source,
		MutableTreeNode target) {
	// Check that we're not dragging onto ourselves!
	if (source.equals(target))
		return;
	int targetDepth = getNodeDepth(target);
	int sourceDepth = getNodeDepth(source);
	// Handle drag onto a future sibling
	if (sourceDepth == targetDepth) {
		/*
		 * Move the source from wherever it currently is and add it as a
		 * sibling of the target node at an index one higher.
		 */
		removeNodeFromParent(source);
		// Capture the index of the target in its parent
		int targetIndex = getIndexOfChild(target.getParent(), target);
		/*
		 * Insert the source node into the target's parent at the
		 * appropriate index
		 */
		insertNodeInto(source, (MutableTreeNode) target.getParent(),
				targetIndex + 1);
	}
	// Traverse up to find a potential sibling node
	else if (targetDepth < sourceDepth)
		moveNode(source, (MutableTreeNode) target.getParent());
	// Check for a move to an immediate future parent
	else if (targetDepth == sourceDepth + 1) {
		/*
		 * Insert at index 0 in the target, removing from our old parent
		 * first
		 */
		removeNodeFromParent(source);
		insertNodeInto(source, target, 0);
	}
	/*
	 * Otherwise traverse, picking the child at index 0 every time and
	 * creating a new one if required
	 */
	else if (targetDepth > sourceDepth) {
		// Create a new non-leaf node first if needed
		if (target.getChildCount() == 0)
			insertNodeInto(new DefaultMutableTreeNode(null), target, 0);
		/*
		 * Recursively try to move the source to the target's child list at
		 * position 0
		 */
		moveNode(source, (MutableTreeNode) target.getChildAt(0));
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:75,代码来源:PreRegistrationTreeModel.java


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