Java Code Examples for org.eclipse.ui.navigator.CommonViewer#getVisibleExpandedElements()

The following examples show how to use org.eclipse.ui.navigator.CommonViewer#getVisibleExpandedElements() . 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: GoUpAction.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void run(IAction action) {
    if (!action.isEnabled()) {
        return;
    }
    CommonViewer viewer = navigator.getCommonViewer();
    Object[] expandedElements = viewer.getVisibleExpandedElements();
    Object input = viewer.getInput();
    if (input instanceof BugGroup) {
        BugGroup group = (BugGroup) input;
        Object data = group.getParent();
        boolean needRefresh = data == null;
        if (needRefresh) {
            BugContentProvider.getProvider(navigator.getNavigatorContentService()).reSetInput();
        } else {
            viewer.setInput(data);
        }
        // viewer.setSelection(new StructuredSelection(input), true);
        // viewer.expandToLevel(input, 1);
        viewer.setExpandedElements(expandedElements);
    }
    action.setEnabled(isEnabled());
}
 
Example 2
Source File: GoIntoAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run(IAction action) {
    if (action.isEnabled() && navigator != null && selectedElement != null) {
        CommonViewer viewer = navigator.getCommonViewer();
        Object[] expandedElements = viewer.getVisibleExpandedElements();
        viewer.setInput(selectedElement);
        viewer.setExpandedElements(expandedElements);
    }
}