Skip to content

Commit f14bb25

Browse files
akurtakovMailaender
authored andcommitted
Create Demo MPart using EModelService
That way the MPart has access to the context and is autoattached to it. It is done manually after creation here thus this is more of a safety net in case the model specifies smth that is not done manually here.
1 parent 66722f6 commit f14bb25

File tree

1 file changed

+3
-4
lines changed
  • chemclipse/plugins/org.eclipse.chemclipse.ux.extension.ui/src/org/eclipse/chemclipse/ux/extension/ui/views

1 file changed

+3
-4
lines changed

chemclipse/plugins/org.eclipse.chemclipse.ux.extension.ui/src/org/eclipse/chemclipse/ux/extension/ui/views/DemoWelcomeTile.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.eclipse.chemclipse.ux.extension.ui.definitions.IWelcomeTileDefinition;
3333
import org.eclipse.e4.core.di.annotations.Execute;
3434
import org.eclipse.e4.ui.model.application.MApplication;
35-
import org.eclipse.e4.ui.model.application.ui.basic.MBasicFactory;
3635
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
3736
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
3837
import org.eclipse.e4.ui.workbench.modeling.EModelService;
@@ -72,7 +71,7 @@ public void handleEvent(EModelService modelService, MApplication application, EP
7271

7372
try {
7473
if(chromatogramFile != null && chromatogramFile.exists()) {
75-
MPart part = createChromatogramPart();
74+
MPart part = createChromatogramPart(modelService);
7675
part.setLabel("DemoChromatogram.ocb");
7776
Map<String, Object> map = new HashMap<>();
7877
map.put(EditorSupport.MAP_FILE, chromatogramFile.getAbsolutePath());
@@ -103,12 +102,12 @@ void showEditorPart(MPart part, EModelService modelService, MApplication applica
103102
partService.showPart(part, PartState.ACTIVATE);
104103
}
105104

106-
MPart createChromatogramPart() {
105+
MPart createChromatogramPart(EModelService modelService) {
107106

108107
/*
109108
* Create the input part and prepare it.
110109
*/
111-
MPart part = MBasicFactory.INSTANCE.createPart();
110+
MPart part = modelService.createModelElement(MPart.class);
112111
part.setElementId("org.eclipse.chemclipse.ux.extension.xxd.ui.part.chromatogramEditorMSD");
113112
part.setContributionURI("bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.editors.ChromatogramEditorMSD");
114113
part.setIconURI(ApplicationImageFactory.getInstance().getURI(IApplicationImage.IMAGE_CHROMATOGRAM, IApplicationImageProvider.SIZE_16x16));

0 commit comments

Comments
 (0)