summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayant Gupta2013-06-17 06:03:44 (EDT)
committerJayant Gupta2013-09-03 13:02:07 (EDT)
commit9bdd3272bca69ef62dc16729b4df3990f8e533e8 (patch)
tree1f277d69651c2bf6d20c07a92316c7c791d52a3e
parent34c898cd8412e58b7fe5dcffcfe2123a9a9e90fa (diff)
downloadorg.eclipse.etrice-9bdd3272bca69ef62dc16729b4df3990f8e533e8.zip
org.eclipse.etrice-9bdd3272bca69ef62dc16729b4df3990f8e533e8.tar.gz
org.eclipse.etrice-9bdd3272bca69ef62dc16729b4df3990f8e533e8.tar.bz2
Adds getDecorator() methods to Feature Provider of StateSupport.refs/changes/52/13852/3
* Renders warning and info markers over the states of behavior editor. * Validates complete ROOM model, each time a decorator re-paint happens. Change-Id: Ie543e48252d539f0f695aca46eedb9b3ceb45a3f Signed-off-by: Jayant Gupta <gsocjayant@gmail.com>
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java73
2 files changed, 86 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
index ed49584..a81d045 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
@@ -66,6 +66,7 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IContextButtonPadData;
+import org.eclipse.graphiti.tb.IDecorator;
import org.eclipse.graphiti.tb.IShapeSelectionInfo;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.tb.ShapeSelectionInfoImpl;
@@ -461,6 +462,18 @@ public class ProviderDispatcher {
else
return bp.getToolTip(ga);
}
+
+ /**
+ * @author jayant
+ **/
+ @Override
+ public IDecorator[] getDecorators(PictogramElement pe) {
+ IToolBehaviorProvider bp = getToolBehaviorProvider(pe);
+ if (bp==null)
+ return super.getDecorators(pe);
+ else
+ return bp.getDecorators(pe);
+ }
}
private StateGraphSupport stateGraphSupport;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
index 00e8551..e78d3dc 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
@@ -13,8 +13,12 @@
package org.eclipse.etrice.ui.behavior.support;
import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
@@ -80,13 +84,16 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.platform.IPlatformImageConstants;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeCreateService;
import org.eclipse.graphiti.tb.ContextButtonEntry;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IContextButtonPadData;
+import org.eclipse.graphiti.tb.IDecorator;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import org.eclipse.graphiti.tb.ImageDecorator;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.ui.services.GraphitiUi;
import org.eclipse.graphiti.util.ColorConstant;
@@ -1073,6 +1080,72 @@ public class StateSupport {
return data;
}
+
+ /**
+ * @author jayant
+ */
+ @Override
+ public IDecorator[] getDecorators(PictogramElement pe) {
+ //Some constants for decorator
+ GraphicsAlgorithm invisible = pe.getGraphicsAlgorithm();
+ GraphicsAlgorithm rectangle = invisible.getGraphicsAlgorithmChildren().get(0);
+ int xOrigin = rectangle.getX();
+ int yOrigin = rectangle.getY();
+ ArrayList<IDecorator> decorators = new ArrayList<IDecorator>();
+
+ //Get the linked Business Object
+ EObject bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(pe);
+
+ //Validate the compete ROOM Model and Get Diagnostics
+ EObject myModel = bo.eResource().getContents().get(0);
+ Diagnostic diagnostics = Diagnostician.INSTANCE.validate(myModel);
+
+ //Inspect each child diagnostic
+ for (Diagnostic diagnostic : diagnostics.getChildren()) {
+
+ //for each child diagnostic, find the associated EObject
+ FeatureBasedDiagnostic featureBasedDiagnostic = (FeatureBasedDiagnostic)diagnostic;
+ EObject source = featureBasedDiagnostic.getSourceEObject();
+ EStructuralFeature feature = featureBasedDiagnostic.getFeature();
+ int index = featureBasedDiagnostic.getIndex();
+ EObject eObject = null;
+ if (!feature.isMany())
+ eObject = (EObject) source.eGet(feature);
+ else {
+ List<?> list = (List<?>) source.eGet(feature);
+ eObject = (EObject) list.get(index);
+ }
+
+ //compare the diagnostic EObject with the Business object linked with the pictogram element
+ //if they are equal, add entry to IDecorator[]
+ if (eObject.equals(bo)){
+ ImageDecorator imageRenderingDecorator = null;
+ switch (diagnostic.getSeverity()) {
+ case Diagnostic.ERROR:
+ imageRenderingDecorator = new ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_ERROR_TSK);
+ break;
+ case Diagnostic.WARNING:
+ imageRenderingDecorator = new ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_WARNING_TSK);
+ break;
+ case Diagnostic.INFO:
+ imageRenderingDecorator = new ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_INFORMATION_TSK);
+ break;
+ }
+ if (imageRenderingDecorator != null){
+ imageRenderingDecorator.setMessage(diagnostic.getMessage());
+ imageRenderingDecorator.setX(xOrigin);
+ imageRenderingDecorator.setY(yOrigin);
+ decorators.add(imageRenderingDecorator);
+ }
+ }
+ }
+
+ if (decorators.isEmpty())
+ return super.getDecorators(pe);
+ else
+ return (IDecorator[]) decorators.toArray(new IDecorator[decorators.size()]);
+ }
}
private FeatureProvider pfp;