-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider Activity Filtering when running in E3 compatibility mode
Currently contributions by E4 are not filtered using the E3 activity mechanism as it is a pure E3 concept. To improve integration and interaction of E4 and E3 when using the compatibility layer this now installs a WorkbenchContributionFactory into the application context that additionally takes activity filtering of the E3 workbench into account. See #2217
- Loading branch information
1 parent
fe1c0be
commit accf339
Showing
7 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
....eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WorkbenchContributionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Christoph Läubrich and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.ui.internal; | ||
|
||
import org.eclipse.e4.core.contexts.IEclipseContext; | ||
import org.eclipse.e4.core.services.contributions.IContributionFactory; | ||
import org.eclipse.ui.activities.IIdentifier; | ||
import org.eclipse.ui.activities.IWorkbenchActivitySupport; | ||
import org.osgi.framework.Bundle; | ||
|
||
/** | ||
* Contribution factory that uses a delegate and additionally provides behavior | ||
* from the {@link Workbench} services. | ||
* | ||
*/ | ||
@SuppressWarnings("restriction") | ||
class WorkbenchContributionFactory implements IContributionFactory { | ||
|
||
private static final String BUNDLE_CLASS_PREFIX = "bundleclass://"; //$NON-NLS-1$ | ||
|
||
private final IContributionFactory delegate; | ||
|
||
private final IEclipseContext context; | ||
|
||
private IWorkbenchActivitySupport activitySupport; | ||
|
||
WorkbenchContributionFactory(Workbench workbench) { | ||
context = workbench.getApplication().getContext(); | ||
delegate = context.get(IContributionFactory.class); | ||
} | ||
|
||
@Override | ||
public Object create(String uriString, IEclipseContext context) { | ||
return delegate.create(uriString, context); | ||
} | ||
|
||
@Override | ||
public Object create(String uriString, IEclipseContext context, IEclipseContext staticContext) { | ||
return delegate.create(uriString, context, staticContext); | ||
} | ||
|
||
@Override | ||
public Bundle getBundle(String uriString) { | ||
return delegate.getBundle(uriString); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(String uriString) { | ||
if (uriString != null && uriString.startsWith(BUNDLE_CLASS_PREFIX)) { | ||
String identifierId = uriString.substring(BUNDLE_CLASS_PREFIX.length()); | ||
if (activitySupport == null) { | ||
activitySupport = context.get(IWorkbenchActivitySupport.class); | ||
} | ||
IIdentifier identifier = activitySupport.getActivityManager().getIdentifier(identifierId); | ||
if (!identifier.isEnabled()) { | ||
return false; | ||
} | ||
} | ||
return delegate.isEnabled(uriString); | ||
} | ||
|
||
} |