Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java12
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/handler/ResetStyleHandler.java25
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSAppearanceProvider.java32
3 files changed, 53 insertions, 16 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java
index df7856e1a72..5b82321e68c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java
@@ -21,7 +21,17 @@ import org.eclipse.papyrus.infra.emf.appearance.commands.SetQualifiedNameDepthCo
import org.eclipse.papyrus.infra.emf.appearance.commands.SetShadowFigureCommand;
import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
-
+/**
+ * Basic implementation of AppearanceStyleProvider, based on EMF EAnnotations
+ *
+ * @author Camille Letavernier
+ */
+//Implementation note: the CSS rely on these EAnnotations to determine
+//whether the CSS appearance should be enabled or not. If the EAnnotations
+//are removed, the implementation of CSSApperanceProvider and ResetStyleHandler
+//should be changed accordingly (e.g. if EAnnotations are replaced by GMF
+//NamedStyles, see
+//Bug 321305 - https://bugs.eclipse.org/bugs/show_bug.cgi?id=321305 )
public class AnnotationStyleProvider implements AppearanceStyleProvider {
public boolean showElementIcon(EModelElement modelElement) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/handler/ResetStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/handler/ResetStyleHandler.java
index 850220e1da4..4c139a2987f 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/handler/ResetStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/handler/ResetStyleHandler.java
@@ -11,7 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.handler;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -32,6 +34,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations;
@@ -45,6 +48,13 @@ import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations;
*/
public class ResetStyleHandler extends AbstractHandler {
+ private static Set<String> papyrusStyleAnnotations = new HashSet<String>();
+ static {
+ papyrusStyleAnnotations.add(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON);
+ papyrusStyleAnnotations.add(VisualInformationPapyrusConstants.SHADOWFIGURE);
+ papyrusStyleAnnotations.add(VisualInformationPapyrusConstants.QUALIFIED_NAME);
+ }
+
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection;
try {
@@ -53,7 +63,6 @@ public class ResetStyleHandler extends AbstractHandler {
return null;
}
} catch (ServiceException ex) {
- // TODO Auto-generated catch block
Activator.log.error(ex);
return null;
}
@@ -150,6 +159,8 @@ public class ResetStyleHandler extends AbstractHandler {
//Remove the "forceValue" annotations
resetAnnotations(view);
+ //Remove the Papyrus Style EAnnotations
+ resetStyleAnnotations(view);
}
private void resetStyle(Style style) {
@@ -171,6 +182,8 @@ public class ResetStyleHandler extends AbstractHandler {
}
}
+ //Resets the "Force Value" annotations (Tags to indicate that the user
+ //has manually selected a value, which will override the CSS Style)
private void resetAnnotations(View view) {
Iterator<EAnnotation> iterator = view.getEAnnotations().iterator();
while(iterator.hasNext()) {
@@ -179,6 +192,16 @@ public class ResetStyleHandler extends AbstractHandler {
}
}
}
+
+ //Resets the "Custom style" Annotations (elementIcon, shadow, qualifiedName)
+ private void resetStyleAnnotations(View view) {
+ Iterator<EAnnotation> iterator = view.getEAnnotations().iterator();
+ while(iterator.hasNext()) {
+ if(papyrusStyleAnnotations.contains(iterator.next().getSource())) {
+ iterator.remove();
+ }
+ }
+ }
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSAppearanceProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSAppearanceProvider.java
index ab59c50ea25..12775229b77 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSAppearanceProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSAppearanceProvider.java
@@ -11,7 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.provider;
+import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
/**
@@ -21,35 +23,37 @@ import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
* @author Camille Letavernier
*
*/
-//FIXME: Currently, manual changes on the appearance properties are not
-//correctly taken into account
public class CSSAppearanceProvider extends AnnotationStyleProvider {
@Override
public boolean showElementIcon(EModelElement modelElement) {
- boolean result = super.showElementIcon(modelElement);
- if(!result && modelElement instanceof CustomStyle) {
- return ((CustomStyle)modelElement).showElementIcon();
+ EAnnotation displayNameLabelIcon = modelElement.getEAnnotation(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON);
+ if(displayNameLabelIcon != null || !(modelElement instanceof CustomStyle)) {
+ return super.showElementIcon(modelElement);
}
- return result;
+
+ return ((CustomStyle)modelElement).showElementIcon();
}
@Override
public int getQualifiedNameDepth(EModelElement modelElement) {
- int result = super.getQualifiedNameDepth(modelElement);
- if(result == 1000 && modelElement instanceof CustomStyle) {
- return ((CustomStyle)modelElement).getQualifiedNameDepth();
+ EAnnotation qualifiedNameAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.QUALIFIED_NAME);
+ if(qualifiedNameAnnotation != null || !(modelElement instanceof CustomStyle)) {
+ return super.getQualifiedNameDepth(modelElement);
}
- return result;
+
+ return ((CustomStyle)modelElement).getQualifiedNameDepth();
}
@Override
public boolean showShadow(EModelElement modelElement) {
- boolean result = super.showShadow(modelElement);
- if(!result && modelElement instanceof CustomStyle) {
- return ((CustomStyle)modelElement).showShadow();
+ EAnnotation shadowAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.SHADOWFIGURE);
+
+ if(shadowAnnotation != null || !(modelElement instanceof CustomStyle)) {
+ return super.showShadow(modelElement);
}
- return result;
+
+ return ((CustomStyle)modelElement).showShadow();
}
}

Back to the top