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


Java TreeItem.setData方法代码示例

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


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

示例1: loadRootsIntoDirectoryTree

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Load the root directories of the file system into the directory tree,
 * priorly removing any entries.
 */
public void loadRootsIntoDirectoryTree() {
	this.directoryTree.removeAll();

    File[] roots = File.listRoots();
    for (int a = 0; a < roots.length; a++) {
		/*
		 * Skip drive A if it is not explicitly wanted - no one needs it nowadays and it slows
		 * initialization down.
		 */
		if (!Options.getInst().hideDrivesAB
				|| (!roots[a].getPath().startsWith("A:") && !roots[a].getPath()
						.startsWith("B:"))) {
			String rootEntry = roots[a].toString();
    		if (rootEntry.endsWith("\\")) rootEntry = rootEntry.substring(0, rootEntry.length() - 1);
    		TreeItem root = new TreeItem(this.directoryTree, 0);
	    	root.setText(rootEntry);
	    	root.setData(roots[a]);
	    	new TreeItem(root, 0);
    	}
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:26,代码来源:FileSelectionComposite.java

示例2: addDirectoriesToTree

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Helper function for building fileTree.
 */
protected void addDirectoriesToTree(TreeItem directoryItem, DirectoryEntry directoryEntry) {
	Iterator files = directoryEntry.getFiles().iterator();
	while (files.hasNext()) {
		final FileEntry entry = (FileEntry) files.next();
		if (entry.isDirectory()) {
			TreeItem item = new TreeItem(directoryItem, SWT.BORDER);
			item.setText(entry.getFilename());
			item.setData(entry);
			addDirectoriesToTree(item, (DirectoryEntry)entry);
		}
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:16,代码来源:DiskExplorerTab.java

示例3: addNodeInTree

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Adds a node in the visual tree. This method is used by the @see fillDomTree method 
 *  
 * @param parent 	the parent (Can be the tree or a parent TreeItem)
 * @param node		the node to be added
 */
public boolean addNodeInTree(Object parent, Node node, IProgressMonitor monitor) {
	TreeItem tItem = (TreeItem) parent;
	String[] values = new String[2];
	tItem.setData(node);
	// calc the node text according to the node type
	switch (node.getNodeType()) {
	case Node.ELEMENT_NODE :
		int dec = 0;
		if (node.hasAttributes()) {// add a fake first node for 'Attributes' item
			tItem.setData("dec", new Integer(dec = 1));
		}
		Node[] childs = XMLUtils.toNodeArray(node.getChildNodes());
		tItem.setData("childs", childs);
		tItem.setItemCount(childs.length + dec);
		
		values[0] = node.getNodeName();
		values[1] = getTextValue(node);
		
		tItem.setText(values);
		tItem.setImage(imageNode);
		break;
	case Node.TEXT_NODE  :
		tItem.setImage(imageText);
		tItem.setText(node.getNodeValue().trim());
		break;
	case Node.ATTRIBUTE_NODE:
		tItem.setImage(imageAttrib);
		String str = node.getNodeName() + "=\"" + node.getNodeValue() + "\"";
		tItem.setText(new String[] {str, str});
		break;
	case Node.ENTITY_NODE:
		tItem.setText("[Entity]");
		break;
	case Node.ENTITY_REFERENCE_NODE :
		tItem.setText("[Entityref]");
		break;
	case Node.PROCESSING_INSTRUCTION_NODE :
		tItem.setText("[Pi]");
		break;
	case Node.COMMENT_NODE :
		tItem.setText("[Comment]");
		break;
	case Node.DOCUMENT_FRAGMENT_NODE :
		tItem.setText("[Docfgmt]");
		break;
	case Node.DOCUMENT_TYPE_NODE :
		tItem.setText("[Doctype]");
		break;
	case Node.NOTATION_NODE :
		tItem.setText("[Notation]");
		break;
	default: break;
	}
	
	return true;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:63,代码来源:TwsDomTree.java


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