Class NavigatorUtil


  • public final class NavigatorUtil
    extends Object
    Utilities for navigator.
    • Method Detail

      • activateOrRefreshFilter

        public static void activateOrRefreshFilter​(org.eclipse.ui.navigator.CommonNavigator navigator,
                                                   String filterId)
        Activates the given filter for a given navigator. If filter is already active the content of navigator is refreshed.
        Parameters:
        navigator - navigator to activate filter for.
        filterId - filter ID to activate.
      • applyFilterNonBlockingUi

        public static void applyFilterNonBlockingUi​(org.eclipse.ui.navigator.CommonNavigator navigator,
                                                    String filterId)
        Special navigator filtering method - for run on non-UI thread to prevent from long time UI blocking.

        Filter with the corresponding id must override ViewerFilter.filter(Viewer viewer, Object parent, Object[] elements) method to operate with viewer object only, NullPointerException will be thrown otherwise.

        Parameters:
        navigator - navigator to activate filter on, cannot be null
        filterId - filter ID to activate, cannot be null
      • aсtivateFilterNonBlockingUi

        public static void aсtivateFilterNonBlockingUi​(org.eclipse.ui.navigator.CommonNavigator navigator,
                                                       String filterId)
        Filter activator on Navigator to prevent from UI side effects (wrong tree opening on cancel).
        Parameters:
        navigator - navigator to activate filter on, cannot be null
        filterId - filter ID to activate, cannot be null
      • deactivateFilter

        public static void deactivateFilter​(org.eclipse.ui.navigator.CommonNavigator navigator,
                                            String filterId)
        Deactivates the given filter for a given navigator.
        Parameters:
        navigator - navigator to deactivate filter for.
        filterId - filter ID to deactivate.
      • setFilterActive

        public static void setFilterActive​(org.eclipse.ui.navigator.CommonNavigator navigator,
                                           String filterId,
                                           boolean active)
        Sets filter enablement.
        Parameters:
        navigator - navigator to deactivate filter for.
        filterId - filter ID to deactivate.
        active - true to activate the filter, false to deactivate.
      • getINavigatorContentProviderStateAware

        public static INavigatorContentProviderStateAware getINavigatorContentProviderStateAware​(org.eclipse.ui.navigator.INavigatorContentService contentService,
                                                                                                 Object element)
        Gets special extension INavigatorContentProviderStateAware of content provider using for navigator tree, for change it state
        Parameters:
        contentService - actual INavigatorContentService for getting navigator content provider, can't be null
        element - for getting INavigatorContentExtension, can't be null
        Returns:
        special extension INavigatorContentProviderStateAware of content provider, can be null if there is no content provider with this extension
      • getProjectFromSelectedObject

        public static org.eclipse.core.resources.IProject getProjectFromSelectedObject​(Object selectedObject,
                                                                                       IResourceLookup resourceLookup)
        Returns the project based on the object from the selection.
        Parameters:
        selectedObject - the selected object to get project for, cannot be null
        resourceLookup - the resource lookup, cannot be null
        Returns:
        the project if retrievable, null otherwise