Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2017-08-03 04:03:12 -0400
committerJuergen Haug2017-08-03 04:03:12 -0400
commit72301eca92a8ed247003f9ea720cfdd697201bde (patch)
treed18eb8b535ed96a120ab06e12055e76690691de0
parentaec89530bed7d6ca258446aa9a15fd1806752895 (diff)
downloadorg.eclipse.etrice-72301eca92a8ed247003f9ea720cfdd697201bde.tar.gz
org.eclipse.etrice-72301eca92a8ed247003f9ea720cfdd697201bde.tar.xz
org.eclipse.etrice-72301eca92a8ed247003f9ea720cfdd697201bde.zip
[ui.behavior] fix for NPE in base positions
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.xtend37
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.java99
2 files changed, 81 insertions, 55 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.xtend
index cb62d9e4a..d4f9262f0 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.xtend
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.xtend
@@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.etrice.core.fsm.fSM.ModelComponent
import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider
import org.eclipse.etrice.ui.common.base.support.DiagramAccessBase
-import org.eclipse.graphiti.mm.pictograms.Diagram
import org.eclipse.graphiti.mm.pictograms.PictogramElement
import org.eclipse.graphiti.mm.pictograms.PictogramLink
import org.eclipse.graphiti.services.Graphiti
@@ -28,10 +27,11 @@ import org.eclipse.graphiti.services.Graphiti
/**
* Provides the {@linkplain PictogramElement} objects of the base class diagram.
* This is a reverse mapping from room business objects to linked base diagram pictograms.
+ *
+ * TODO: use fsmgenmodel instead
*/
class BaseDiagramProvider {
- val Diagram baseDiagram
val Multimap<EObject, PictogramElement> baseDiagramBusinessObjs = ArrayListMultimap.create
new(AbstractFSMDiagramTypeProvider diagramTypeProvider) {
@@ -39,19 +39,28 @@ class BaseDiagramProvider {
val mc = Graphiti.linkService.getBusinessObjectForLinkedPictogramElement(diagramTypeProvider.diagram) as ModelComponent
val rs = diagramTypeProvider.diagram.eResource.resourceSet
- // open base diagram => causes full recursive update or creation of all base diagrams
- baseDiagram = if(mc.base != null) diagramAccess.getDiagram(mc.base, rs)
- if(baseDiagram != null) {
- // create mapping from business object to pictogram elements
- EcoreUtil.ExternalCrossReferencer.find(baseDiagram).forEach [ targetEObj, eFeatureSetting |
- eFeatureSetting.map[getEObject].filter(PictogramLink).map[pictogramElement].forEach [ pe |
- baseDiagramBusinessObjs.put(targetEObj, pe)
+ // open base diagrams => causes full recursive update or creation of all base diagrams
+ // all base diagrams have to be considered because inherited subgraph could not exist yet
+ val baseClasses = newArrayList => [
+ var base = mc.base
+ while(base !== null && it.add(base)) {
+ base = base.base
+ }
+ ]
+ baseClasses.reverseView.forEach[ base |
+ val baseDiagram = diagramAccess.getDiagram(base, rs)
+ if(baseDiagram != null) {
+ // create mapping from business object to pictogram elements
+ EcoreUtil.ExternalCrossReferencer.find(baseDiagram).forEach [ targetEObj, eFeatureSetting |
+ eFeatureSetting.map[getEObject].filter(PictogramLink).map[pictogramElement].forEach [ pe |
+ baseDiagramBusinessObjs.put(targetEObj, pe)
+ ]
]
- ]
-
- // base diagram resource not needed anymore
- rs.resources.remove(baseDiagram.eResource)
- }
+
+ // base diagram resource not needed anymore
+ rs.resources.remove(baseDiagram.eResource)
+ }
+ ]
}
def Collection<PictogramElement> getPictograms(EObject roomObj) {
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.java
index 0c14f1a28..0c2eae0a5 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/provider/BaseDiagramProvider.java
@@ -15,7 +15,9 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.inject.Injector;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -36,15 +38,18 @@ import org.eclipse.graphiti.services.ILinkService;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
/**
* Provides the {@linkplain PictogramElement} objects of the base class diagram.
* This is a reverse mapping from room business objects to linked base diagram pictograms.
+ *
+ * TODO: use fsmgenmodel instead
*/
@SuppressWarnings("all")
public class BaseDiagramProvider {
- private final Diagram baseDiagram;
-
private final Multimap<EObject, PictogramElement> baseDiagramBusinessObjs = ArrayListMultimap.<EObject, PictogramElement>create();
public BaseDiagramProvider(final AbstractFSMDiagramTypeProvider diagramTypeProvider) {
@@ -57,49 +62,61 @@ public class BaseDiagramProvider {
Diagram _diagram_1 = diagramTypeProvider.getDiagram();
Resource _eResource = _diagram_1.eResource();
final ResourceSet rs = _eResource.getResourceSet();
- Diagram _xifexpression = null;
- ModelComponent _base = mc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- ModelComponent _base_1 = mc.getBase();
- _xifexpression = diagramAccess.getDiagram(_base_1, rs);
- }
- this.baseDiagram = _xifexpression;
- boolean _notEquals_1 = (!Objects.equal(this.baseDiagram, null));
- if (_notEquals_1) {
- Map<EObject, Collection<EStructuralFeature.Setting>> _find = EcoreUtil.ExternalCrossReferencer.find(this.baseDiagram);
- final BiConsumer<EObject, Collection<EStructuralFeature.Setting>> _function = new BiConsumer<EObject, Collection<EStructuralFeature.Setting>>() {
- @Override
- public void accept(final EObject targetEObj, final Collection<EStructuralFeature.Setting> eFeatureSetting) {
- final Function1<EStructuralFeature.Setting, EObject> _function = new Function1<EStructuralFeature.Setting, EObject>() {
- @Override
- public EObject apply(final EStructuralFeature.Setting it) {
- return it.getEObject();
- }
- };
- Iterable<EObject> _map = IterableExtensions.<EStructuralFeature.Setting, EObject>map(eFeatureSetting, _function);
- Iterable<PictogramLink> _filter = Iterables.<PictogramLink>filter(_map, PictogramLink.class);
- final Function1<PictogramLink, PictogramElement> _function_1 = new Function1<PictogramLink, PictogramElement>() {
- @Override
- public PictogramElement apply(final PictogramLink it) {
- return it.getPictogramElement();
- }
- };
- Iterable<PictogramElement> _map_1 = IterableExtensions.<PictogramLink, PictogramElement>map(_filter, _function_1);
- final Consumer<PictogramElement> _function_2 = new Consumer<PictogramElement>() {
+ ArrayList<ModelComponent> _newArrayList = CollectionLiterals.<ModelComponent>newArrayList();
+ final Procedure1<ArrayList<ModelComponent>> _function = new Procedure1<ArrayList<ModelComponent>>() {
+ @Override
+ public void apply(final ArrayList<ModelComponent> it) {
+ ModelComponent base = mc.getBase();
+ while (((base != null) && it.add(base))) {
+ ModelComponent _base = base.getBase();
+ base = _base;
+ }
+ }
+ };
+ final ArrayList<ModelComponent> baseClasses = ObjectExtensions.<ArrayList<ModelComponent>>operator_doubleArrow(_newArrayList, _function);
+ List<ModelComponent> _reverseView = ListExtensions.<ModelComponent>reverseView(baseClasses);
+ final Consumer<ModelComponent> _function_1 = new Consumer<ModelComponent>() {
+ @Override
+ public void accept(final ModelComponent base) {
+ final Diagram baseDiagram = diagramAccess.getDiagram(base, rs);
+ boolean _notEquals = (!Objects.equal(baseDiagram, null));
+ if (_notEquals) {
+ Map<EObject, Collection<EStructuralFeature.Setting>> _find = EcoreUtil.ExternalCrossReferencer.find(baseDiagram);
+ final BiConsumer<EObject, Collection<EStructuralFeature.Setting>> _function = new BiConsumer<EObject, Collection<EStructuralFeature.Setting>>() {
@Override
- public void accept(final PictogramElement pe) {
- BaseDiagramProvider.this.baseDiagramBusinessObjs.put(targetEObj, pe);
+ public void accept(final EObject targetEObj, final Collection<EStructuralFeature.Setting> eFeatureSetting) {
+ final Function1<EStructuralFeature.Setting, EObject> _function = new Function1<EStructuralFeature.Setting, EObject>() {
+ @Override
+ public EObject apply(final EStructuralFeature.Setting it) {
+ return it.getEObject();
+ }
+ };
+ Iterable<EObject> _map = IterableExtensions.<EStructuralFeature.Setting, EObject>map(eFeatureSetting, _function);
+ Iterable<PictogramLink> _filter = Iterables.<PictogramLink>filter(_map, PictogramLink.class);
+ final Function1<PictogramLink, PictogramElement> _function_1 = new Function1<PictogramLink, PictogramElement>() {
+ @Override
+ public PictogramElement apply(final PictogramLink it) {
+ return it.getPictogramElement();
+ }
+ };
+ Iterable<PictogramElement> _map_1 = IterableExtensions.<PictogramLink, PictogramElement>map(_filter, _function_1);
+ final Consumer<PictogramElement> _function_2 = new Consumer<PictogramElement>() {
+ @Override
+ public void accept(final PictogramElement pe) {
+ BaseDiagramProvider.this.baseDiagramBusinessObjs.put(targetEObj, pe);
+ }
+ };
+ _map_1.forEach(_function_2);
}
};
- _map_1.forEach(_function_2);
+ _find.forEach(_function);
+ EList<Resource> _resources = rs.getResources();
+ Resource _eResource = baseDiagram.eResource();
+ _resources.remove(_eResource);
}
- };
- _find.forEach(_function);
- EList<Resource> _resources = rs.getResources();
- Resource _eResource_1 = this.baseDiagram.eResource();
- _resources.remove(_eResource_1);
- }
+ }
+ };
+ _reverseView.forEach(_function_1);
}
public Collection<PictogramElement> getPictograms(final EObject roomObj) {

Back to the top