Search in sources :

Example 1 with IWorkbenchActivitySupport

use of org.eclipse.ui.activities.IWorkbenchActivitySupport in project eclipse.platform.ui by eclipse-platform.

the class ActivityPropertyTester method isActivityEnabled.

private static boolean isActivityEnabled(String activityId, IWorkbench workbench) {
    try {
        IWorkbenchActivitySupport workbenchActivitySupport = workbench.getActivitySupport();
        IActivityManager activityManager = workbenchActivitySupport.getActivityManager();
        return activityManager.getActivity(activityId).isEnabled();
    } catch (Exception e) {
    // workbench not yet activated; nothing enabled yet
    }
    return false;
}
Also used : IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport) IActivityManager(org.eclipse.ui.activities.IActivityManager)

Example 2 with IWorkbenchActivitySupport

use of org.eclipse.ui.activities.IWorkbenchActivitySupport in project eclipse.platform.ui by eclipse-platform.

the class ActivityPropertyTester method isCategoryEnabled.

private static boolean isCategoryEnabled(String categoryId, IWorkbench workbench) {
    try {
        IWorkbenchActivitySupport workbenchActivitySupport = workbench.getActivitySupport();
        IActivityManager activityManager = workbenchActivitySupport.getActivityManager();
        return WorkbenchActivityHelper.isEnabled(activityManager, categoryId);
    } catch (Exception e) {
    // workbench not yet activated; nothing enabled yet
    }
    return false;
}
Also used : IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport) IActivityManager(org.eclipse.ui.activities.IActivityManager)

Example 3 with IWorkbenchActivitySupport

use of org.eclipse.ui.activities.IWorkbenchActivitySupport in project eclipse.platform.ui by eclipse-platform.

the class IDEWorkbenchActivityHelper method runPendingUpdates.

/**
 * Drain the queue and consult the helper.
 */
protected void runPendingUpdates() {
    String[] ids = null;
    synchronized (lock) {
        ids = fPendingNatureUpdates.toArray(new String[fPendingNatureUpdates.size()]);
        fPendingNatureUpdates.clear();
    }
    IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI.getWorkbench().getActivitySupport();
    for (String id : ids) {
        final IPluginContribution contribution = natureMap.get(id);
        if (contribution == null) {
            // bad nature ID.
            continue;
        }
        final ITriggerPoint triggerPoint = workbenchActivitySupport.getTriggerPointManager().getTriggerPoint(NATURE_POINT);
        // consult the advisor - if the activities need enabling, they will
        // be
        WorkbenchActivityHelper.allowUseOf(triggerPoint, contribution);
    }
}
Also used : IPluginContribution(org.eclipse.ui.IPluginContribution) ITriggerPoint(org.eclipse.ui.activities.ITriggerPoint) IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport)

Example 4 with IWorkbenchActivitySupport

use of org.eclipse.ui.activities.IWorkbenchActivitySupport in project eclipse.platform.ui by eclipse-platform.

the class PluginActionContributionItem method getIdentifier.

/**
 * Create the IIdentifier reference for this item.
 *
 * @since 3.0
 */
private IIdentifier getIdentifier() {
    if (!WorkbenchActivityHelper.isFiltering()) {
        return null;
    }
    if (identifier == null) {
        IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI.getWorkbench().getActivitySupport();
        IPluginContribution contribution = (IPluginContribution) getAction();
        // no need to check if contribution.getPluginId() == null - plugin
        // actions are always from plugins.
        identifier = workbenchActivitySupport.getActivityManager().getIdentifier(WorkbenchActivityHelper.createUnifiedId(contribution));
    }
    return identifier;
}
Also used : IPluginContribution(org.eclipse.ui.IPluginContribution) IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport)

Example 5 with IWorkbenchActivitySupport

use of org.eclipse.ui.activities.IWorkbenchActivitySupport in project eclipse.platform.ui by eclipse-platform.

the class ActivityPersistanceHelper method loadEnabledStates.

/**
 * Load the enabled states for the given activity IDs.
 *
 * @param previouslyEnabledActivities the activity states to maintain. This set
 *                                    must be writabe.
 * @param activityIdsToProcess        the activity ids to process
 */
protected void loadEnabledStates(Set<String> previouslyEnabledActivities, Set<String> activityIdsToProcess) {
    if (activityIdsToProcess.isEmpty()) {
        return;
    }
    Set<String> enabledActivities = new HashSet<>(previouslyEnabledActivities);
    IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
    IWorkbenchActivitySupport support = PlatformUI.getWorkbench().getActivitySupport();
    IActivityManager activityManager = support.getActivityManager();
    for (String activityId : activityIdsToProcess) {
        String preferenceKey = createPreferenceKey(activityId);
        try {
            IActivity activity = activityManager.getActivity(activityId);
            if (activity.getExpression() != null) {
                continue;
            }
            if ("".equals(store.getDefaultString(preferenceKey))) {
                // $NON-NLS-1$ // no override has been provided
                // in the customization file
                // the default should be whatever the XML specifies
                store.setDefault(preferenceKey, activity.isDefaultEnabled());
            }
        } catch (NotDefinedException e) {
        // can't happen - we're iterating over defined activities
        }
        if (store.getBoolean(preferenceKey)) {
            enabledActivities.add(activityId);
        } else {
            enabledActivities.remove(activityId);
        }
    }
    support.setEnabledActivityIds(enabledActivities);
}
Also used : IActivity(org.eclipse.ui.activities.IActivity) NotDefinedException(org.eclipse.ui.activities.NotDefinedException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) HashSet(java.util.HashSet) IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport) IActivityManager(org.eclipse.ui.activities.IActivityManager)

Aggregations

IWorkbenchActivitySupport (org.eclipse.ui.activities.IWorkbenchActivitySupport)23 HashSet (java.util.HashSet)10 IActivityManager (org.eclipse.ui.activities.IActivityManager)10 Test (org.junit.Test)9 IPluginContribution (org.eclipse.ui.IPluginContribution)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IActivity (org.eclipse.ui.activities.IActivity)4 IIdentifier (org.eclipse.ui.activities.IIdentifier)4 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)2 MenuManager (org.eclipse.jface.action.MenuManager)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 ICategory (org.eclipse.ui.activities.ICategory)2 NotDefinedException (org.eclipse.ui.activities.NotDefinedException)2 IEvaluationService (org.eclipse.ui.services.IEvaluationService)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1