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;
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations