Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-06-21 05:42:01 -0400
committercletavernie2012-06-21 05:42:01 -0400
commitdb6108e00c1bc801527b16206609157eabe8652c (patch)
tree2ee04446a264274a505ace9461614cc2cb064a50 /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src
parent98a02e11e67387ab365de12cc1f75bb373483169 (diff)
downloadorg.eclipse.papyrus-db6108e00c1bc801527b16206609157eabe8652c.tar.gz
org.eclipse.papyrus-db6108e00c1bc801527b16206609157eabe8652c.tar.xz
org.eclipse.papyrus-db6108e00c1bc801527b16206609157eabe8652c.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java7
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java33
2 files changed, 37 insertions, 3 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
index 1afa7059a40..9a15f4ca803 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
@@ -11,10 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
+import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
+
import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
@@ -47,7 +48,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
public abstract class AbstractStyleDialog extends TrayDialog {
@@ -326,6 +326,9 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
protected String getLabel(Expression expression) {
+ if(expression == null) {
+ return "";
+ }
String label = getLabel(expression.getTerms());
for(Subterm subTerm : expression.getSubterms()) {
if(subTerm.getOperator() != null) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
index 8caf3d4041b..89a04aeb221 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
@@ -11,6 +11,8 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
+import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
+
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -39,6 +41,7 @@ import org.eclipse.jface.viewers.ISelection;
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.appearance.helper.VisualInformationPapyrusConstants;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.ATTRIBUTE_OP;
import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
@@ -46,16 +49,17 @@ import org.eclipse.papyrus.infra.gmfdiag.css.AttributeValue;
import org.eclipse.papyrus.infra.gmfdiag.css.CompositeSelector;
import org.eclipse.papyrus.infra.gmfdiag.css.CssFactory;
import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css.Expression;
import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
import org.eclipse.papyrus.infra.gmfdiag.css.SelectorCondition;
import org.eclipse.papyrus.infra.gmfdiag.css.SimpleSelector;
import org.eclipse.papyrus.infra.gmfdiag.css.Stylesheet;
import org.eclipse.papyrus.infra.gmfdiag.css.configuration.Activator;
import org.eclipse.papyrus.infra.gmfdiag.css.handler.CSSRefreshHandler;
+import org.eclipse.papyrus.infra.gmfdiag.css.provider.CustomStyle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
-import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
public abstract class AbstractStyleHandler extends AbstractHandler {
@@ -190,6 +194,10 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
declarations.putAll(handleStyle((Style)view));
}
+ if(view instanceof CustomStyle) {
+ declarations.putAll(handleCustomStyle((CustomStyle)view, view));
+ }
+
return declarations;
}
@@ -264,6 +272,29 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return declarations;
}
+ //FIXME: Use constants for the CSS Properties names
+ //FIXME: Use a helper to determine whether the custom styles are computed or forced
+ protected Map<Declaration, Boolean> handleCustomStyle(CustomStyle customStyle, View view) {
+ Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
+
+ GMFToCSSConverter converter = GMFToCSSConverter.instance;
+
+ handleCustomStyle(view, "elementIcon", VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON, declarations, converter.convert(customStyle.showElementIcon()));
+ handleCustomStyle(view, "shadow", VisualInformationPapyrusConstants.SHADOWFIGURE, declarations, converter.convert(customStyle.showShadow()));
+ handleCustomStyle(view, "qualifiedNameDepth", VisualInformationPapyrusConstants.QUALIFIED_NAME, declarations, converter.convert(customStyle.getQualifiedNameDepth()));
+
+ return declarations;
+ }
+
+ protected void handleCustomStyle(View view, String cssProperty, String eAnnotationName, Map<Declaration, Boolean> result, Expression value) {
+ Declaration cssDeclaration = CssFactory.eINSTANCE.createDeclaration();
+ cssDeclaration.setProperty(cssProperty);
+ cssDeclaration.setExpression(value);
+
+ boolean check = view.getEAnnotation(eAnnotationName) != null;
+ result.put(cssDeclaration, check);
+ }
+
protected Declaration handleStyleFeature(Style style, EStructuralFeature feature) {
Declaration declaration = CssFactory.eINSTANCE.createDeclaration();
declaration.setProperty(feature.getName());

Back to the top