Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2016-07-27 19:35:29 +0000
committerBrian de Alwis2016-07-28 13:20:47 +0000
commit56bfbcc4dcddb8871aeca7cbe893036ce38e59c1 (patch)
tree8bbb22b4ed1c874827463d5e89d30b70d45327d9
parent0768b535f775175bb38fb885952b27e11f6522fc (diff)
downloadeclipse.platform.ui-56bfbcc4dcddb8871aeca7cbe893036ce38e59c1.tar.gz
eclipse.platform.ui-56bfbcc4dcddb8871aeca7cbe893036ce38e59c1.tar.xz
eclipse.platform.ui-56bfbcc4dcddb8871aeca7cbe893036ce38e59c1.zip
Bug 462610 - ApplicationPartServiceImpl#findPart violates contract by throwing IllegalStateExceptionY20160728-1000
Move EPartService#createPart(MPartDescriptor) to EModelService to allow creating an MPart from an MPartDescriptor. Change-Id: I3b66f5b9d0e3996ff308dedf8cdfbe8816c70b88
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java26
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java37
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java12
3 files changed, 44 insertions, 31 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
index 168ed0b1637..a97372ca376 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
@@ -1046,6 +1046,32 @@ public class ModelServiceImpl implements EModelService {
}
@Override
+ public MPart createPart(MPartDescriptor descriptor) {
+ if (descriptor == null) {
+ return null;
+ }
+ MPart part = createModelElement(MPart.class);
+ part.setElementId(descriptor.getElementId());
+ part.getMenus().addAll(EcoreUtil.copyAll(descriptor.getMenus()));
+ if (descriptor.getToolbar() != null) {
+ part.setToolbar((MToolBar) EcoreUtil.copy((EObject) descriptor.getToolbar()));
+ }
+ part.setContributorURI(descriptor.getContributorURI());
+ part.setCloseable(descriptor.isCloseable());
+ part.setContributionURI(descriptor.getContributionURI());
+ part.setLabel(descriptor.getLabel());
+ part.setIconURI(descriptor.getIconURI());
+ part.setTooltip(descriptor.getTooltip());
+ part.getHandlers().addAll(EcoreUtil.copyAll(descriptor.getHandlers()));
+ part.getTags().addAll(descriptor.getTags());
+ part.getVariables().addAll(descriptor.getVariables());
+ part.getProperties().putAll(descriptor.getProperties());
+ part.getPersistedState().putAll(descriptor.getPersistedState());
+ part.getBindingContexts().addAll(descriptor.getBindingContexts());
+ return part;
+ }
+
+ @Override
public void hideLocalPlaceholders(MWindow window, MPerspective perspective) {
List<MPlaceholder> globals = findElements(window, null, MPlaceholder.class, null,
OUTSIDE_PERSPECTIVE | IN_SHARED_AREA);
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
index 69d65446bce..7ecab325462 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
@@ -50,7 +50,6 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
import org.eclipse.e4.ui.services.EContextService;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.IPresentationEngine;
@@ -59,12 +58,13 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.IPartListener;
import org.eclipse.e4.ui.workbench.modeling.ISaveHandler;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.osgi.util.NLS;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+/**
+ * A window-based {@link EPartService}.
+ */
public class PartServiceImpl implements EPartService {
/**
@@ -818,35 +818,10 @@ public class PartServiceImpl implements EPartService {
return activePart;
}
- private MPart createPart(MPartDescriptor descriptor) {
- if (descriptor == null) {
- return null;
- }
- MPart part = modelService.createModelElement(MPart.class);
- part.setElementId(descriptor.getElementId());
- part.getMenus().addAll(EcoreUtil.copyAll(descriptor.getMenus()));
- if (descriptor.getToolbar() != null) {
- part.setToolbar((MToolBar) EcoreUtil.copy((EObject) descriptor.getToolbar()));
- }
- part.setContributorURI(descriptor.getContributorURI());
- part.setCloseable(descriptor.isCloseable());
- part.setContributionURI(descriptor.getContributionURI());
- part.setLabel(descriptor.getLabel());
- part.setIconURI(descriptor.getIconURI());
- part.setTooltip(descriptor.getTooltip());
- part.getHandlers().addAll(EcoreUtil.copyAll(descriptor.getHandlers()));
- part.getTags().addAll(descriptor.getTags());
- part.getVariables().addAll(descriptor.getVariables());
- part.getProperties().putAll(descriptor.getProperties());
- part.getPersistedState().putAll(descriptor.getPersistedState());
- part.getBindingContexts().addAll(descriptor.getBindingContexts());
- return part;
- }
-
@Override
public MPart createPart(String id) {
MPartDescriptor descriptor = modelService.getPartDescriptor(id);
- return createPart(descriptor);
+ return modelService.createPart(descriptor);
}
@Override
@@ -872,7 +847,7 @@ public class PartServiceImpl implements EPartService {
if (sharedPart == null) {
MPartDescriptor descriptor = modelService.getPartDescriptor(id);
- sharedPart = createPart(descriptor);
+ sharedPart = modelService.createPart(descriptor);
if (sharedPart == null) {
return null;
}
@@ -1180,7 +1155,7 @@ public class PartServiceImpl implements EPartService {
MPart part = findPart(id);
if (part == null) {
MPartDescriptor descriptor = modelService.getPartDescriptor(id);
- part = createPart(descriptor);
+ part = modelService.createPart(descriptor);
if (part == null) {
return null;
}
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
index 9f693f0ffd4..31843e2ab77 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
@@ -22,6 +22,7 @@ import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.SideValue;
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.MPartSashContainerElement;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
@@ -508,6 +509,17 @@ public interface EModelService {
public MPartDescriptor getPartDescriptor(String id);
/**
+ * Creates a new part from the given descriptor.
+ *
+ * @param descriptor
+ * a part descriptor, must not be <code>null</code>
+ * @return a new part
+ * @see EPartService#createPart(String)
+ * @since 1.5
+ */
+ public MPart createPart(MPartDescriptor descriptor);
+
+ /**
* This method ensures that there will never be two placeholders for the same referenced element
* visible in the presentation at the same time. It does this by hiding placeholders which are
* contained in any MPerspective if there is a placeholder for the element in any 'shared' area

Back to the top