diff options
| author | Oleg Besedin | 2012-05-11 17:38:20 +0000 |
|---|---|---|
| committer | Oleg Besedin | 2012-05-11 17:39:27 +0000 |
| commit | b43745bc68a74fe2a0812304305362fd7b58883e (patch) | |
| tree | 995596efe614107b3abe2101c7716bfaea5006a1 | |
| parent | bf34877735a3f25e9afa1ab0330960641accca1d (diff) | |
| download | eclipse.platform.ui-b43745bc68a74fe2a0812304305362fd7b58883e.tar.gz eclipse.platform.ui-b43745bc68a74fe2a0812304305362fd7b58883e.tar.xz eclipse.platform.ui-b43745bc68a74fe2a0812304305362fd7b58883e.zip | |
Bug 375741 - intermittent problems with context menu visibility etc.v20120511-1739
2 files changed, 42 insertions, 28 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java index 7d60aa493a9..6dac921de3f 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java @@ -28,6 +28,11 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; import org.eclipse.e4.ui.workbench.IPresentationEngine; import org.eclipse.e4.ui.workbench.UIEvents; +import org.eclipse.e4.ui.workbench.modeling.ESelectionService; +import org.eclipse.jface.viewers.IPostSelectionProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; @@ -53,7 +58,7 @@ import org.eclipse.ui.internal.util.Util; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; -public abstract class CompatibilityPart { +public abstract class CompatibilityPart implements ISelectionChangedListener { public static final String COMPATIBILITY_EDITOR_URI = "bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor"; //$NON-NLS-1$ @@ -151,6 +156,19 @@ public abstract class CompatibilityPart { WorkbenchPlugin.log("Unable to initialize error part", ex.getStatus()); //$NON-NLS-1$ } } + + IWorkbenchPartSite site = legacyPart.getSite(); + if (site != null) { + ISelectionProvider selectionProvider = site.getSelectionProvider(); + if (selectionProvider != null) { + selectionProvider.addSelectionChangedListener(this); + + if (selectionProvider instanceof IPostSelectionProvider) { + ((IPostSelectionProvider) selectionProvider) + .addPostSelectionChangedListener(this); + } + } + } return true; } @@ -168,6 +186,21 @@ public abstract class CompatibilityPart { } private void invalidate() { + if (wrapped != null) { + IWorkbenchPartSite site = wrapped.getSite(); + if (site != null) { + ISelectionProvider selectionProvider = site.getSelectionProvider(); + if (selectionProvider != null) { + selectionProvider.removeSelectionChangedListener(this); + + if (selectionProvider instanceof IPostSelectionProvider) { + ((IPostSelectionProvider) selectionProvider) + .removePostSelectionChangedListener(this); + } + } + } + } + WorkbenchPartReference reference = getReference(); reference.invalidate(); @@ -380,4 +413,10 @@ public abstract class CompatibilityPart { public MPart getModel() { return part; } + + public void selectionChanged(SelectionChangedEvent e) { + ESelectionService selectionService = (ESelectionService) part.getContext().get( + ESelectionService.class.getName()); + selectionService.setSelection(e.getSelection()); + } } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java index 58f7dd1bb4f..f433fd841c9 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 IBM Corporation and others. + * Copyright (c) 2010, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,6 @@ import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; -import org.eclipse.jface.viewers.IPostSelectionProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; @@ -113,35 +112,11 @@ public class SelectionService implements ISelectionChangedListener, ISelectionSe @Inject void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) final MPart part) { - if (activePart != null) { - ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider(); - if (selectionProvider != null) { - selectionProvider.removeSelectionChangedListener(this); - - if (selectionProvider instanceof IPostSelectionProvider) { - ((IPostSelectionProvider) selectionProvider) - .removePostSelectionChangedListener(this); - } - } - activePart = null; - } - + activePart = null; if (part != null) { Object client = part.getObject(); if (client instanceof CompatibilityPart) { IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart(); - - ISelectionProvider selectionProvider = workbenchPart.getSite() - .getSelectionProvider(); - if (selectionProvider != null) { - selectionProvider.addSelectionChangedListener(this); - - if (selectionProvider instanceof IPostSelectionProvider) { - ((IPostSelectionProvider) selectionProvider) - .addPostSelectionChangedListener(this); - } - } - activePart = workbenchPart; } } |
