Search in sources :

Example 6 with AbstractTreeViewer

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

the class DTDTreeContentProvider method expandToNode.

private void expandToNode(DTDNode node) {
    DTDFile dtdFile = node.getDTDFile();
    // first expand the root
    AbstractTreeViewer viewer = (AbstractTreeViewer) fViewer;
    viewer.expandToLevel(dtdFile, 1);
    NodeList listToExpand = null;
    if (node instanceof Element || node instanceof ParameterEntityReference) {
        listToExpand = dtdFile.getElementsAndParameterEntityReferences();
    } else if (node instanceof Notation) {
        listToExpand = dtdFile.getNotations();
    } else if (node instanceof Entity) {
        listToExpand = dtdFile.getEntities();
    } else if (node instanceof Comment) {
        listToExpand = dtdFile.getComments();
    }
    if (listToExpand != null) {
        viewer.expandToLevel(listToExpand, 1);
    }
    viewer.expandToLevel(node, 0);
}
Also used : ParameterEntityReference(org.eclipse.wst.dtd.core.internal.ParameterEntityReference) Entity(org.eclipse.wst.dtd.core.internal.Entity) Comment(org.eclipse.wst.dtd.core.internal.Comment) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) Element(org.eclipse.wst.dtd.core.internal.Element) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 7 with AbstractTreeViewer

use of org.eclipse.jface.viewers.AbstractTreeViewer in project hale by halestudio.

the class TreePathPatternFilter method isParentMatch.

/**
 * @see PatternFilter#isParentMatch(Viewer, Object)
 */
@Override
protected boolean isParentMatch(Viewer viewer, Object element) {
    TreePath elementPath = (TreePath) element;
    boolean proceed = allowDescend(elementPath);
    if (!proceed) {
        return false;
    }
    Object[] children;
    ITreePathContentProvider cp = ((ITreePathContentProvider) ((AbstractTreeViewer) viewer).getContentProvider());
    children = cp.getChildren(elementPath);
    if ((children != null) && (children.length > 0)) {
        // convert children to tree paths
        List<TreePath> pathChildren = TreePathFilteredTree.getPathsForElements(elementPath, children);
        return isAnyVisible(viewer, element, pathChildren.toArray());
    }
    return false;
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) ITreePathContentProvider(org.eclipse.jface.viewers.ITreePathContentProvider) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer)

Example 8 with AbstractTreeViewer

use of org.eclipse.jface.viewers.AbstractTreeViewer in project eclipse.platform.text by eclipse.

the class SearchResultPageTest method testRemoveTreeMatches.

@Test
// checkElementDisplay(..) misses cases where one line contains multiple matches
@Ignore
public void testRemoveTreeMatches() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    ISearchResultViewPart view = NewSearchUI.getSearchResultView();
    FileSearchPage page = (FileSearchPage) view.getActivePage();
    page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_TREE);
    AbstractTreeViewer viewer = (AbstractTreeViewer) page.getViewer();
    AbstractTextSearchResult result = (AbstractTextSearchResult) fQuery1.getSearchResult();
    // make sure all elements have items.
    viewer.expandAll();
    Object[] elements = result.getElements();
    // page.setUpdateTracing(true);
    for (int i = 0; i < elements.length; i++) {
        Match[] matches = result.getMatches(elements[i]);
        viewer.reveal(elements[i]);
        for (int j = 0; j < matches.length; j++) {
            checkElementDisplay(viewer, result, elements[i]);
            result.removeMatch(matches[j]);
            consumeEvents(page);
        }
    }
// page.setUpdateTracing(false);
}
Also used : ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) FileSearchPage(org.eclipse.search.internal.ui.text.FileSearchPage) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Match(org.eclipse.search.ui.text.Match) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with AbstractTreeViewer

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

the class XMLMultiPageEditorPart method addEditorActions.

private void addEditorActions(IDesignViewer viewer) {
    if (viewer instanceof AbstractTreeViewer) {
        final Tree tree = (Tree) ((AbstractTreeViewer) viewer).getControl();
        fMenuManager = new MenuManager();
        fMenuManager.add(new Action(XMLEditorMessages.ConfigureColumns_label) {

            public void run() {
                ConfigureColumns.forTree(tree, new SameShellProvider(tree));
            }
        });
        // $NON-NLS-1$
        getSite().registerContextMenu("org.eclipse.wst.xml.ui.editor", fMenuManager, getSite().getSelectionProvider());
        fMenuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        fEditorManager.add(new EditorActions(fEditorManager.getControl()));
        fEditorManager.update(true);
    }
}
Also used : Action(org.eclipse.jface.action.Action) SameShellProvider(org.eclipse.jface.window.SameShellProvider) MenuManager(org.eclipse.jface.action.MenuManager) Tree(org.eclipse.swt.widgets.Tree) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) Separator(org.eclipse.jface.action.Separator)

Example 10 with AbstractTreeViewer

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

the class DTDTreeContentProvider method nodesAdded.

public void nodesAdded(NodesEvent event) {
    if (fViewer instanceof AbstractTreeViewer) {
        StructuredViewer viewer = (StructuredViewer) fViewer;
        ISelection selection = viewer.getSelection();
        Object firstObj = (!selection.isEmpty() && selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
        DTDNode oldSelectedNode = null;
        if (firstObj instanceof DTDNode) {
            oldSelectedNode = (DTDNode) firstObj;
        }
        // update the tree
        refreshTree(event);
        final List nodes = event.getNodes();
        if (!nodes.isEmpty()) {
            final DTDNode node = (DTDNode) nodes.get(0);
            if (oldSelectedNode == null || node.getStructuredDTDDocumentRegion() != oldSelectedNode.getStructuredDTDDocumentRegion() || node.getStartOffset() != oldSelectedNode.getStartOffset() || node.getEndOffset() != oldSelectedNode.getEndOffset()) {
                expandToNode(node);
                viewer.setSelection(new StructuredSelection(node));
            }
        }
    }
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) ArrayList(java.util.ArrayList) List(java.util.List) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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