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

The following examples show how to use org.eclipse.ui.navigator.CommonViewer#refresh() . 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: FilterBugsDialogAction.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void run(IAction action) {
    if (navigator == null) {
        return;
    }
    Set<BugPattern> filtered = FindbugsPlugin.getFilteredPatterns();
    Set<BugCode> filteredTypes = FindbugsPlugin.getFilteredPatternTypes();
    FilterBugsDialog dialog = new FilterBugsDialog(navigator.getSite().getShell(), filtered, filteredTypes);
    dialog.setTitle("Bug Filter Configuration");
    int result = dialog.open();
    if (result != Window.OK) {
        return;
    }
    String selectedIds = dialog.getSelectedIds();

    FindbugsPlugin.getDefault().getPreferenceStore().setValue(FindBugsConstants.LAST_USED_EXPORT_FILTER, selectedIds);

    BugContentProvider provider = BugContentProvider.getProvider(navigator.getNavigatorContentService());
    provider.refreshFilters();
    CommonViewer viewer = navigator.getCommonViewer();
    Object[] expandedElements = viewer.getExpandedElements();
    viewer.refresh(true);
    viewer.setExpandedElements(expandedElements);
}
 
Example 2
Source File: RefreshAction.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void run(IAction action) {
    if (navigator != null) {
        CommonViewer viewer = navigator.getCommonViewer();
        BugContentProvider provider = BugContentProvider.getProvider(navigator.getNavigatorContentService());
        // provider.setRefreshRequested(true);

        Object[] expandedElements = viewer.getExpandedElements();
        Object input = viewer.getInput();
        if (provider.getChildren(input).length == 0) {
            viewer.setInput(null);
            if (input instanceof IWorkingSet || input instanceof IWorkspaceRoot) {
                viewer.setInput(input);
            } else {
                viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
            }
            viewer.refresh(true);
        } else {
            provider.reSetInput();
        }
        viewer.setExpandedElements(expandedElements);
    }
}
 
Example 3
Source File: FilterPatternAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run(IAction action) {
    Set<String> sortedIds = FindbugsPlugin.getFilteredIds();
    String patternType = getPatternOrPatternType();
    if (patternType != null) {
        if (!sortedIds.contains(patternType)) {
            sortedIds.add(patternType);
        } else {
            sortedIds.remove(patternType);
        }
    }
    String ids = FindBugsConstants.encodeIds(sortedIds);
    final IPreferenceStore store = FindbugsPlugin.getDefault().getPreferenceStore();
    store.setValue(FindBugsConstants.LAST_USED_EXPORT_FILTER, ids);
    BugContentProvider provider = BugContentProvider.getProvider(navigator.getNavigatorContentService());
    if (!provider.isBugFilterActive()) {
        MessageDialog.openWarning(null, "Toggle Filter", "Filtering by pattern or type id is currently not enabled!\n"
                + "To enable it, please select \"Toggle Filters...->Bugs by Id\" filter!");

    }
    provider.refreshFilters();
    CommonViewer viewer = navigator.getCommonViewer();
    Object[] expandedElements = viewer.getExpandedElements();
    viewer.refresh(true);
    viewer.setExpandedElements(expandedElements);
    data = null;
}
 
Example 4
Source File: ToolboxExplorer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Refreshes the instance of the viewer if any
 */
public static void refresh()
{
    CommonViewer instance = getViewer();
    if (instance != null)
    {
        instance.refresh();
    }
}
 
Example 5
Source File: Navigator.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Refresh the navigation view if it is available.
 */
public static void refresh() {
	CommonViewer viewer = getNavigationViewer();
	NavigationRoot root = getNavigationRoot();
	if (viewer == null || root == null)
		return;
	Object[] oldExpansion = viewer.getExpandedElements();
	root.update();
	viewer.refresh();
	setRefreshedExpansion(viewer, oldExpansion);
}
 
Example 6
Source File: Navigator.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Refreshes the content *under* the given element.
 */
public static void refresh(INavigationElement<?> element) {
	CommonViewer viewer = getNavigationViewer();
	if (viewer == null || element == null)
		return;
	element.update();
	Object[] oldExpansion = viewer.getExpandedElements();
	viewer.refresh(element);
	updateLabels(viewer, element);
	if (oldExpansion == null)
		return;
	setRefreshedExpansion(viewer, oldExpansion);
}