Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2017-07-19 08:52:12 +0000
committerJuergen Haug2017-07-19 08:53:15 +0000
commit97d0301407cd01f6acdad6b063632aca17418c03 (patch)
treee408be31fb33f181eb1befe43d4d4d86bb948c91 /plugins
parente53af21ef530a7bd976c5a3d761bbca892c9fbfe (diff)
downloadorg.eclipse.etrice-97d0301407cd01f6acdad6b063632aca17418c03.tar.gz
org.eclipse.etrice-97d0301407cd01f6acdad6b063632aca17418c03.tar.xz
org.eclipse.etrice-97d0301407cd01f6acdad6b063632aca17418c03.zip
[ui] refactored ui.commands, added RoomOpeningHelper
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java4
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/BehaviorExporter.java20
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java6
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/RoomOpeningHelper.java82
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java26
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java11
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java48
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditStructureHandler.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/AbstractBaseDiagramTypeProvider.java22
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/DiagramExporter.java (renamed from plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramExporter.java)3
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/IBulkDiagramExporter.java21
-rw-r--r--plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java7
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java10
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java14
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java5
22 files changed, 217 insertions, 111 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
index 73c0ee1e4..fa38f2706 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/AbstractFSMDiagramTypeProvider.java
@@ -12,7 +12,7 @@
package org.eclipse.etrice.ui.behavior.fsm.editor;
-import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
+import org.eclipse.etrice.ui.common.base.editor.AbstractBaseDiagramTypeProvider;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.platform.IDiagramContainer;
@@ -21,7 +21,7 @@ import org.eclipse.graphiti.platform.IDiagramContainer;
* functionality provided by {@link AbstractFSMEditor}. Diagram editor plugins
* that extend {@link AbstractFSMEditor} should also extend and use this class.
*/
-public abstract class AbstractFSMDiagramTypeProvider extends AbstractDiagramTypeProvider {
+public abstract class AbstractFSMDiagramTypeProvider extends AbstractBaseDiagramTypeProvider {
/* (non-Javadoc)
* @see org.eclipse.graphiti.dt.AbstractDiagramTypeProvider#resourceReloaded(org.eclipse.graphiti.mm.pictograms.Diagram)
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/BehaviorExporter.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/BehaviorExporter.java
index 26e08296e..782b7a916 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/BehaviorExporter.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/editor/BehaviorExporter.java
@@ -14,31 +14,35 @@ package org.eclipse.etrice.ui.behavior.fsm.editor;
import java.io.File;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.core.fsm.fSM.State;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.ui.behavior.fsm.support.FSMSupportUtil;
-import org.eclipse.etrice.ui.common.base.editor.DiagramExporter;
+import org.eclipse.etrice.ui.common.base.export.DiagramExporter;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.ui.PlatformUI;
-import com.google.inject.Inject;
-
-public class BehaviorExporter {
+public class BehaviorExporter implements IBulkDiagramExporter {
private static final String SUFFIX = "_behavior";
- @Inject
private DiagramAccessBase da;
+
+ public BehaviorExporter(DiagramAccessBase da) {
+ this.da = da;
+ }
- public void export(ModelComponent mc, String folder) {
+ public void export(EObject roomClass, String folder) {
boolean wasOpen = false;
- AbstractFSMEditor editor = (AbstractFSMEditor) da.findDiagramEditor(mc);
+ AbstractFSMEditor editor = (AbstractFSMEditor) da.findDiagramEditor(roomClass);
if (editor!=null)
wasOpen = true;
else
- editor = (AbstractFSMEditor) da.openDiagramEditor(mc);
+ editor = (AbstractFSMEditor) da.openDiagramEditor(roomClass);
+ ModelComponent mc = editor.getModelComponent();
if (editor!=null) {
String filename = folder+File.separatorChar+mc.getComponentName()+SUFFIX;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
index 2d6c2d87e..69ec1ea16 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramAccess.java
@@ -20,8 +20,10 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.ui.behavior.editor.BehaviorEditor;
import org.eclipse.etrice.ui.behavior.fsm.commands.PopulateDiagramCommand;
+import org.eclipse.etrice.ui.behavior.fsm.editor.BehaviorExporter;
import org.eclipse.etrice.ui.behavior.fsm.support.DiagramUpdateFeature;
import org.eclipse.etrice.ui.common.base.commands.UpdateCommand;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IFeatureProvider;
@@ -29,7 +31,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.ui.services.GraphitiUi;
public class DiagramAccess extends DiagramAccessBase {
-
+
public DiagramAccess() {
super();
}
@@ -108,4 +110,9 @@ public class DiagramAccess extends DiagramAccessBase {
return null;
}
+
+ @Override
+ public IBulkDiagramExporter getDiagramExporter() {
+ return new BehaviorExporter(this);
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
index bd53b5b8c..aa35a51ad 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
@@ -14,6 +14,7 @@ package org.eclipse.etrice.ui.behavior;
import org.eclipse.etrice.ui.behavior.fsm.support.AbstractFSMProviderDispatcher;
import org.eclipse.etrice.ui.behavior.support.ProviderDispatcher;
+import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
@@ -65,4 +66,9 @@ public class DiagramTypeProvider extends AbstractFSMDiagramTypeProvider {
public boolean isAutoUpdateAtRuntime() {
return USE_AUTO_UPDATE;
}
+
+ @Override
+ public DiagramAccessBase getDiagramAccess() {
+ return new DiagramAccess();
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.commands/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.commands/META-INF/MANIFEST.MF
index bf86331ff..4d5380aeb 100644
--- a/plugins/org.eclipse.etrice.ui.commands/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.commands/META-INF/MANIFEST.MF
@@ -10,14 +10,14 @@ Require-Bundle: org.eclipse.etrice.core.fsm;bundle-version="1.1.1",
org.eclipse.etrice.core.room.ui;bundle-version="1.1.1",
org.eclipse.etrice.ui.common;bundle-version="1.1.1",
org.eclipse.etrice.ui.common.base;bundle-version="1.1.1",
- org.eclipse.etrice.ui.structure;bundle-version="1.1.1",
org.eclipse.etrice.ui.behavior.fsm;bundle-version="1.1.1",
- org.eclipse.etrice.ui.behavior;bundle-version="1.1.1",
org.eclipse.graphiti;bundle-version="0.8.0",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100",
org.eclipse.xtext.ui;bundle-version="2.6.0",
org.eclipse.graphiti.ui;bundle-version="0.8.0",
org.eclipse.gef;bundle-version="3.7.0",
- org.eclipse.ui.ide;bundle-version="3.7.0"
+ org.eclipse.ui.ide;bundle-version="3.7.0",
+ org.eclipse.xtext.ui.shared
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.etrice.ui.commands
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/RoomOpeningHelper.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/RoomOpeningHelper.java
new file mode 100644
index 000000000..bbe6e9ee7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/RoomOpeningHelper.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.commands;
+
+import java.util.function.Predicate;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.common.base.Annotation;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.ui.common.base.editor.AbstractBaseDiagramTypeProvider;
+import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
+import org.eclipse.graphiti.dt.IDiagramTypeProvider;
+import org.eclipse.graphiti.ui.services.GraphitiUi;
+import org.eclipse.xtext.ui.shared.Access;
+
+public class RoomOpeningHelper {
+
+ static private final String BEHAVIOR_DTP = "org.eclipse.etrice.ui.behavior.diagramTypeProvider";
+ static private final String STRUCTURE_DTP = "org.eclipse.etrice.ui.structure.diagramTypeProvider";
+
+ static public void openBehavior(EObject object) {
+ if (object instanceof ActorClass) {
+ ActorClass ac = (ActorClass) object;
+ boolean hasManualBehavior = ac.getBehaviorAnnotations().parallelStream().anyMatch(new Predicate<Annotation>() {
+
+ @Override
+ public boolean test(Annotation annotation) {
+ return annotation.getType() != null && "BehaviorManual".equals(annotation.getType().getName());
+ }
+ });
+ if (hasManualBehavior) {
+ showInTextualEditor(ac);
+ } else {
+ getBehaviorDiagramAccess().openDiagramEditor(ac);
+ }
+ }
+ }
+
+ static public void openStructure(EObject object) {
+ if(object instanceof StructureClass){
+ getStructureDiagramAccess().openDiagramEditor(object);
+ }
+ }
+
+ static public void showInTextualEditor(EObject object) {
+ URI uri = (object != null) ? EcoreUtil.getURI(object) : null;
+ if (uri != null) {
+ Access.getIURIEditorOpener().get().open(uri, true);
+ }
+ }
+
+ static public DiagramAccessBase getBehaviorDiagramAccess() {
+ return getDiagramAccess(BEHAVIOR_DTP);
+ }
+
+ static public DiagramAccessBase getStructureDiagramAccess() {
+ return getDiagramAccess(STRUCTURE_DTP);
+ }
+
+ static DiagramAccessBase getDiagramAccess(String providerId) {
+ IDiagramTypeProvider dtp = GraphitiUi.getExtensionManager().createDiagramTypeProvider(providerId);
+ if(dtp instanceof AbstractBaseDiagramTypeProvider) {
+ return ((AbstractBaseDiagramTypeProvider) dtp).getDiagramAccess();
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
index c668afcb1..a38afc82c 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
@@ -16,12 +16,10 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.ui.RoomUiModule;
import org.eclipse.etrice.core.ui.editor.RoomEditor;
-import org.eclipse.etrice.ui.behavior.editor.BehaviorEditor;
-import org.eclipse.etrice.ui.structure.editor.StructureEditor;
+import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
@@ -120,16 +118,10 @@ public abstract class AbstractEditHandler extends AbstractHandler {
}
}
}
- else if (editor instanceof StructureEditor) {
- StructureClass sc = ((StructureEditor)editor).getStructureClass();
- if (sc instanceof ActorClass) {
- openEditor(sc);
- }
- }
- else if (editor instanceof BehaviorEditor) {
- ActorClass ac = ((BehaviorEditor)editor).getActorClass();
- openEditor(ac);
+ else if (editor instanceof DiagramEditorBase) {
+ openEditor(((DiagramEditorBase) editor).getModelComponent());
}
+
return null;
}
@@ -178,14 +170,10 @@ public abstract class AbstractEditHandler extends AbstractHandler {
return isEnabled(fragment);
}
}
- else if (editor instanceof StructureEditor) {
- StructureClass sc = ((StructureEditor)editor).getStructureClass();
- return isEnabled(fragmentProvider.getFragment(sc, null));
- }
- else if (editor instanceof BehaviorEditor) {
- ActorClass ac = ((BehaviorEditor)editor).getActorClass();
- return isEnabled(fragmentProvider.getFragment(ac, null));
+ else if (editor instanceof DiagramEditorBase) {
+ openEditor(((DiagramEditorBase) editor).getModelComponent());
}
+
return false;
}
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
index f581a8c3f..11690a140 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
@@ -14,14 +14,14 @@ package org.eclipse.etrice.ui.commands.handlers;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.naming.RoomFragmentProvider;
-import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.fsm.fSM.State;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.core.fsm.fSM.Transition;
+import org.eclipse.etrice.core.naming.RoomFragmentProvider;
+import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.util.RoomNewNamingUtil;
import org.eclipse.etrice.core.ui.RoomUiModule;
-import org.eclipse.etrice.ui.behavior.DiagramAccess;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
@@ -126,10 +126,7 @@ public class EditBehaviorHandler extends AbstractEditHandler {
}
protected void openEditor(EObject object) {
- if (object instanceof ActorClass) {
- DiagramAccess diagramAccess = new DiagramAccess();
- diagramAccess.openDiagramEditor((ActorClass) object);
- }
+ RoomOpeningHelper.openBehavior(object);
}
@Override
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
index 9480ffc30..839b4bc20 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
@@ -3,21 +3,11 @@ package org.eclipse.etrice.ui.commands.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.ui.util.EditUIUtil;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.core.ui.RoomUiModule;
-import org.eclipse.etrice.ui.behavior.editor.BehaviorEditor;
-import org.eclipse.etrice.ui.structure.editor.StructureEditor;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
+import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.xtext.resource.ILocationInFileProvider;
-import org.eclipse.xtext.ui.editor.XtextEditor;
-import org.eclipse.xtext.util.ITextRegion;
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
@@ -26,17 +16,6 @@ import com.google.inject.Injector;
*/
public class EditModelHandler extends AbstractHandler {
- @Inject
- ILocationInFileProvider locationProvider;
-
- /**
- * The constructor.
- */
- public EditModelHandler() {
- Injector injector = RoomUiModule.getInjector();
- injector.injectMembers(this);
- }
-
/**
* the command has been executed, so extract extract the needed information
* from the application context.
@@ -44,27 +23,10 @@ public class EditModelHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IEditorPart editor = window.getActivePage().getActiveEditor();
- StructureClass sc = null;
- if (editor instanceof StructureEditor) {
- sc = ((StructureEditor)editor).getStructureClass();
- }
- else if (editor instanceof BehaviorEditor) {
- sc = ((BehaviorEditor)editor).getActorClass();
- }
- if (sc!=null) {
- try {
- if (EditUIUtil.openEditor(sc)) {
- editor = window.getActivePage().getActiveEditor();
- if (editor instanceof XtextEditor) {
- XtextEditor xed = (XtextEditor) editor;
- ITextRegion location = locationProvider.getFullTextRegion(sc);
- xed.selectAndReveal(location.getOffset(), location.getLength());
- }
- }
- } catch (PartInitException e) {
- e.printStackTrace();
- }
+ if (editor instanceof DiagramEditorBase) {
+ RoomOpeningHelper.showInTextualEditor(((DiagramEditorBase) editor).getModelComponent());
}
+
return null;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditStructureHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditStructureHandler.java
index 126ccd8a0..e5f1fc70a 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditStructureHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditStructureHandler.java
@@ -14,8 +14,7 @@ package org.eclipse.etrice.ui.commands.handlers;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.naming.RoomFragmentProvider;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
import org.eclipse.xtext.ui.editor.XtextEditor;
/**
@@ -40,10 +39,7 @@ public class EditStructureHandler extends AbstractEditHandler {
*/
@Override
protected void openEditor(EObject object) {
- if (object instanceof StructureClass) {
- DiagramAccess diagramAccess = new DiagramAccess();
- diagramAccess.openDiagramEditor((StructureClass) object);
- }
+ RoomOpeningHelper.openStructure(object);
}
@Override
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
index ea0ee2350..a47ade015 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/ExportDiagramsHandler.java
@@ -34,10 +34,10 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.ui.RoomUiModule;
-import org.eclipse.etrice.ui.behavior.fsm.editor.BehaviorExporter;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.common.base.preferences.UIBasePreferenceConstants;
-import org.eclipse.etrice.ui.structure.editor.StructureExporter;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
@@ -143,16 +143,17 @@ public class ExportDiagramsHandler extends AbstractHandler {
if (folder.exists()) {
String folderPath = folder.getLocation().toOSString();
- BehaviorExporter exporter = org.eclipse.etrice.ui.behavior.Activator.getDefault().getInjector().getInstance(BehaviorExporter.class);
+ IBulkDiagramExporter behaviorExporter = RoomOpeningHelper.getBehaviorDiagramAccess().getDiagramExporter();
+ IBulkDiagramExporter structureExporter = RoomOpeningHelper.getStructureDiagramAccess().getDiagramExporter();
for (ActorClass ac : model.getActorClasses()) {
if (ac.getStateMachine()!=null)
- exporter.export(ac, folderPath);
+ behaviorExporter.export(ac, folderPath);
- StructureExporter.export(ac, folderPath);
+ structureExporter.export(ac, folderPath);
}
for (SubSystemClass ssc : model.getSubSystemClasses()) {
- StructureExporter.export(ssc, folderPath);
+ structureExporter.export(ssc, folderPath);
}
try {
diff --git a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
index 6abca91f9..219fd0bf8 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.common.base/META-INF/MANIFEST.MF
@@ -33,6 +33,7 @@ Export-Package: org.eclipse.etrice.ui.common.base,
org.eclipse.etrice.ui.common.base.concurrency,
org.eclipse.etrice.ui.common.base.dialogs,
org.eclipse.etrice.ui.common.base.editor,
+ org.eclipse.etrice.ui.common.base.export,
org.eclipse.etrice.ui.common.base.preferences,
org.eclipse.etrice.ui.common.base.quickfix,
org.eclipse.etrice.ui.common.base.resource,
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/AbstractBaseDiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/AbstractBaseDiagramTypeProvider.java
new file mode 100644
index 000000000..b33d3254c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/AbstractBaseDiagramTypeProvider.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * juergen.haug@protos.de (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.base.editor;
+
+import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
+import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
+
+public abstract class AbstractBaseDiagramTypeProvider extends AbstractDiagramTypeProvider {
+
+ public abstract DiagramAccessBase getDiagramAccess();
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramExporter.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/DiagramExporter.java
index 42a9b7942..b4789a72a 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/editor/DiagramExporter.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/DiagramExporter.java
@@ -10,7 +10,7 @@
*
*******************************************************************************/
-package org.eclipse.etrice.ui.common.base.editor;
+package org.eclipse.etrice.ui.common.base.export;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
@@ -23,6 +23,7 @@ import org.eclipse.draw2d.SWTGraphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
+import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
import org.eclipse.etrice.ui.common.base.preferences.UIBasePreferenceConstants;
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.gef.EditPart;
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/IBulkDiagramExporter.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/IBulkDiagramExporter.java
new file mode 100644
index 000000000..385e3e591
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/export/IBulkDiagramExporter.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * juergen.haug@protos.de (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.common.base.export;
+
+import org.eclipse.emf.ecore.EObject;
+
+public interface IBulkDiagramExporter {
+
+ void export(EObject mc, String folder);
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
index 22c5831ab..232d0ae90 100644
--- a/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
+++ b/plugins/org.eclipse.etrice.ui.common.base/src/org/eclipse/etrice/ui/common/base/support/DiagramAccessBase.java
@@ -33,6 +33,7 @@ import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.etrice.core.common.ui.linking.GlobalNonPlatformURIEditorOpener;
import org.eclipse.etrice.ui.common.base.UIBaseActivator;
import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.common.base.preferences.UIBasePreferenceConstants;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.services.Graphiti;
@@ -243,6 +244,7 @@ public abstract class DiagramAccessBase {
}
public abstract String getDiagramName(EObject rootObject);
+ public abstract IBulkDiagramExporter getDiagramExporter();
abstract protected String getDigramFileName(EObject rootObject);
abstract protected String getDiagramTypeId();
abstract protected String getEditorId();
diff --git a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
index 3e888c31e..2df144d6d 100644
--- a/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.structure/META-INF/MANIFEST.MF
@@ -26,3 +26,4 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.etrice.ui.structure,
org.eclipse.etrice.ui.structure.editor,
org.eclipse.etrice.ui.structure.support
+Import-Package: org.eclipse.etrice.ui.commands
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
index b5f3a3a92..041549189 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
@@ -16,9 +16,11 @@ package org.eclipse.etrice.ui.structure;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.etrice.ui.structure.commands.UpdateDiagramCommand;
import org.eclipse.etrice.ui.structure.editor.StructureEditor;
+import org.eclipse.etrice.ui.structure.editor.StructureExporter;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -88,4 +90,9 @@ public class DiagramAccess extends DiagramAccessBase {
Injector injector = RoomUiModule.getInjector();
injector.injectMembers(this);
}
+
+ @Override
+ public IBulkDiagramExporter getDiagramExporter() {
+ return new StructureExporter();
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
index 7ac6fb5ee..bab75da07 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramTypeProvider.java
@@ -13,7 +13,8 @@
package org.eclipse.etrice.ui.structure;
import org.eclipse.etrice.core.ui.RoomUiModule;
-import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
+import org.eclipse.etrice.ui.common.base.editor.AbstractBaseDiagramTypeProvider;
+import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.xtext.scoping.IScopeProvider;
@@ -21,7 +22,7 @@ import com.google.inject.Inject;
import com.google.inject.Injector;
//@SuppressWarnings("restriction")
-public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
+public class DiagramTypeProvider extends AbstractBaseDiagramTypeProvider {
private static final boolean USE_AUTO_UPDATE = true;
@@ -84,4 +85,9 @@ public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
public IScopeProvider getScopeProvider() {
return scopeProvider;
}
+
+ @Override
+ public DiagramAccessBase getDiagramAccess() {
+ return new DiagramAccess();
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
index 5f553e29e..79efd9148 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/editor/StructureExporter.java
@@ -14,17 +14,23 @@ package org.eclipse.etrice.ui.structure.editor;
import java.io.File;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.ui.common.base.editor.DiagramExporter;
+import org.eclipse.etrice.ui.common.base.export.DiagramExporter;
+import org.eclipse.etrice.ui.common.base.export.IBulkDiagramExporter;
import org.eclipse.etrice.ui.structure.DiagramAccess;
-public class StructureExporter {
+public class StructureExporter implements IBulkDiagramExporter {
private static final String SUFFIX = "_structure";
- public static void export(StructureClass ac, String folder) {
+ public void export(EObject roomClass, String folder) {
+ Assert.isLegal(roomClass instanceof StructureClass);
+
+ StructureClass sc = (StructureClass) roomClass;
DiagramAccess da = new DiagramAccess();
- DiagramExporter.export(ac, da, folder+File.separatorChar+ac.getName()+SUFFIX);
+ DiagramExporter.export(sc, da, folder+File.separatorChar+sc.getName()+SUFFIX);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
index b47e95b2d..88c27c587 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
@@ -34,6 +34,7 @@ import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.SubSystemRef;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
import org.eclipse.etrice.ui.common.base.preferences.UIBasePreferenceConstants;
import org.eclipse.etrice.ui.common.base.support.BaseToolBehaviorProvider;
import org.eclipse.etrice.ui.common.base.support.CantRemoveFeature;
@@ -41,8 +42,6 @@ import org.eclipse.etrice.ui.common.base.support.ChangeAwareCreateFeature;
import org.eclipse.etrice.ui.common.base.support.ChangeAwareCustomFeature;
import org.eclipse.etrice.ui.common.base.support.CommonSupportUtil;
import org.eclipse.etrice.ui.common.base.support.DeleteWithoutConfirmFeature;
-import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
-import org.eclipse.etrice.ui.structure.DiagramAccess;
import org.eclipse.etrice.ui.structure.DiagramTypeProvider;
import org.eclipse.etrice.ui.structure.ImageProvider;
import org.eclipse.etrice.ui.structure.dialogs.ActorContainerRefPropertyDialog;
@@ -667,8 +666,7 @@ public class ActorContainerRefSupport {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- DiagramAccessBase diagramAccess = new DiagramAccess();
- diagramAccess.openDiagramEditor(sc);
+ RoomOpeningHelper.openStructure(sc);
}
});
}
@@ -718,8 +716,7 @@ public class ActorContainerRefSupport {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- DiagramAccessBase diagramAccess = new org.eclipse.etrice.ui.behavior.DiagramAccess();
- diagramAccess.openDiagramEditor(ac);
+ RoomOpeningHelper.openBehavior(ac);
}
});
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
index 17804780d..535e8b87b 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
@@ -19,11 +19,11 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.ui.commands.RoomOpeningHelper;
import org.eclipse.etrice.ui.common.base.editor.DiagramEditorBase;
import org.eclipse.etrice.ui.common.base.support.BaseToolBehaviorProvider;
import org.eclipse.etrice.ui.common.base.support.CantRemoveFeature;
import org.eclipse.etrice.ui.common.base.support.DeleteWithoutConfirmFeature;
-import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase;
import org.eclipse.etrice.ui.common.commands.ChangeDiagramInputJob;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
@@ -249,8 +249,7 @@ public class StructureClassSupport {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- DiagramAccessBase diagramAccess = new org.eclipse.etrice.ui.behavior.DiagramAccess();
- diagramAccess.openDiagramEditor(ac);
+ RoomOpeningHelper.openBehavior(ac);
}
});
}

Back to the top