Example usage for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS

List of usage examples for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS.

Prototype

int ALL_LEVELS

To view the source code for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS.

Click Source Link

Document

Constant indicating that all levels of the tree should be expanded or collapsed.

Usage

From source file:org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart.java

License:Open Source License

public void collapseAll() {
    if (viewer == null)
        return;//from   www  .j  a va 2  s  .c  o  m
    viewer.getControl().setRedraw(false);
    viewer.collapseToLevel(viewer.getInput(), AbstractTreeViewer.ALL_LEVELS);
    viewer.getControl().setRedraw(true);
}

From source file:org.eclipse.team.internal.ui.mapping.CommonViewerAdvisor.java

License:Open Source License

protected void expandToNextDiff(Object element) {
    ((TreeViewer) getViewer()).expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
}

From source file:org.eclipse.team.internal.ui.synchronize.AbstractTreeViewerAdvisor.java

License:Open Source License

/**
 * Handles a double-click event from the viewer. Expands or collapses a folder when double-clicked.
 * // w  ww.j a v a 2  s  .c o m
 * @param viewer the viewer
 * @param event the double-click event
 */
protected boolean handleDoubleClick(StructuredViewer viewer, DoubleClickEvent event) {
    if (super.handleDoubleClick(viewer, event))
        return true;
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    Object element = getFirstElementOrPath(selection);
    AbstractTreeViewer treeViewer = (AbstractTreeViewer) getViewer();
    if (element != null) {
        if (treeViewer.getExpandedState(element)) {
            treeViewer.collapseToLevel(element, AbstractTreeViewer.ALL_LEVELS);
        } else {
            expandToNextDiff(element);
        }
    }
    return true;
}

From source file:org.eclipse.team.internal.ui.synchronize.actions.ExpandAllAction.java

License:Open Source License

protected void expandAllFromSelection() {
    AbstractTreeViewer tree = viewer;/*  w w  w .j  av  a2 s  .  c o  m*/
    if (tree == null)
        return;
    ISelection selection = tree.getSelection();
    if (!selection.isEmpty()) {
        Iterator elements = ((IStructuredSelection) selection).iterator();
        try {
            tree.getControl().setRedraw(false);
            while (elements.hasNext()) {
                Object next = elements.next();
                tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
            }
        } finally {
            tree.getControl().setRedraw(true);
        }
    }
}

From source file:org.eclipse.team.internal.ui.synchronize.NavigationActionGroup.java

License:Open Source License

public void initialize(ISynchronizePageConfiguration configuration) {
    super.initialize(configuration);
    final Viewer viewer = configuration.getPage().getViewer();
    if (viewer instanceof AbstractTreeViewer) {

        expandAllAction = new ExpandAllAction((AbstractTreeViewer) viewer);
        Utils.initAction(expandAllAction, "action.expandAll."); //$NON-NLS-1$

        collapseAll = new Action() {
            public void run() {
                if (viewer.getControl().isDisposed() || !(viewer instanceof AbstractTreeViewer))
                    return;
                viewer.getControl().setRedraw(false);
                ((AbstractTreeViewer) viewer).collapseToLevel(viewer.getInput(), AbstractTreeViewer.ALL_LEVELS);
                viewer.getControl().setRedraw(true);
            }//from w w  w  .j a  va  2  s  .co m
        };
        Utils.initAction(collapseAll, "action.collapseAll."); //$NON-NLS-1$

        ICompareNavigator nav = (ICompareNavigator) configuration
                .getProperty(SynchronizePageConfiguration.P_NAVIGATOR);
        if (nav != null) {
            gotoNext = new NavigateAction(configuration, true /*next*/);
            gotoPrevious = new NavigateAction(configuration, false /*previous*/);
        }
    }
}

From source file:org.eclipse.test.internal.performance.results.ui.ComponentsView.java

License:Open Source License

/**
 * Select a results element in the tree.
 *//*w  w  w.  j  a  v a 2s  .  c  om*/
public void select(ComponentResultsElement componentResults, String configName, String scenarioName,
        String buildName) {

    // Collapse previous expanded components except the requested one
    // TODO (frederic) also collapse expanded components children elements
    this.expandedComponents.remove(componentResults);
    Iterator iterator = this.expandedComponents.iterator();
    while (iterator.hasNext()) {
        this.viewer.collapseToLevel(iterator.next(), AbstractTreeViewer.ALL_LEVELS);
    }
    this.expandedComponents.clear();

    // Set the tree selection
    ScenarioResultsElement scenarioResultsElement = (ScenarioResultsElement) componentResults
            .getResultsElement(scenarioName);
    if (scenarioResultsElement != null) {
        ConfigResultsElement configResultsElement = (ConfigResultsElement) scenarioResultsElement
                .getResultsElement(configName);
        if (configResultsElement != null) {
            BuildResultsElement buildResultsElement = (BuildResultsElement) configResultsElement
                    .getResultsElement(buildName);
            if (buildResultsElement != null) {
                this.viewer.setSelection(new StructuredSelection(buildResultsElement), true);
                this.setFocus();
            }
        }
    }
}

From source file:org.eclipse.titan.log.viewer.actions.ExtractTestCasesAction.java

License:Open Source License

@Override
public void run(final IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
    this.monitor = pMonitor == null ? new NullProgressMonitor() : pMonitor;

    // First of all, verify that the file is a TITAN supported log file
    try {//from   w  ww.ja  va  2  s.com
        this.logFileMetaData = this.logFileHandler.autoDetect();
    } catch (TechnicalException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
        return;
    }

    try {
        Object temp = logFile.getSessionProperty(Constants.EXTRACTION_RUNNING);
        if (temp != null && (Boolean) temp) {
            monitor.done();
            return;
        }
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
    }

    try {
        this.monitor.beginTask(Messages.getString("ExtractTestCasesAction.0"), 100); //$NON-NLS-1$

        // Check if a property file exists for the log file (if log file has changed or not)
        boolean logFileHasChanged = LogFileCacheHandler.hasLogFileChanged(this.logFile);

        // Get the property file
        File propertyFile = LogFileCacheHandler.getPropertyFileForLogFile(this.logFile);

        if (logFileHasChanged) {
            if (updateLogFileIndex()) {
                return;
            }
        } else {
            if (Constants.DEBUG) {
                TITANDebugConsole.getConsole().newMessageStream()
                        .println("Log file has NOT changed -> extracting from index file!"); //$NON-NLS-1$
            }
            // Get log file meta data 
            this.logFileMetaData = LogFileCacheHandler.logFileMetaDataReader(propertyFile);
            // Extract test cases from the index file
            this.testCaseExtractor.extractTestCasesFromIndexedLogFile(this.logFile);
        }
    } catch (final IOException e) {
        handleExtractingError(e);
    } catch (final ClassNotFoundException e) {
        handleExtractingError(e);
    } catch (final CoreException e) {
        handleExtractingError(e);
    }

    setExtractionRunningProperty(false);
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                    .getActivePage();
            IViewPart view = activePage.findView(PROJECT_EXPLORER_VIEW_ID);

            if (view instanceof CommonNavigator) {
                CommonViewer viewer = ((CommonNavigator) view).getCommonViewer();
                viewer.refresh(logFile, true);
                viewer.expandToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
            }
        }
    });
    this.testCaseEventDispatcher.deleteObserver(this);
    this.testCaseExtractor.deleteObserver(this.testCaseEventDispatcher);
    this.monitor.done();
}

From source file:org.eclipse.titan.log.viewer.actions.ExtractTestCasesAction.java

License:Open Source License

private boolean updateLogFileIndex() throws CoreException, IOException {
    if (Constants.DEBUG) {
        TITANDebugConsole.getConsole().newMessageStream()
                .println("Log file has changed -> extracting from log file!"); //$NON-NLS-1$
    }/*from  w w w . j  av a 2 s .c  om*/
    logFile.setSessionProperty(Constants.EXTRACTION_RUNNING, true);

    ResourceUtils.refreshResources(Arrays.asList(logFile));

    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            IViewPart view = activePage.findView(PROJECT_EXPLORER_VIEW_ID);
            if (view instanceof CommonNavigator) {
                CommonViewer viewer = ((CommonNavigator) view).getCommonViewer();
                viewer.refresh(logFile, true);
                viewer.collapseToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
            }
        }
    });

    // Extract test cases from log file
    this.testCaseExtractor.extractTestCasesFromLogFile(this.logFileMetaData, monitor);

    if (monitor.isCanceled()) {
        LogFileCacheHandler.clearCache(logFile);
        monitor.done();
        setExtractionRunningProperty(false);
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                        .getActivePage();
                IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");
                if (view instanceof CommonNavigator) {
                    CommonViewer viewer = ((CommonNavigator) view).getCommonViewer();
                    viewer.refresh(logFile, true);
                    viewer.collapseToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
                }
            }
        });
        return true;
    }

    LogFileCacheHandler.fillCache(logFile, this.logFileMetaData, this.testCaseExtractor.getTestCases(),
            this.testCaseExtractor.getLogRecordIndexes());
    return false;
}

From source file:org.eclipse.titan.log.viewer.utils.ActionUtils.java

License:Open Source License

/**
 * Updates the log file and it's children in the project explorer view. It should be used when the test cases
 * of the log file or the log file has changed. For example when the test case extraction is done.
 * @param logFile//from w ww. ja  v  a 2s. com
 */
public static void refreshLogFileInProjectsViewer(final IFile logFile) {
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                    .getActivePage();
            IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");

            if (view instanceof CommonNavigator) {
                CommonViewer viewer = ((CommonNavigator) view).getCommonViewer();
                viewer.refresh(logFile, true);
                viewer.expandToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
            }
        }
    });
}

From source file:org.eclipse.titan.log.viewer.utils.LogFileCacheHandler.java

License:Open Source License

/**
 * Should be called when a log file has changed. Closes the associated views. Shows a <code>MessageBox</code> where the user can decide if he/she wants to process
 * the log file or just close the views. If the user choose yes, the processing will start in a new <code>WorkspaceJob</code>.
 * @param logFile// ww  w. j  a  v  a 2 s  .com
 */
public static void handleLogFileChange(final IFile logFile) {
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final IViewReference[] viewReferences = activePage.getViewReferences();
    ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
    clearCache(logFile);

    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");
            if (view instanceof CommonNavigator) {
                CommonNavigator navigator = (CommonNavigator) view;
                navigator.getCommonViewer().collapseToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
            }
        }
    });

    MessageBox mb = new MessageBox(activePage.getActivePart().getSite().getShell(),
            SWT.ICON_ERROR | SWT.OK | SWT.CANCEL);
    mb.setText("The log file has been modified.");
    mb.setMessage("The log file has been modified. Click on OK to extract the test cases"
            + " or CANCEL to close the associated views.");
    if (mb.open() == SWT.OK) {
        WorkspaceJob job = new WorkspaceJob("Testcase extraction from log file: " + logFile.getName()) {
            @Override
            public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
                boolean completed = LogFileCacheHandler.processLogFile(logFile, monitor, false);
                return completed ? Status.OK_STATUS : Status.CANCEL_STATUS;
            }
        };
        job.setPriority(Job.LONG);
        job.setUser(true);
        job.setRule(logFile.getProject());
        job.schedule();
    }
}