Example usage for org.eclipse.jface.viewers TreeViewer collapseAll

List of usage examples for org.eclipse.jface.viewers TreeViewer collapseAll

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TreeViewer collapseAll.

Prototype

public void collapseAll() 

Source Link

Document

Collapses all nodes of the viewer's tree, starting with the root.

Usage

From source file:org.kalypso.project.database.client.extension.project.AbstractModuleProjectOpenAction.java

License:Open Source License

private void revealProjectInExplorer(final IWorkbenchPage page, final IProject project)
        throws PartInitException {
    // At least show project in Resource Navigator
    final StructuredSelection projectSelection = new StructuredSelection(project);

    final CommonNavigator projectExplorer = (CommonNavigator) page.findView(IPageLayout.ID_PROJECT_EXPLORER);
    if (projectExplorer != null) {
        page.showView(IPageLayout.ID_PROJECT_EXPLORER, null, IWorkbenchPage.VIEW_ACTIVATE);
        final CommonViewer commonViewer = projectExplorer.getCommonViewer();
        commonViewer.collapseAll();//from w w  w  .j  av  a2s .  com
        commonViewer.setSelection(projectSelection);
        commonViewer.expandToLevel(project, 1);
    } else {
        final ResourceNavigator view = (ResourceNavigator) page.showView(IPageLayout.ID_RES_NAV);
        if (view != null) {
            final TreeViewer treeViewer = view.getTreeViewer();
            treeViewer.collapseAll();
            view.selectReveal(projectSelection);
            treeViewer.expandToLevel(project, 1);
        }
    }
}

From source file:org.kalypso.ui.rrm.internal.timeseries.view.actions.CollapseAllTreeItemsHandler.java

License:Open Source License

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart part = HandlerUtil.getActivePart(event);
    if (part == null)
        return null;

    final TreeViewer treeViewer = (TreeViewer) part.getAdapter(TreeViewer.class);
    if (treeViewer == null)
        return null;

    treeViewer.collapseAll();

    return null;//from w w w. jav a2 s.  c  o m
}

From source file:org.nabucco.testautomation.config.ui.rcp.command.config.execute.TreeErrorExpander.java

License:Open Source License

/**
 * Expands all error in the master detail tree of the given view.
 * //from w ww  .  j av  a 2 s.  co m
 * @param view the view
 * @param result the TestConfigurationResult to evaluate
 */
public void expandTree(TestConfigurationResultMaintenanceMultiPageEditView view, TestConfigurationResult result)
        throws ClientException {

    MasterDetailBlock<TestConfigurationResultMaintenanceMultiPageEditViewModel> masterDetailsBlock = view
            .getMasterDetailsBlock();
    TreeViewer treeViewer = masterDetailsBlock.getTreeViewer();

    TestConfigurationStatusType status = result.getStatus();

    if (status == TestConfigurationStatusType.FINISHED) {
        // Expand to level 2
        treeViewer.collapseAll();
        treeViewer.expandToLevel(2);
        // Additionally expand all errors
        List<TestResultContainer> testResultList = result.getTestResultList();
        for (TestResultContainer testResultContainer : testResultList) {
            ArrayList<Integer> initialPath = new ArrayList<Integer>();
            initialPath.add(0);
            initialPath.add(testResultList.indexOf(testResultContainer));
            Set<TreePath> paths = getTreePathsToError(getRoot(treeViewer), testResultContainer.getResult(),
                    initialPath);
            if (paths != null && paths.size() > 0) {
                for (TreePath path : paths) {
                    treeViewer.expandToLevel(path, 0);
                }
            }
        }
        return;
    } else {
        // Expand every path till TestScriptResult
        List<TestResultContainer> testResultList = result.getTestResultList();
        for (TestResultContainer testResultContainer : testResultList) {
            ArrayList<Integer> initialPath = new ArrayList<Integer>();
            initialPath.add(0);
            initialPath.add(testResultList.indexOf(testResultContainer));
            Set<TreePath> paths = getTreePathsToScriptResult(getRoot(treeViewer),
                    testResultContainer.getResult(), initialPath);
            if (paths != null && paths.size() > 0) {
                for (TreePath path : paths) {
                    treeViewer.expandToLevel(path, 0);
                }
            }
        }
        return;
    }
}