Bug 220663 [ActivityMgmt] Invalid thread access when activity is enabled
I couldn't find information about which events are supposed to be fired on any thread vs. on the UI thread. Kim, do you have a suggestion where the asyncExec should go? org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3716) at org.eclipse.swt.SWT.error(SWT.java:3634) at org.eclipse.swt.SWT.error(SWT.java:3605) at org.eclipse.swt.widgets.Widget.error(Widget.java:442) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:336) at org.eclipse.swt.widgets.Menu.getItems(Menu.java:832) at org.eclipse.jface.action.MenuManager.update(MenuManager.java:679) at org.eclipse.jface.action.MenuManager.update(MenuManager.java:638) at org.eclipse.ui.internal.menus.WorkbenchMenuService.updateManagers(WorkbenchMenuService.java:332) at org.eclipse.ui.internal.menus.WorkbenchMenuService.access$1(WorkbenchMenuService.java:327) at org.eclipse.ui.internal.menus.WorkbenchMenuService$3.activityManagerChanged(WorkbenchMenuService.java:294) at org.eclipse.ui.internal.activities.AbstractActivityManager.fireActivityManagerChanged(AbstractActivityManager.java:51) at org.eclipse.ui.internal.activities.ProxyActivityManager$1.activityManagerChanged(ProxyActivityManager.java:50) at org.eclipse.ui.internal.activities.AbstractActivityManager.fireActivityManagerChanged(AbstractActivityManager.java:51) at org.eclipse.ui.internal.activities.MutableActivityManager.setEnabledActivityIds(MutableActivityManager.java:535) at org.eclipse.ui.internal.activities.ws.WorkbenchActivitySupport.setEnabledActivityIds(WorkbenchActivitySupport.java:322) at org.eclipse.ui.activities.WorkbenchActivityHelper.enableActivities(WorkbenchActivityHelper.java:156) at org.eclipse.ui.activities.WorkbenchActivityHelper.allow(WorkbenchActivityHelper.java:120) at org.eclipse.ui.activities.WorkbenchActivityHelper.allowUseOf(WorkbenchActivityHelper.java:91) at org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper.processProject(IDEWorkbenchActivityHelper.java:202) at org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper$3.resourceChanged(IDEWorkbenchActivityHelper.java:165) at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:282) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:276) at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:148) at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:313) at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1022) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1809) at org.eclipse.team.core.variants.PersistantResourceVariantByteStore.run(PersistantResourceVariantByteStore.java:171) at org.eclipse.team.internal.core.subscribers.DescendantResourceVariantByteStore.run(DescendantResourceVariantByteStore.java:181) at org.eclipse.team.core.variants.ResourceVariantTree.collectChanges(ResourceVariantTree.java:110) at org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree.collectChanges(CVSResourceVariantTree.java:87) at org.eclipse.team.core.variants.AbstractResourceVariantTree.refresh(AbstractResourceVariantTree.java:90) at org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree.refresh(CVSResourceVariantTree.java:334) at org.eclipse.team.core.variants.AbstractResourceVariantTree.refresh(AbstractResourceVariantTree.java:54) at org.eclipse.team.core.variants.ResourceVariantTreeSubscriber.refresh(ResourceVariantTreeSubscriber.java:162) at org.eclipse.team.core.variants.ResourceVariantTreeSubscriber.refresh(ResourceVariantTreeSubscriber.java:126) at org.eclipse.team.core.subscribers.Subscriber.refresh(Subscriber.java:465) at org.eclipse.team.internal.ccvs.core.CVSWorkspaceSubscriber.refreshWithContentFetch(CVSWorkspaceSubscriber.java:434) at org.eclipse.team.internal.ccvs.ui.mappings.WorkspaceSubscriberContext.refresh(WorkspaceSubscriberContext.java:305) at org.eclipse.team.core.mapping.provider.SynchronizationContext.refresh(SynchronizationContext.java:109) at org.eclipse.team.internal.ui.synchronize.RefreshModelParticipantJob.doRefresh(RefreshModelParticipantJob.java:68) at org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.run(RefreshParticipantJob.java:309) at org.eclipse.team.internal.ui.synchronize.RefreshModelParticipantJob.run(RefreshModelParticipantJob.java:116) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchActivityHelper.java
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IRegistryChangeEvent;
import org.eclipse.core.runtime.IRegistryChangeListener;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.ITriggerPoint;
import org.eclipse.ui.activities.IWorkbenchActivitySupport;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
/**
 * Utility class that manages promotion of activites in response to workspace changes.
 * 
 * @since 3.0
 */
public class IDEWorkbenchActivityHelper {
    private static final String NATURE_POINT = "org.eclipse.ui.ide.natures"; 
    
    /**
     * Resource listener that reacts to new projects (and associated natures) 
     * coming into the workspace.
     */
    private IResourceChangeListener listener;
    /**
     * Mapping from composite nature ID to IPluginContribution.  Used for proper
     * activity mapping of natures.
     */
    private Map natureMap;
    /**
     * Singleton instance.
     */