Class WorkbenchActivityHelper


  • public final class WorkbenchActivityHelper
    extends java.lang.Object
    A utility class that contains helpful methods for interacting with the activities API.
    Since:
    3.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String TRIGGER_PRE_UI_POINT
      The ID of the trigger point that only returns activities with core expressions.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static boolean allowUseOf​(java.lang.Object object)
      Deprecated.
      static boolean allowUseOf​(ITriggerPoint triggerPoint, java.lang.Object object)
      Answers whether a given contribution is allowed to be used based on activity enablement.
      static java.lang.String createUnifiedId​(IPluginContribution contribution)
      Utility method to create a String containing the plugin and extension ids of a contribution.
      static java.util.Set<java.lang.String> expandActivityDependencies​(java.util.Set<java.lang.String> baseActivities)
      Return the expanded activities for the given activity set.
      static java.lang.Object[] filterArray​(java.lang.Object[] array)
      Returns an array with those objects of the argument array that pass the filterItem(Object) test.
      static <T> java.util.Collection<T> filterCollection​(java.util.Collection<T> toBeFiltered, java.util.Collection<T> result)
      Fills and returns the second argument with those objects of the first argument that pass the filterItem(Object) test.
      static boolean filterItem​(java.lang.Object object)
      Answers whether the provided object should be filtered from the UI based on activity state.
      static java.util.Set<java.lang.String> getActivityIdsForCategory​(ICategory category)
      Return the activities directly required by a given category.
      static java.util.Set<java.lang.String> getContainedCategories​(IActivityManager activityManager, java.lang.String categoryId)
      Return a list of category ids that are implicitly contained within the given category.
      static java.util.Set<java.lang.String> getDisabledCategories​(IActivityManager activityManager, java.lang.String categoryId)
      Return a list of category ids that will become implicity disabled if the given category becomes disabled Note that the set returned by this set represents the delta of categories that would be enabled - if the category is already enabled then it is omitted.
      static java.util.Set<java.lang.String> getEnabledCategories​(IActivityManager activityManager)
      Return the set of enabled categories.
      static java.util.Set<java.lang.String> getEnabledCategories​(IActivityManager activityManager, java.lang.String categoryId)
      Return a list of category ids that will become implicity enabled if the given category becomes enabled Note that the set returned by this set represents the delta of categories that would be enabled - if the category is already enabled then it is omitted.
      static java.util.Set<java.lang.String> getEnabledCategoriesForActivity​(IActivityManager activityManager, java.lang.String activityId)
      Return the number of enabled categories that this activity belongs to.
      static IIdentifier getIdentifier​(IPluginContribution contribution)
      Return the identifier that maps to the given contribution.
      static java.util.Set<java.lang.String> getPartiallyEnabledCategories​(IActivityManager activityManager)
      Return the set of partially enabled categories.
      static java.util.Set<java.lang.String> getRequiredActivityIds​(java.lang.String activityId)
      Return the activities required for this activity.
      static boolean isEnabled​(IActivityManager activityManager, java.lang.String categoryId)
      Returns whether the given category is enabled.
      static boolean isFiltering()
      Returns whether the UI is set up to filter contributions.
      static boolean isPartiallyEnabled​(IActivityManager activityManager, java.lang.String categoryId)
      Returns whether the given category is partially enabled.
      static ICategory[] resolveCategories​(IMutableActivityManager activityManager, java.util.Set<java.lang.String> categoryIds)
      Resolve the collection of category ids to an array of ICategory objects.
      static java.lang.Object[] restrictArray​(java.lang.Object[] array)
      Returns an array with those objects of the argument array that pass the restrictUseOf(Object) test.
      static <T> java.util.Collection<T> restrictCollection​(java.util.Collection<T> toBeFiltered, java.util.Collection<T> result)
      Fills and returns the second argument with those objects of the first argument that pass the restrictUseOf(Object) test.
      static boolean restrictUseOf​(java.lang.Object object)
      Restrict the use of the object only if it is matched by an activity with a core expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRIGGER_PRE_UI_POINT

        public static final java.lang.String TRIGGER_PRE_UI_POINT
        The ID of the trigger point that only returns activities with core expressions.
        Since:
        3.4
        See Also:
        Constant Field Values
    • Method Detail

      • getIdentifier

        public static IIdentifier getIdentifier​(IPluginContribution contribution)
        Return the identifier that maps to the given contribution.
        Parameters:
        contribution - the contribution
        Returns:
        the identifier
        Since:
        3.1
      • allowUseOf

        @Deprecated
        public static boolean allowUseOf​(java.lang.Object object)
        Deprecated.
        Answers whether a given contribution is allowed to be used based on activity enablement. If it is currently disabled, then a dialog is opened and the user is prompted to activate the required activities. If the user declines their activation then false is returned. In all other cases true is returned.
        Parameters:
        object - the contribution to test.
        Returns:
        whether the contribution is allowed to be used based on activity enablement.
        See Also:
        allowUseOf(ITriggerPoint, Object)
      • allowUseOf

        public static boolean allowUseOf​(ITriggerPoint triggerPoint,
                                         java.lang.Object object)
        Answers whether a given contribution is allowed to be used based on activity enablement. If it is currently disabled, then a dialog is opened and the user is prompted to activate the required activities. If the user declines their activation then false is returned. In all other cases true is returned.
        Parameters:
        triggerPoint - the trigger point being hit
        object - the contribution to test.
        Returns:
        whether the contribution is allowed to be used based on activity enablement.
      • restrictUseOf

        public static boolean restrictUseOf​(java.lang.Object object)
        Restrict the use of the object only if it is matched by an activity with a core expression. A normal disabled activity will not restrict the use of this object.
        Parameters:
        object - the object to restrict
        Returns:
        true if this object is matched by a disabled activity with an expression.
        Since:
        3.4
      • createUnifiedId

        public static java.lang.String createUnifiedId​(IPluginContribution contribution)
        Utility method to create a String containing the plugin and extension ids of a contribution. This will have the form
         pluginId / extensionId
         
        . If the IPluginContribution does not define a plugin id then the extension id alone is returned.
        Parameters:
        contribution - the contribution to use
        Returns:
        the unified id
      • filterItem

        public static boolean filterItem​(java.lang.Object object)
        Answers whether the provided object should be filtered from the UI based on activity state. Returns false except when the object is an instance of IPluginContribution whos unified id matches an IIdentifier that is currently disabled.
        Parameters:
        object - the object to test
        Returns:
        whether the object should be filtered
        See Also:
        createUnifiedId(IPluginContribution)
      • isFiltering

        public static boolean isFiltering()
        Returns whether the UI is set up to filter contributions. This is the case if there are defined activities.
        Returns:
        whether the UI is set up to filter contributions
      • getEnabledCategories

        public static java.util.Set<java.lang.String> getEnabledCategories​(IActivityManager activityManager,
                                                                           java.lang.String categoryId)
        Return a list of category ids that will become implicity enabled if the given category becomes enabled Note that the set returned by this set represents the delta of categories that would be enabled - if the category is already enabled then it is omitted.
        Parameters:
        activityManager - the activity manager to test against
        categoryId - the category to be enabled
        Returns:
        a list of category ids that will become implicity enabled if the given category becomes enabled
        Since:
        3.1
      • expandActivityDependencies

        public static java.util.Set<java.lang.String> expandActivityDependencies​(java.util.Set<java.lang.String> baseActivities)
        Return the expanded activities for the given activity set. This will resolve all activity requirement bindings.
        Parameters:
        baseActivities - the set of activities to expand
        Returns:
        the expanded activities
        Since:
        3.1
      • getRequiredActivityIds

        public static java.util.Set<java.lang.String> getRequiredActivityIds​(java.lang.String activityId)
        Return the activities required for this activity.
        Parameters:
        activityId - the activity id
        Returns:
        the activities required for this activity
        Since:
        3.1
      • getActivityIdsForCategory

        public static java.util.Set<java.lang.String> getActivityIdsForCategory​(ICategory category)
        Return the activities directly required by a given category.
        Parameters:
        category - the category
        Returns:
        the activities directly required by a given category
        Since:
        3.1
      • getDisabledCategories

        public static java.util.Set<java.lang.String> getDisabledCategories​(IActivityManager activityManager,
                                                                            java.lang.String categoryId)
        Return a list of category ids that will become implicity disabled if the given category becomes disabled Note that the set returned by this set represents the delta of categories that would be enabled - if the category is already enabled then it is omitted.
        Parameters:
        activityManager - the activity manager to test against
        categoryId - the category to be enabled
        Returns:
        a list of category ids that will become implicity enabled if the given category becomes enabled
        Since:
        3.1
      • getContainedCategories

        public static java.util.Set<java.lang.String> getContainedCategories​(IActivityManager activityManager,
                                                                             java.lang.String categoryId)
        Return a list of category ids that are implicitly contained within the given category.
        Parameters:
        activityManager - the activity manager to test agaisnt
        categoryId - the category to be enabled
        Returns:
        a list of category ids that will become implicity enabled if the given category becomes enabled
        Since:
        3.1
      • getEnabledCategories

        public static java.util.Set<java.lang.String> getEnabledCategories​(IActivityManager activityManager)
        Return the set of enabled categories. An enabled category is one in which all contained activities are enabled.
        Parameters:
        activityManager - the activity manager to test against
        Returns:
        the set of enabled categories.
        Since:
        3.1
      • getPartiallyEnabledCategories

        public static java.util.Set<java.lang.String> getPartiallyEnabledCategories​(IActivityManager activityManager)
        Return the set of partially enabled categories.
        Parameters:
        activityManager - the activity manager to test against
        Returns:
        the set of partially enabled categories
        Since:
        3.2
      • isPartiallyEnabled

        public static boolean isPartiallyEnabled​(IActivityManager activityManager,
                                                 java.lang.String categoryId)
        Returns whether the given category is partially enabled. A partially enabled category is one in which the number of enabled activites is both non-zero and less than the total number of activities in the category.
        Parameters:
        activityManager - the activity manager to test against
        categoryId - the category id
        Returns:
        whether the category is enabled
        Since:
        3.2
      • getEnabledCategoriesForActivity

        public static java.util.Set<java.lang.String> getEnabledCategoriesForActivity​(IActivityManager activityManager,
                                                                                      java.lang.String activityId)
        Return the number of enabled categories that this activity belongs to.
        Parameters:
        activityManager - the activity manager to test against *
        activityId - the activity id to query on
        Returns:
        the set of enabled category ids that this activity belongs to
        Since:
        3.1
      • isEnabled

        public static boolean isEnabled​(IActivityManager activityManager,
                                        java.lang.String categoryId)
        Returns whether the given category is enabled. A category is enabled if all of its activities are enabled.
        Parameters:
        activityManager - the activity manager to test against
        categoryId - the category id
        Returns:
        whether the category is enabled
        Since:
        3.1
      • resolveCategories

        public static ICategory[] resolveCategories​(IMutableActivityManager activityManager,
                                                    java.util.Set<java.lang.String> categoryIds)
        Resolve the collection of category ids to an array of ICategory objects.
        Parameters:
        activityManager - the activity manager to test against
        categoryIds - the category ids
        Returns:
        the array of category ids resolved to ICategory objects
        Since:
        3.1
      • restrictCollection

        public static <T> java.util.Collection<T> restrictCollection​(java.util.Collection<T> toBeFiltered,
                                                                     java.util.Collection<T> result)
        Fills and returns the second argument with those objects of the first argument that pass the restrictUseOf(Object) test.
        Parameters:
        toBeFiltered - the input collection
        result - the collection to which objects passing the test should be added
        Returns:
        the result collection for convenience
        Since:
        3.4
      • restrictArray

        public static java.lang.Object[] restrictArray​(java.lang.Object[] array)
        Returns an array with those objects of the argument array that pass the restrictUseOf(Object) test.
        Parameters:
        array - the input array
        Returns:
        a new array of the same type as the argument array, containing objects that pass the test
        Since:
        3.4
      • filterCollection

        public static <T> java.util.Collection<T> filterCollection​(java.util.Collection<T> toBeFiltered,
                                                                   java.util.Collection<T> result)
        Fills and returns the second argument with those objects of the first argument that pass the filterItem(Object) test.
        Parameters:
        toBeFiltered - the input collection
        result - the collection to which objects passing the test should be added
        Returns:
        the result collection for convenience
        Since:
        3.4
      • filterArray

        public static java.lang.Object[] filterArray​(java.lang.Object[] array)
        Returns an array with those objects of the argument array that pass the filterItem(Object) test.
        Parameters:
        array - the input array
        Returns:
        a new array of the same type as the argument array, containing objects that pass the test
        Since:
        3.4