本文整理匯總了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);
}
}
}
示例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);
}
}
}
示例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;
}