本文整理汇总了Java中org.eclipse.jface.viewers.AbstractTreeViewer类的典型用法代码示例。如果您正苦于以下问题:Java AbstractTreeViewer类的具体用法?Java AbstractTreeViewer怎么用?Java AbstractTreeViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractTreeViewer类属于org.eclipse.jface.viewers包,在下文中一共展示了AbstractTreeViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initContextualView
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
private void initContextualView(IEditorPart editor) {
if (editor == null) {
return;
}
IFile file = editor.getEditorInput().getAdapter(IFile.class);
TreeViewer treeViewer = ContextualView.getTreeViewer();
if (treeViewer != null) {
// Finding all markers in given file.
ArrayList<IMarker> allMarkers;
allMarkers = MarkerFactory.findMarkersAsArrayList(file);
if (allMarkers == null) {
return;
}
Iterator<IMarker> iter = allMarkers.iterator();
while (iter.hasNext()) {
IMarker marker = iter.next();
if (MarkUtilities.getLeaderId(marker) == null && MarkUtilities.getGroupId(marker) != null) {
iter.remove();
}
}
if (!treeViewer.getTree().isDisposed()) {
treeViewer.setInput(allMarkers.toArray());
}
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
}
}
示例2: doubleClick
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
@Override
public void doubleClick(DoubleClickEvent event) {
final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null || selection.isEmpty())
return;
final Object sel = selection.getFirstElement();
final ITreeContentProvider provider = (ITreeContentProvider) viewer.getContentProvider();
if (!provider.hasChildren(sel))
return;
if (viewer.getExpandedState(sel))
viewer.collapseToLevel(sel, AbstractTreeViewer.ALL_LEVELS);
else
viewer.expandToLevel(sel, 1);
}
示例3: createTreeViewer
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的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());
}
示例4: isElementVisible
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
boolean hasChildren= ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()).hasChildren(element);
if (fIsDeepFiltering) {
if (!super.isElementVisible(viewer, element))
return false;
// Also apply deep filtering to the other registered filters
ViewerFilter[] filters= ((TreeViewer)viewer).getFilters();
for (int i= 0; i < filters.length; i++) {
if (filters[i] == this)
continue;
if (!filters[i].select(viewer, element, element))
return false;
}
return true;
}
return hasChildren || isLeafMatch(viewer, element);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:FilteredElementTreeSelectionDialog.java
示例5: postRemove
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
private void postRemove(final Object[] elements) {
if (elements.length <= 0)
return;
postRunnable(new Runnable() {
public void run() {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
if (fViewer instanceof AbstractTreeViewer)
((AbstractTreeViewer)fViewer).remove(elements);
else if (fViewer instanceof ListViewer)
((ListViewer)fViewer).remove(elements);
else if (fViewer instanceof TableViewer)
((TableViewer)fViewer).remove(elements);
}
}
});
}
示例6: createControl
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
@Override
public void createControl(Composite parent) {
super.createControl(parent);
viewer = getTreeViewer();
contentProvider = new TreeNodeContentProvider();
viewer.setContentProvider(contentProvider);
labelProvider = new TextUMLLabelProvider();
viewer.setLabelProvider(labelProvider);
// disabled: used to make elements to show sorted by type
// viewer.setComparator(new UIModelObjectViewerComparator());
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
// tracks selections in the outline and reflects them in the editor
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
TreeSelection selection = (TreeSelection) event.getSelection();
if (!selection.isEmpty()) {
TreeNode treeNode = (TreeNode) selection.getFirstElement();
UIModelObject model = (UIModelObject) treeNode.getValue();
selectInEditor(model.getToken());
}
}
});
refresh();
}
示例7: expandNodeAfterCreation
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
private void expandNodeAfterCreation( NotificationEvent ev )
{
if ( ev instanceof ContentEvent
&& ev.getEventType( ) == NotificationEvent.CONTENT_EVENT
&& ( (ContentEvent) ev ).getAction( ) == ContentEvent.ADD )
{
IDesignElement element = ( (ContentEvent) ev ).getContent( );
if ( element != null )
{
final DesignElementHandle handle = element.getHandle( input.getModule( ) );
groupViewer.expandToLevel( handle,
AbstractTreeViewer.ALL_LEVELS );
groupViewer.setSelection( new StructuredSelection( handle ),
true );
refresh( );
}
}
}
示例8: containElement
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
/**
* Tests if the specified element is on the given tree viewer
*
* @param treeViewer
* the tree viewer
* @param element
* the element
*
* @return true if the element is on the tree, or false else.
*/
public static boolean containElement( AbstractTreeViewer treeViewer,
Object element )
{
ITreeContentProvider provider = (ITreeContentProvider) treeViewer.getContentProvider( );
Object input = treeViewer.getInput( );
if ( input instanceof Object[] )
{
Object[] inputs = (Object[]) input;
for ( int i = 0; i < inputs.length; i++ )
{
if ( containElement( inputs[i], provider, element ) )
{
return true;
}
}
return false;
}
return containElement( input, provider, element );
}
示例9: createTreeViewer
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
protected TreeViewer createTreeViewer(Composite parent)
{
int style = SWT.V_SCROLL | SWT.H_SCROLL;
TreeViewer treeViewer = new TreeViewer(parent,
SWT.SINGLE | (style & ~SWT.MULTI));
// Hard-coded filters
treeViewer.addFilter(new NamePatternFilter());
treeViewer.setContentProvider(getContentProvider());
treeViewer.setLabelProvider(new TapestryDecoratingLabelProvider());
treeViewer.setSorter(new NameSorter());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.setInput(this);
Tree tree = treeViewer.getTree();
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = tree.getItemHeight() * 12;
tree.setLayoutData(gd);
return treeViewer;
}
示例10: createControl
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
public void createControl(Composite parent)
{
super.createControl(parent);
TreeViewer treeViewer = getTreeViewer();
treeViewer.setLabelProvider(new ItpLabelProvider());
treeViewer.setContentProvider(new CommonContentProvider());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
public void selectionChanged(SelectionChangedEvent event)
{
if (!(event.getSelection() instanceof IStructuredSelection)) return;
IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if (selection.size() != 1) return;
Object element = selection.getFirstElement();
if (element instanceof SegmentGroup) return;
if (!(element instanceof CommonElement)) return;
CommonElement commonElement = (CommonElement)element;
if (commonElement.getLength() == -1) return;
fEditor.selectAndReveal(commonElement.getOffset(), commonElement.getLength());
}
});
setModel(fEditor.getModel());
}
示例11: createControl
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
public void createControl(Composite parent)
{
super.createControl(parent);
TreeViewer treeViewer = getTreeViewer();
treeViewer.setLabelProvider(new DefLabelProvider());
treeViewer.setContentProvider(new CommonContentProvider());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
public void selectionChanged(SelectionChangedEvent event)
{
if (!(event.getSelection() instanceof IStructuredSelection)) return;
IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if (selection.size() != 1) return;
Object element = selection.getFirstElement();
if (element instanceof SegmentGroup) return;
if (!(element instanceof CommonElement)) return;
CommonElement cElement = (CommonElement)element;
fEditor.selectAndReveal(cElement.getOffset(), cElement.getLength());
}
});
setModel(fEditor.getModel());
}
示例12: KeyTreeViewer
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
public KeyTreeViewer ( final Composite parent )
{
this.resourceManager = new LocalResourceManager ( JFaceResources.getResources ( parent.getDisplay () ), parent );
this.viewer = new TreeViewer ( parent );
this.viewer.getControl ().setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );
this.viewer.setAutoExpandLevel ( AbstractTreeViewer.ALL_LEVELS );
this.contentProvider = new ObservableListTreeContentProvider ( new FactoryImpl (), null );
this.viewer.setContentProvider ( this.contentProvider );
this.viewer.setLabelProvider ( this.labelProvider = new LabelProviderImpl ( this.resourceManager, this.contentProvider.getRealizedElements () ) );
}
示例13: expandAll
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
public static void expandAll(final TreeViewer treeViewer, final SchemaNode node) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
@Override
public void run() {
try {
treeViewer.getTree().setRedraw(false);
treeViewer.expandToLevel(node, AbstractTreeViewer.ALL_LEVELS);
} finally {
treeViewer.getTree().setRedraw(true);
}
}
});
}
示例14: collapseAll
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
public static void collapseAll(final TreeViewer treeViewer, final SchemaNode node) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
@Override
public void run() {
try {
treeViewer.getTree().setRedraw(false);
treeViewer.collapseToLevel(node, AbstractTreeViewer.ALL_LEVELS);
} finally {
treeViewer.getTree().setRedraw(true);
}
}
});
}
示例15: populate
import org.eclipse.jface.viewers.AbstractTreeViewer; //导入依赖的package包/类
@Override
public void populate(final TFSRepository repository, final ItemIdentifier id) {
final BranchObjectInput input = new BranchObjectInput(repository, id);
final TreeViewer viewer = control.getViewer();
viewer.setInput(input);
viewer.expandToLevel(input.branch, AbstractTreeViewer.ALL_LEVELS);
}