org.eclipse.jface.viewers.AbstractTreeViewer Java Examples

The following examples show how to use org.eclipse.jface.viewers.AbstractTreeViewer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourceContentOutlinePage.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void expandConnection(CodewindConnection connection) {
	if (connection == null) {
		return;
	}
	List<CodewindApplication> apps = connection.getApps();
	if (!apps.isEmpty()) {
		Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
				IViewPart view = getViewPart(CodewindExplorerView.VIEW_ID);
				if (view instanceof CommonNavigator) {
					CommonViewer viewer = ((CommonNavigator)view).getCommonViewer();
			
					if (!viewer.getExpandedState(connection)) {
						viewer.expandToLevel(AbstractTreeViewer.ALL_LEVELS);
					}
	            }
 			}
		});
	}
}
 
Example #3
Source File: FilteredElementTreeSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: AbstractSelectTreeViewer2.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parent
 *            Parent composite
 * @param checkboxTree
 *            <code>TriStateFilteredTree</code> wrapping a
 *            <code>CheckboxTreeViewer</code>
 * @param legendColumnIndex
 *            index of the legend column (-1 if none)
 */
private AbstractSelectTreeViewer2(Composite parent, TriStateFilteredCheckboxTree checkboxTree,
        int legendIndex, String id) {
    super(parent, checkboxTree.getViewer());

    TreeViewer treeViewer = checkboxTree.getViewer();
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.setComparator(COMPARATOR);
    if (treeViewer instanceof CheckboxTreeViewer) {
        ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener());
    }
    treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener());
    checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext());
    fCheckboxTree = checkboxTree;
    fLegendIndex = legendIndex;
    fId = id;
    fLogCategory = fId + LOG_CATEGORY_SUFFIX;
    fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet();
    setLabelProvider(new DataProviderTreeLabelProvider());
}
 
Example #5
Source File: AbstractSelectTreeViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parent
 *            Parent composite
 * @param checkboxTree
 *            <code>TriStateFilteredTree</code> wrapping a
 *            <code>CheckboxTreeViewer</code>
 * @param legendColumnIndex
 *            index of the legend column (-1 if none)
 */
private AbstractSelectTreeViewer(Composite parent, TriStateFilteredCheckboxTree checkboxTree,
        int legendIndex, String id) {
    super(parent, checkboxTree.getViewer());

    TreeViewer treeViewer = checkboxTree.getViewer();
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.setComparator(COMPARATOR);
    if (treeViewer instanceof CheckboxTreeViewer) {
        ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener());
    }
    treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener());
    checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext());
    fCheckboxTree = checkboxTree;
    fLegendIndex = legendIndex;
    fId = id;
    fLogCategory = fId + LOG_CATEGORY_SUFFIX;
    setLabelProvider(new DataProviderTreeLabelProvider());
    fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet();
}
 
Example #6
Source File: JavaBrowsingContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example #7
Source File: CubeGroupContent.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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( );
		}
	}
}
 
Example #8
Source File: AbstractInformationControl.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * 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());
}
 
Example #9
Source File: UIUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 );
}
 
Example #10
Source File: ViewerUtils.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/** @see AbstractTreeViewer#expandToLevel(int) */
public static void expandToLevel(final Viewer viewer, final int level) {
  Display.getDefault()
      .asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (viewer == null || viewer.getControl().isDisposed()) return;

              if (viewer instanceof AbstractTreeViewer) {
                AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
                treeViewer.expandToLevel(level);
              }
            }
          });
}
 
Example #11
Source File: ViewerUtils.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If supported by the viewer expands all elements and makes sure it runs in the SWT thread.
 *
 * @param viewer
 * @see AbstractTreeViewer#expandAll()
 */
public static void expandAll(final Viewer viewer) {
  Display.getDefault()
      .asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (viewer == null || viewer.getControl().isDisposed()) return;

              if (viewer instanceof AbstractTreeViewer) {
                AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
                treeViewer.expandAll();
              }
            }
          });
}
 
Example #12
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void toggleExpansion(Object element) {
	final Object obj = element == null ? CodewindManager.getManager() : element;
	Display.getDefault().asyncExec(new Runnable() {
           @Override
           public void run() {
			IViewPart view = getViewPart(CodewindExplorerView.VIEW_ID);
			if (view instanceof CommonNavigator) {
				CommonViewer viewer = ((CommonNavigator)view).getCommonViewer();
		
				if (!viewer.getExpandedState(obj)) {
					viewer.expandToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
				} else {
					viewer.collapseToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
				}
            }
			}
	});
}
 
Example #13
Source File: NonGEFSynchronizerWithTreeView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Hook the tree view need to synchronized
 * 
 * @param viewer
 */
public void setTreeViewer( AbstractTreeViewer viewer )
{
	this.viewer = viewer;
	getTreeViewer( ).addSelectionChangedListener( new ISelectionChangedListener( ) {

		public void selectionChanged( SelectionChangedEvent event )
		{
			treeSelect( event );
		}

	} );
}
 
Example #14
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void collapseAll() {
	try {
		fViewer.getControl().setRedraw(false);
		fViewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
	} finally {
		fViewer.getControl().setRedraw(true);
	}
}
 
Example #15
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    Control composite = super.createDialogArea(parent);

    if (composite instanceof Composite) {
        updateCompositeLayout((Composite) composite);
    }

    TreeViewer treeViewer = getTreeViewer();
    treeViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return matchItemToShowInTree(element);
        }
    });
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.expandAll();

    if (this.initialFilter.length() > 0) {
        this.text.setText(this.initialFilter);
        this.text.setSelection(this.initialFilter.length());
        this.setFilter(this.initialFilter, new NullProgressMonitor(), true);
    }

    notifyViewCreated();
    onControlCreated.call(this.text);
    onControlCreated.call(this.getTreeViewer());

    return composite;
}
 
Example #16
Source File: JavaBrowsingContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void postAdd(final Object parent, final Object[] elements) {
	if (elements == null || elements.length <= 0)
		return;

	postRunnable(new Runnable() {
		public void run() {
			Control ctrl= fViewer.getControl();
			if (ctrl != null && !ctrl.isDisposed()) {
				Object[] newElements= getNewElements(elements);
				if (fViewer instanceof AbstractTreeViewer) {
					if (fViewer.testFindItem(parent) == null) {
						Object root= ((AbstractTreeViewer)fViewer).getInput();
						if (root != null)
							((AbstractTreeViewer)fViewer).add(root, newElements);
					}
					else
						((AbstractTreeViewer)fViewer).add(parent, newElements);
				}
				else if (fViewer instanceof ListViewer)
					((ListViewer)fViewer).add(newElements);
				else if (fViewer instanceof TableViewer)
					((TableViewer)fViewer).add(newElements);
				if (fViewer.testFindItem(elements[0]) != null)
					fBrowsingPart.adjustInputAndSetSelection(elements[0]);
			}
		}
	});
}
 
Example #17
Source File: AbstractSearchResultsViewerFilter.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean isParentMatch(Viewer viewer, Object element) {
    Object[] children = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)
            .getContentProvider()).getChildren(element);

    if ((children != null) && (children.length > 0)) {
        return isAnyVisible(viewer, element, children);
    }
    return false;
}
 
Example #18
Source File: UserLibraryPreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void editUserLibraryElement(CPUserLibraryElement element) {
	LibraryNameDialog dialog= new LibraryNameDialog(getShell(), element, fLibraryList.getElements());
	if (dialog.open() == Window.OK) {
		CPUserLibraryElement newLibrary= dialog.getNewLibrary();
		if (element != null) {
			fLibraryList.replaceElement(element, newLibrary);
		} else {
			fLibraryList.addElement(newLibrary);
		}
		fLibraryList.expandElement(newLibrary, AbstractTreeViewer.ALL_LEVELS);
		fLibraryList.selectElements(new StructuredSelection(newLibrary));
	}
}
 
Example #19
Source File: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeViewer createTreeViewer(Composite parent, int style) {
	Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.heightHint= tree.getItemHeight() * 12;
	tree.setLayoutData(gd);

	final TreeViewer treeViewer= new OutlineTreeViewer(tree);

	// Hard-coded filters
	treeViewer.addFilter(new NamePatternFilter());
	treeViewer.addFilter(new MemberFilter());

	fInnerLabelProvider= new OutlineLabelProvider();
	fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
	IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager();
	if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$
		fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null));

	treeViewer.setLabelProvider(new ColoringLabelProvider(fInnerLabelProvider));

	fLexicalSortingAction= new LexicalSortingAction(treeViewer);
	fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer);
	fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer);
	fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer, getId(), getInputForCategories());

	fOutlineContentProvider= new OutlineContentProvider(false);
	treeViewer.setContentProvider(fOutlineContentProvider);
	fOutlineSorter= new OutlineSorter();
	treeViewer.setComparator(fOutlineSorter);
	treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);


	treeViewer.getTree().addKeyListener(getKeyAdapter());

	return treeViewer;
}
 
Example #20
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addDropAdapters(AbstractTreeViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), PluginTransfer.getInstance() };
	int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;

	DelegatingDropAdapter delegatingDropAdapter= new DelegatingDropAdapter();
	delegatingDropAdapter.addDropTargetListener(new TypeHierarchyTransferDropAdapter(this, viewer));
	delegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(viewer));

	viewer.addDropSupport(ops, transfers, delegatingDropAdapter);
}
 
Example #21
Source File: LevelTreeContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public synchronized void elementsChanged(Object[] updatedElements) {
	if (getSearchResult() == null)
		return;

	AbstractTreeViewer viewer= (AbstractTreeViewer) getPage().getViewer();

	Set<Object> toRemove= new HashSet<Object>();
	Set<Object> toUpdate= new HashSet<Object>();
	Map<Object, Set<Object>> toAdd= new HashMap<Object, Set<Object>>();
	for (int i= 0; i < updatedElements.length; i++) {
		if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0)
			insert(toAdd, toUpdate, updatedElements[i]);
		else
			remove(toRemove, toUpdate, updatedElements[i]);
	}

	viewer.remove(toRemove.toArray());
	for (Iterator<Object> iter= toAdd.keySet().iterator(); iter.hasNext();) {
		Object parent= iter.next();
		HashSet<Object> children= (HashSet<Object>) toAdd.get(parent);
		viewer.add(parent, children.toArray());
	}
	for (Iterator<Object> elementsToUpdate= toUpdate.iterator(); elementsToUpdate.hasNext();) {
		viewer.refresh(elementsToUpdate.next());
	}

}
 
Example #22
Source File: CallHierarchyContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
*      java.lang.Object, java.lang.Object)
*/
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
  	if (oldInput instanceof TreeRoot) {
  		MethodWrapper[] roots = ((TreeRoot) oldInput).getRoots();
 			cancelJobs(roots);
  	}
      if (viewer instanceof AbstractTreeViewer) {
          fManager = new DeferredTreeContentManager((AbstractTreeViewer) viewer, fPart.getSite());
      }
  }
 
Example #23
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void refreshNavigatorView(String viewId, Object element) {
	Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
  	IViewPart part = getViewPart(viewId);
      if (part != null) {
          if (part instanceof CommonNavigator) {
              CommonNavigator v = (CommonNavigator) part;
              v.getCommonViewer().refresh(element);
              v.getCommonViewer().expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
          }
      }
        }
	});
}
 
Example #24
Source File: PatternFilter.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Check if the parent (category) is a match to the filter text. The default behavior returns true if the element has
 * at least one child element that is a match with the filter text. Subclasses may override this method.
 *
 * @param viewer the viewer that contains the element
 * @param element the tree element to check
 * @return true if the given element has children that matches the filter text
 */
protected boolean isParentMatch(Viewer viewer, Object element) {
   Object[] children =
      ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()).getChildren(element);

   if ((children != null) && (children.length > 0)) {
      return isAnyVisible(viewer, element, children);
   }
   return false;
}
 
Example #25
Source File: KeyTreeViewer.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 () ) );
}
 
Example #26
Source File: SGenWizardPage2.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void createObjectTree(Composite container) {
	lblNewLabel = new Label(container, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType());

	resourceTree = new CheckboxTreeViewer(container, SWT.BORDER);
	resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	resourceTree.setContentProvider(new WorkspaceTreeContentProvider());
	resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider());

	TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) {
		@Override
		public void checkStateChanged(CheckStateChangedEvent event) {
			super.checkStateChanged(event);
		}
	};
	resourceTree.addCheckStateListener(checkStateListener);
	resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener));
	resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
	resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
		@Override
		public boolean select(Viewer viewer, Object parentElement, Object element) {
			// TODO: Filter by common navigator filter instead of supressing
			// '.' prefixed folder
			if (element instanceof IFolder) {
				return !((IFolder) element).getName().startsWith(".");
			}
			return true;
		}
	} });
}
 
Example #27
Source File: TreePatternFilter.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Check if at least one of the parents of this element is a match with the
 * filter text.
 *
 * @param viewer
 *            the viewer that contains the element
 * @param element
 *            the tree element to check
 * @return true if the given element has a parent that matches the filter
 *         text
 */
private boolean isChildMatch(Viewer viewer, Object element) {
    Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider())
            .getParent(element);
    while (parent != null) {
        if (isLeafMatch(viewer, parent)) {
            return true;
        }
        parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider())
                .getParent(parent);
    }
    return false;
}
 
Example #28
Source File: RemoteProfilesPreferencePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void newElementAdded(TracePackageElement element) {
    if (element.getParent() != null) {
        fTreeViewer.refresh(element.getParent());
    } else {
        fTreeViewer.refresh();
    }
    fTreeViewer.expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
    fTreeViewer.setSelection(new StructuredSelection(element));
    validate();
}
 
Example #29
Source File: TypeScriptNavigatorContentProvider.java    From typescript.java with MIT License 5 votes vote down vote up
private void updateTypeScriptResourcesLabel(IIDETypeScriptProject tsProject) {
	// he widget may have been destroyed
	// by the time this is run. Check for this and do nothing if so.
	Control ctrl = viewer.getControl();
	if (ctrl == null || ctrl.isDisposed()) {
		return;
	}
	if (viewer instanceof AbstractTreeViewer) {
		AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
		treeViewer.refresh(tsProject, true);
	}
}
 
Example #30
Source File: ReportListView.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 5 votes vote down vote up
private void hookDoubleClickAction() {
    viewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();

            if (selection == null || selection.isEmpty()) {
                return;
            }

            final Object sel = selection.getFirstElement();

            if(sel instanceof BugPathItem) {
                BugPathItem bpi = (BugPathItem) sel;
                jumpToBugPosition(bpi);
                return;
            }

            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);
            }

        }
    });
}