本文整理汇总了Java中org.eclipse.swt.widgets.Tree类的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于org.eclipse.swt.widgets包,在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSelectedPackage
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
private void removeSelectedPackage(SelectionEvent e, TreeViewer treeViewer) {
Tree tree = getTree(e);
if (tree == null) {
return;
}
TreeItem[] selection = tree.getSelection();
if (selection != null && selection.length > 0) {
for (TreeItem item : selection) {
TreeItem parent = item.getParentItem();
if (parent == null) {
removePackage(item);
updatePageComplete(tree);
} else {
alert("请选择要删除的包!");
}
}
} else {
alert("请选择要删除的包!");
}
}
示例2: setSortColumn
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
private void setSortColumn(
TreeColumn column, int colIndex, int direction) {
ViewerComparator sorter = buildColumnSorter(colIndex);
if (SWT.UP == direction) {
sorter = new InverseSorter(sorter);
}
Tree tree = propViewer.getTree();
tree.setSortColumn(column);
tree.setSortDirection(direction);
propViewer.setComparator(sorter);
}
示例3: CustomElementSelectionForm
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* Create the composite.
*/
public CustomElementSelectionForm(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(2, false));
treeViewer = new TreeViewer(this, SWT.BORDER);
Tree tree = getTreeViewer().getTree();
// Set a minimum height to prevent weird dialog dimensions
tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).minSize(0, 200).create());
elementLabel = new Label(this, SWT.NONE);
elementLabel.setLayoutData(GridDataFactory.swtDefaults().create());
elementLabel.setText("New Label");
elementInput = new SuffixText(this, SWT.BORDER);// new Text(this, SWT.BORDER);
elementInput.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
}
示例4: createViewer
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
@Override
protected TreeViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout,
final int style) {
final TreeViewer viewer = new TreeViewer(parent, virual ? (style | VIRTUAL) : style);
final Tree tree = viewer.getTree();
tree.setLinesVisible(linesVisible);
tree.setHeaderVisible(headerVisible);
int columnIndex = 0;
for (final String columnLabel : columnLabels) {
final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, NONE);
final TreeColumn column = viewerColumn.getColumn();
columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
column.setText(columnLabel);
column.setMoveable(moveable);
columnIndex++;
}
return viewer;
}
示例5: shouldCreateToolTip
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
@Override
protected boolean shouldCreateToolTip(final Event e) {
this.lastDescriptor = null;
if (e.widget instanceof Tree) {
final Tree tree = (Tree) e.widget;
final TreeItem item = tree.getItem(new Point(e.x, e.y));
if (null != item && item.getData() instanceof ResultNode) {
final ResultNode node = (ResultNode) item.getData();
if (node.getElement() instanceof TestCase) {
final URI uri = ((TestCase) node.getElement()).getURI();
if (null != uri) {
final StyledTextDescriptor descriptor = getDescriptor(uri);
if (null != descriptor) {
this.lastDescriptor = descriptor;
}
}
}
}
}
return null != this.lastDescriptor;
}
示例6: createColumns
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
protected void createColumns ( final Tree tree )
{
final TreeColumn typeFilterColumn = new TreeColumn ( tree, SWT.NONE );
typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
typeFilterColumn.setResizable ( true );
typeFilterColumn.setWidth ( 200 );
final TreeColumn idFilterColumn = new TreeColumn ( tree, SWT.NONE );
idFilterColumn.setText ( getString ( "_UI_IdFilterColumn_label" ) ); //$NON-NLS-1$
idFilterColumn.setResizable ( true );
idFilterColumn.setWidth ( 200 );
final TreeColumn actionFilterColumn = new TreeColumn ( tree, SWT.NONE );
actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
actionFilterColumn.setResizable ( true );
actionFilterColumn.setWidth ( 200 );
}
示例7: createHandler
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* Creates and returns a new IGazeHandler object from the specified object
* and partRef, or returns null if no handler object is defined for that object.
*/
public static IGazeHandler createHandler(Object target,
IWorkbenchPartReference partRef) {
// create gaze handler for a StyledText widget within an EditorPart
if (target instanceof StyledText &&
partRef instanceof IEditorReference) {
return new StyledTextGazeHandler(target); //can go back to using partRef
} else if (target instanceof Browser) {
//create gaze handler for a Browser Stack overflow and Bug Report widget
//cannot get associated partRef
return new BrowserGazeHandler(target);
} else if (target instanceof Tree &&
partRef instanceof IViewReference &&
partRef.getTitle().equals("Project Explorer")) {
//create gaze handler for a Project Explorer Tree
return new ProjectExplorerGazeHandler(target, partRef);
}
return null;
}
示例8: computeAndDisplayStats
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
protected void computeAndDisplayStats(AvroSchemaEditor editor) {
SchemaViewer masterViewer = editor.getContentPart().getSchemaViewer(AvroContext.Kind.MASTER);
TreeViewer treeViewer = masterViewer.getTreeViewer();
AvroNode inputNode = (AvroNode) treeViewer.getInput();
NodeType inputType = inputNode.getType();
String name = AttributeUtil.getNameFromAttribute(inputNode);
NodeStats stats = new NodeStats("Compute stats of " + inputType.toString().toLowerCase()
+ " " + name + " from editor " + editor.getName());
stats.start();
Tree tree = treeViewer.getTree();
TreeItem[] items = tree.getItems();
for (TreeItem item : items) {
visitTreeItem(item, stats);
}
stats.finish();
AvroSchemaLogger.logStats(stats, false);
}
示例9: reloadViewer
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
@Override
public void reloadViewer() {
final Tree tree = _tourViewer.getTree();
tree.setRedraw(false);
{
final Object[] expandedElements = _tourViewer.getExpandedElements();
final ISelection selection = _tourViewer.getSelection();
_tourViewer.setInput(_rootItem = new TVICatalogRootItem(this));
_tourViewer.setExpandedElements(expandedElements);
_tourViewer.setSelection(selection);
}
tree.setRedraw(true);
}
示例10: constrainShellSize
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
@Override
protected void constrainShellSize() {
super.constrainShellSize();
if (Util.isCocoa()) {
final Tree tree = getTreeViewer().getTree();
final FontDescriptor treeFontDescriptor = FontDescriptor.createFrom(JFaceResources.getBannerFont()).setStyle(SWT.NORMAL);
final Font treeFont = treeFontDescriptor.createFont(tree.getDisplay());
updateTreeFont(treeFont);
tree.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
treeFontDescriptor.destroyFont(treeFont);
}
});
}
}
示例11: copyTree
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
*
* @param header ヘッダー
* @param tree ツリー
*/
public static void copyTree(String[] header, Tree tree) {
TreeItem[] treeItems = tree.getSelection();
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.join(header, "\t"));
sb.append("\r\n");
for (TreeItem column : treeItems) {
String[] columns = new String[header.length];
for (int i = 0; i < header.length; i++) {
columns[i] = column.getText(i);
}
sb.append(StringUtils.join(columns, "\t"));
sb.append("\r\n");
}
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
示例12: createTreeViewer
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* Creates tree viewer to manage content
*
* @param parent
* parent control
*/
private void createTreeViewer(Composite parent) {
int style = SWT.H_SCROLL | SWT.V_SCROLL;
// Create the tree
Tree widget = new Tree(parent, style);
// Configure the layout
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = widget.getItemHeight() * 12;
widget.setLayoutData(data);
treeViewer = new TreeViewer(widget);
namePatternFilter = new QuickOutlineNamePatternFilter();
treeViewer.addFilter(namePatternFilter);
treeContentProvider = getContentProvider();
treeViewer.setContentProvider(treeContentProvider);
treeLabelProvider = getLabelProvider();
treeViewer.setLabelProvider(treeLabelProvider);
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.setUseHashlookup(true);
treeViewer.setInput(getInitialInput());
}
示例13: createObjectsNavigator
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
private void createObjectsNavigator(Composite parent) {
objectsNavigator = new TreeViewer(parent, SWT.BORDER);
Tree tree = objectsNavigator.getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
objectsNavigator
.setContentProvider(new ObjectsNavigatorContentProvider());
objectsNavigator.setLabelProvider(new ObjectsNavigatorLabelProvider());
objectsNavigator
.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
Object selItem = ((IStructuredSelection) event
.getSelection()).getFirstElement();
if (selItem instanceof ObjectCategoryItem) {
updateDetailsPanel((ObjectCategoryItem) selItem);
}
}
});
}
示例14: getExpandTreePaths
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* getExpandTreePaths
*
* @param tree
* @param selectedItem
* @return TreePath[]
*/
public static TreePath[] getExpandTreePaths(Tree tree, TreeItem selectedItem) {
ArrayList<Object> items = new ArrayList<Object>();
internalCollectTreeItems(items, tree);
ArrayList<Object> result = new ArrayList<Object>();
for (Iterator<Object> it = items.iterator(); it.hasNext();) {
Item item = (Item) it.next();
// if (item == selectedItem) {
TreePath treePath = getTreePathFromItem(item);
if (treePath != null) {
result.add(treePath);
}
// }
}
return (TreePath[]) result.toArray(new TreePath[items.size()]);
}
示例15: findObjectAtExcluding
import org.eclipse.swt.widgets.Tree; //导入依赖的package包/类
/**
* @see org.eclipse.gef.EditPartViewer#findObjectAtExcluding(Point, Collection, EditPartViewer.Conditional)
*/
@Override
public EditPart findObjectAtExcluding(Point pt, Collection exclude, Conditional condition) {
if (getControl() == null)
return null;
final Tree tree = getTreeControl();
Rectangle area = tree.getClientArea();
if (pt.x < area.x || pt.y < area.y || pt.x >= area.x + area.width || pt.y >= area.y + area.height)
return null;
EditPart result = null;
TreeItem tie = tree.getItem(new org.eclipse.swt.graphics.Point(pt.x, pt.y));
if (tie != null) {
result = (EditPart) tie.getData();
} else if (tree.getData() instanceof EditPart) {
result = (EditPart) tree.getData();
}
while (result != null) {
if ((condition == null || condition.evaluate(result)) && !exclude.contains(result))
return result;
result = result.getParent();
}
return null;
}