Search in sources :

Example 11 with AbstractTreeViewer

use of org.eclipse.jface.viewers.AbstractTreeViewer in project webtools.sourceediting by eclipse.

the class DTDTreeContentProvider method refreshTree.

/**
 * <p>Refreshes the tree from the parents of the given node.</p>
 * @param node refresh the tree from the parents of this node
 */
private void refreshTree(Object node) {
    List parents = getParents(node);
    if (parents.size() > 0) {
        for (int p = 0; p < parents.size(); ++p) {
            final Object parent = parents.get(p);
            // insert the node directly to improve performance
            if (parent instanceof DTDFile) {
                Object[] objs = getChildren(parent);
                for (int i = 0; i < objs.length; i++) {
                    if (objs[i] == node) {
                        ((AbstractTreeViewer) fViewer).insert(parent, node, i);
                        break;
                    }
                }
            }
            this.refreshTreeNode(parent, true);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 12 with AbstractTreeViewer

use of org.eclipse.jface.viewers.AbstractTreeViewer in project egit by eclipse.

the class ReflogViewContentProvider method inputChanged.

@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    if (oldInput != null && loader != null) {
        loader.cancel(oldInput);
    }
    currentInput = newInput;
    if (viewer instanceof AbstractTreeViewer && newInput != null) {
        loader = new DeferredBatchLoader((AbstractTreeViewer) viewer);
        loader.addUpdateCompleteListener(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                if (event.getResult().isOK()) {
                    // Force a selection event
                    viewer.setSelection(viewer.getSelection());
                }
            }
        });
    }
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Aggregations

AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)12 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)5 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IResource (org.eclipse.core.resources.IResource)2 IResourceDelta (org.eclipse.core.resources.IResourceDelta)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)2 Control (org.eclipse.swt.widgets.Control)2 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)2 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 Action (org.eclipse.jface.action.Action)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ITreePathContentProvider (org.eclipse.jface.viewers.ITreePathContentProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1