aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Berger2014-02-11 11:04:03 (EST)
committerGerrit Code Review @ Eclipse.org2014-02-13 10:59:47 (EST)
commitb07e1de7fb6b4522463e119c303dac877dfeea20 (patch)
tree4acd5c0f5de75ec9962ad96f058ab4014e68b650
parentc42d61dbe5ead0fa4bb0f1fc60267d9003ff00d1 (diff)
downloadeclipse.platform.ui-b07e1de7fb6b4522463e119c303dac877dfeea20.zip
eclipse.platform.ui-b07e1de7fb6b4522463e119c303dac877dfeea20.tar.gz
eclipse.platform.ui-b07e1de7fb6b4522463e119c303dac877dfeea20.tar.bz2
Bug 426345 - View shortcuts not working in E4 viewrefs/changes/17/21817/5
Change-Id: I92740bbd81e0b9e64c0e3d9af70e1793759ccbeb Signed-off-by: David Berger <david.berger@logicals.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/E4PartWrapper.java41
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java30
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java49
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java6
4 files changed, 80 insertions, 46 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/E4PartWrapper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/E4PartWrapper.java
new file mode 100644
index 0000000..5b432d1
--- /dev/null
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/E4PartWrapper.java
@@ -0,0 +1,41 @@
+package org.eclipse.ui.internal;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+public class E4PartWrapper extends ViewPart {
+
+ public static final String E4_WRAPPER_KEY = "e4Wrapper"; //$NON-NLS-1$
+ MPart wrappedPart;
+
+ public E4PartWrapper(MPart part) {
+ wrappedPart = part;
+ setPartName(part.getLabel());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt
+ * .widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ if (wrappedPart.getObject() != null && wrappedPart.getContext() != null)
+ ContextInjectionFactory.invoke(wrappedPart.getObject(), Focus.class,
+ wrappedPart.getContext());
+ }
+}
+
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
index 46e684a..4816045 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
@@ -354,6 +354,21 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
Object clientObject = part.getObject();
if (clientObject instanceof CompatibilityPart) {
return ((CompatibilityPart) clientObject).getPart();
+ } else if (clientObject != null) {
+ if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) {
+ return (IWorkbenchPart) part.getTransientData().get(
+ E4PartWrapper.E4_WRAPPER_KEY);
+ }
+
+ ViewReference viewReference = getViewReference(part);
+ E4PartWrapper legacyPart = new E4PartWrapper(part);
+ try {
+ viewReference.initialize(legacyPart);
+ } catch (PartInitException e) {
+ WorkbenchPlugin.log(e);
+ }
+ part.getTransientData().put(E4PartWrapper.E4_WRAPPER_KEY, legacyPart);
+ return legacyPart;
}
}
return null;
@@ -2122,6 +2137,21 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
Object object = part.getObject();
if (object instanceof CompatibilityPart) {
return ((CompatibilityPart) object).getPart();
+ } else if (object != null) {
+ if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) {
+ return (IWorkbenchPart) part.getTransientData().get(
+ E4PartWrapper.E4_WRAPPER_KEY);
+ }
+
+ ViewReference viewReference = getViewReference(part);
+ E4PartWrapper legacyPart = new E4PartWrapper(part);
+ try {
+ viewReference.initialize(legacyPart);
+ } catch (PartInitException e) {
+ WorkbenchPlugin.log(e);
+ }
+ part.getTransientData().put(E4PartWrapper.E4_WRAPPER_KEY, legacyPart);
+ return legacyPart;
}
}
return null;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
index 00c5848..62e50fc 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
@@ -17,10 +17,8 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
-import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.IPresentationEngine;
import org.eclipse.e4.ui.workbench.UIEvents;
@@ -30,7 +28,6 @@ import org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISaveablePart;
@@ -48,7 +45,6 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.e4.compatibility.CompatibilityPart;
import org.eclipse.ui.internal.misc.UIListenerLogging;
import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.part.ViewPart;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
@@ -57,11 +53,6 @@ import org.osgi.service.event.EventHandler;
*/
public abstract class WorkbenchPartReference implements IWorkbenchPartReference, ISizeProvider {
- /**
- *
- */
- private static final String E4_WRAPPER_KEY = "e4Wrapper"; //$NON-NLS-1$
-
/**
* Internal property ID: Indicates that the underlying part was created
*/
@@ -163,36 +154,6 @@ public abstract class WorkbenchPartReference implements IWorkbenchPartReference,
}
};
- class E4PartWrapper extends ViewPart {
- MPart wrappedPart;
-
- E4PartWrapper(MPart part) {
- wrappedPart = part;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt
- * .widgets.Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
- @Override
- public void setFocus() {
- if (part.getObject() != null && part.getContext() != null)
- ContextInjectionFactory.invoke(part.getObject(), Focus.class, part.getContext());
- }
-
- }
private IWorkbenchPage page;
private MPart part;
@@ -452,14 +413,10 @@ public abstract class WorkbenchPartReference implements IWorkbenchPartReference,
legacyPart = compatibilityPart.getPart();
}
} else if (part.getObject() != null) {
- if (part.getTransientData().get(E4_WRAPPER_KEY) instanceof E4PartWrapper) {
- legacyPart = (IWorkbenchPart) part.getTransientData().get(E4_WRAPPER_KEY);
- } else {
- legacyPart = new E4PartWrapper(part);
- part.getTransientData().put(E4_WRAPPER_KEY, legacyPart);
+ if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) {
+ return (IWorkbenchPart) part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY);
}
-
- }
+ }
}
return legacyPart;
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 a51e044..8372f0c 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
@@ -34,6 +34,7 @@ import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.internal.E4PartWrapper;
import org.eclipse.ui.internal.WorkbenchPage;
public class SelectionService implements ISelectionChangedListener, ISelectionService {
@@ -130,6 +131,11 @@ public class SelectionService implements ISelectionChangedListener, ISelectionSe
if (client instanceof CompatibilityPart) {
IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart();
activePart = workbenchPart;
+ } else if (client != null) {
+ if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) {
+ activePart = (IWorkbenchPart) part.getTransientData().get(
+ E4PartWrapper.E4_WRAPPER_KEY);
+ }
}
}
}