Bug 305586 [Model] Model tweaking round 3
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 df0e72e..5da8edf 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
@@ -2007,7 +2007,7 @@ IPerspectiveFactory factory = ((PerspectiveDescriptor) perspective).createFactory(); // use a new perspective since we're only interested in // shortcuts here, see bug 305918 - modelLayout = new ModeledPageLayout(application, modelService, + modelLayout = new ModeledPageLayout(application, modelService, partService, AdvancedFactoryImpl.eINSTANCE.createPerspective(), perspective, this, false); factory.createInitialLayout(modelLayout); @@ -2025,7 +2025,8 @@ // instantiate the perspective IPerspectiveFactory factory = ((PerspectiveDescriptor) perspective).createFactory(); - modelLayout = new ModeledPageLayout(application, modelService, modelPerspective, + modelLayout = new ModeledPageLayout(application, modelService, partService, + modelPerspective, perspective, this, true); factory.createInitialLayout(modelLayout); tagPerspective(modelPerspective);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java index 1cb736c..330e839 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java
@@ -25,6 +25,7 @@ public void addView(String viewId) { MPart viewModel = ModeledPageLayout.createViewModel(application, viewId, true, layout.page, + layout.partService, layout.createReferences); folderModel.getChildren().add(viewModel); }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java index 9fb8457..5b735e8 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
@@ -24,8 +24,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl; import org.eclipse.e4.workbench.modeling.EModelService; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.e4.workbench.modeling.EPartService; import org.eclipse.swt.SWT; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; @@ -38,6 +37,7 @@ private MApplication application; private EModelService modelService; + EPartService partService; WorkbenchPage page; private MPerspective perspModel; private IPerspectiveDescriptor descriptor; @@ -53,10 +53,12 @@ boolean createReferences; public ModeledPageLayout(MApplication application, EModelService modelService, + EPartService partService, MPerspective perspModel, IPerspectiveDescriptor descriptor, WorkbenchPage page, boolean createReferences) { this.application = application; this.modelService = modelService; + this.partService = partService; this.page = page; // Create the editor area stack this.perspModel = perspModel; @@ -225,10 +227,10 @@ } public static MPart createViewModel(MApplication application, String id, boolean visible, - WorkbenchPage page, boolean createReferences) { + WorkbenchPage page, EPartService partService, boolean createReferences) { for (MPartDescriptor descriptor : application.getDescriptors()) { if (descriptor.getElementId().equals(id)) { - MPart part = (MPart) EcoreUtil.copy((EObject) descriptor); + MPart part = (MPart) partService.createPart(id); part.setToBeRendered(visible); // there should only be view references for views that are // visible to the end user, that is, the tab items are being @@ -259,7 +261,8 @@ refModel = refModel.getParent(); } - MPart viewModel = createViewModel(application, viewId, visible, page, createReferences); + MPart viewModel = createViewModel(application, viewId, visible, page, partService, + createReferences); if (withStack) { String stackId = viewId + "MStack"; // Default id...basically unusable //$NON-NLS-1$
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java index a463a6f..5333fd2 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java
@@ -31,7 +31,7 @@ public void addPlaceholder(String viewId) { MPart viewModel = ModeledPageLayout.createViewModel(application, viewId, false, - layout.page, layout.createReferences); + layout.page, layout.partService, layout.createReferences); folderModel.getChildren().add(viewModel); }