Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench;singleton:=true
Bundle-Version: 1.16.0.qualifier
Bundle-Version: 1.16.100.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
Expand All @@ -35,7 +36,7 @@
public class ApplicationPartServiceImpl implements EPartService {

private static final Supplier<RuntimeException> NO_VALID_PARTSERVICE = () -> new IllegalStateException(
"No valid PartService can be aquired from the current context"); //$NON-NLS-1$
"No valid PartService can be acquired from the current context"); //$NON-NLS-1$

private MApplication application;

Expand All @@ -50,15 +51,17 @@ public class ApplicationPartServiceImpl implements EPartService {
private Optional<EPartService> getActiveWindowService() {
IEclipseContext activeWindowContext = application.getContext().getActiveChild();
if (activeWindowContext == null) {
throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$
// in this case the application has no focus so we can't determine the active
// child.
return Optional.empty();
}
EPartService activeWindowPartService = activeWindowContext.get(EPartService.class);
if (activeWindowPartService == null) {
throw new IllegalStateException("Active window context is invalid"); //$NON-NLS-1$
}
if (activeWindowPartService == this) {
// in this cas we would run into an infinite recursion, so from the current
// active window we can't aquire another part service
// in this case we would run into an infinite recursion, so from the current
// active window we can't acquire another part service
return Optional.empty();
}
return Optional.of(activeWindowPartService);
Expand All @@ -68,10 +71,20 @@ private Optional<EPartService> getActiveWindowService(MPart part) {
return getActiveWindowService().or(() -> {
IEclipseContext context = part.getContext();
if (context != null) {
// First try the context of the part
EPartService partService = context.get(EPartService.class);
if (partService instanceof PartServiceImpl) {
return Optional.of(partService);
}
// Otherwise use the context of the contained window
MWindow window = modelService.getTopLevelWindowFor(part);
if (window != null) {
IEclipseContext windowContext = window.getContext();
EPartService windowPartService = windowContext.get(EPartService.class);
if (windowPartService instanceof PartServiceImpl) {
return Optional.of(windowPartService);
}
}
}
return Optional.empty();
});
Expand Down
Loading