Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-03-10 09:43:55 -0400
committerCamille Letavernier2015-03-24 10:41:36 -0400
commit826133abc636732699e6e3d7d4a3942e5d8b1221 (patch)
treecf6da1965225f56bc85af581110a575038acfb8a /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src
parentd231c12d87a551317c41a646e111166c86857d8d (diff)
downloadorg.eclipse.papyrus-826133abc636732699e6e3d7d4a3942e5d8b1221.tar.gz
org.eclipse.papyrus-826133abc636732699e6e3d7d4a3942e5d8b1221.tar.xz
org.eclipse.papyrus-826133abc636732699e6e3d7d4a3942e5d8b1221.zip
462969: [CSS3] Update Papyrus tooling to use the new CSS3 XText grammar
https://bugs.eclipse.org/bugs/show_bug.cgi?id=462969
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.java141
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java169
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java26
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java18
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java101
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java9
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java89
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java41
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java12
9 files changed, 323 insertions, 283 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 a95c96b1579..39b2d141631 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
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
import static org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.DiagramTypeHelper.getDiagramType;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -25,19 +26,19 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
-import org.eclipse.papyrus.infra.gmfdiag.css.AttributeValue;
-import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
-import org.eclipse.papyrus.infra.gmfdiag.css.Expression;
-import org.eclipse.papyrus.infra.gmfdiag.css.HexColor;
-import org.eclipse.papyrus.infra.gmfdiag.css.Name;
-import org.eclipse.papyrus.infra.gmfdiag.css.Number;
-import org.eclipse.papyrus.infra.gmfdiag.css.SelectorCondition;
-import org.eclipse.papyrus.infra.gmfdiag.css.StringValue;
-import org.eclipse.papyrus.infra.gmfdiag.css.Subterm;
-import org.eclipse.papyrus.infra.gmfdiag.css.Term;
import org.eclipse.papyrus.infra.gmfdiag.css.converters.ColorToGMFConverter;
-import org.eclipse.papyrus.infra.gmfdiag.css.util.CssSwitch;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ColorTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.IdentifierTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.NumberTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.StringTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.SymbolTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.UrlTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_property;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.simple_selector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.util.CSSSwitch;
import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
import org.eclipse.papyrus.infra.widgets.editors.BooleanCheckbox;
import org.eclipse.papyrus.infra.widgets.editors.EnumRadio;
@@ -63,9 +64,9 @@ import org.w3c.dom.css.RGBColor;
public abstract class AbstractStyleDialog extends TrayDialog {
- protected final Map<Attribute, Boolean> conditions;
+ protected final Map<AttributeSelector, Boolean> conditions;
- protected final Map<Declaration, Boolean> declarations;
+ protected final Map<css_declaration, Boolean> declarations;
protected final String selectorName;
@@ -87,7 +88,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
protected Composite declarationsContainer;
- public AbstractStyleDialog(Shell shell, Map<Attribute, Boolean> conditions, Map<Declaration, Boolean> declarations, String selectorName, View context) {
+ public AbstractStyleDialog(Shell shell, Map<AttributeSelector, Boolean> conditions, Map<css_declaration, Boolean> declarations, String selectorName, View context) {
super(shell);
this.conditions = conditions;
this.declarations = declarations;
@@ -221,6 +222,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
diagramRestrictionWidget.setValue(this.diagramRestriction);
diagramRestrictionWidget.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
diagramRestriction = (Boolean) ((EnumRadio) editor).getValue();
updateSelectorLabel();
@@ -243,6 +245,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
selectorNameWidget.setValue(this.useSelectorName);
selectorNameWidget.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
useSelectorName = (Boolean) ((EnumRadio) editor).getValue();
updateSelectorLabel();
@@ -259,12 +262,10 @@ public abstract class AbstractStyleDialog extends TrayDialog {
detailLabel.setText("If the following properties are matched:");
detailLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
- for (SelectorCondition condition : conditions.keySet()) {
- final Attribute currentCondition = (Attribute) condition;
-
+ for (final AttributeSelector currentCondition : conditions.keySet()) {
String attributeLabel = currentCondition.getName();
if (currentCondition.getValue() != null) {
- attributeLabel += " " + currentCondition.getValue().getOperator() + " " + currentCondition.getValue().getValue();
+ attributeLabel += " " + currentCondition.getOp() + " " + currentCondition.getValue();
}
BooleanCheckbox checkbox = new BooleanCheckbox(parent, SWT.NONE, attributeLabel);
@@ -272,6 +273,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
checkbox.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
conditions.put(currentCondition, ((BooleanCheckbox) editor).getValue());
updateSelectorLabel();
@@ -293,6 +295,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
styleNameEditor.setValue(cssClass);
styleNameEditor.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
cssClass = (String) ((StringEditor) editor).getValue();
updateSelectorLabel();
@@ -308,7 +311,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
declarationsLabel.setText("Select the properties you want to set. Unchecked properties will keep their default value\n (Which might be inherited from another style).");
declarationsLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
- for (Declaration declaration : declarations.keySet()) {
+ for (css_declaration declaration : declarations.keySet()) {
// Separate checkbox and label (Checkbox - Label) - (Checkbox - Label) - (Checkbox - Label)
// This is required to paint a custom foreground color on non-classic windows Theme
// Checkboxes do not support foreground color on Windows, except for the Classic theme
@@ -319,7 +322,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
propertyComposite.setLayout(compositeLayout);
propertyComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- String label = declaration.getProperty() + ": " + getLabel(declaration.getExpression());
+ String label = declaration.getProperty().getName() + ": " + getLabel(declaration.getValueTokens());
final BooleanCheckbox checkbox = new BooleanCheckbox(propertyComposite, SWT.NONE);
checkbox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
@@ -337,16 +340,17 @@ public abstract class AbstractStyleDialog extends TrayDialog {
propertyComposite.addMouseListener(listener);
labelWidget.addMouseListener(listener);
- Color[] colors = getColors(declaration.getExpression());
+ Color[] colors = getColors(declaration.getValueTokens());
propertyComposite.setBackground(colors[0]);
labelWidget.setForeground(colors[1]);
- final Declaration currentDeclaration = declaration;
+ final css_declaration currentDeclaration = declaration;
checkbox.setValue(declarations.get(currentDeclaration));
checkbox.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
boolean value = ((BooleanCheckbox) editor).getValue();
declarations.put(currentDeclaration, value);
@@ -358,23 +362,17 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
}
- protected Color[] getColors(Expression expression) {
- Term term = expression.getTerms();
- if (term instanceof HexColor) {
- HexColor hexColor = (HexColor) term;
- return getColors(hexColor);
- }
-
- for (Subterm subterm : expression.getSubterms()) {
- if (subterm.getTerm() instanceof HexColor) {
- return getColors((HexColor) subterm.getTerm());
+ protected Color[] getColors(List<CssTok> expression) {
+ for (CssTok subterm : expression) {
+ if (subterm instanceof ColorTok) {
+ return getColors((ColorTok) subterm);
}
}
return new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
}
- protected Color[] getColors(HexColor hexColor) {
+ protected Color[] getColors(ColorTok hexColor) {
Color[] colors = new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
Color color = getColor(hexColor);
@@ -395,8 +393,8 @@ public abstract class AbstractStyleDialog extends TrayDialog {
return L;
}
- protected Color getColor(HexColor color) {
- RGBColor rgbColor = CSS2ColorHelper.getRGBColor("#" + color.getValue());
+ protected Color getColor(ColorTok color) {
+ RGBColor rgbColor = CSS2ColorHelper.getRGBColor(color.getValue());
int intColor = ColorToGMFConverter.getIntColor(rgbColor);
return ColorRegistry.getInstance().getColor(intColor);
}
@@ -408,47 +406,54 @@ public abstract class AbstractStyleDialog extends TrayDialog {
return null;
}
- protected String getLabel(Expression expression) {
- if (expression == null) {
+ protected String getLabel(List<CssTok> expression) {
+ if (expression == null || expression.isEmpty()) {
return "";
}
- String label = getLabel(expression.getTerms());
- for (Subterm subTerm : expression.getSubterms()) {
- if (subTerm.getOperator() != null) {
- label += subTerm.getOperator();
+
+ String label = "";
+ for (CssTok token : expression) {
+ if (token instanceof SymbolTok) {
+ label += ((SymbolTok) token).getSymbol();
+ } else {
+ label += " " + getLabel(token);
}
- label += " " + getLabel(subTerm.getTerm());
}
- return label;
+
+ return label.trim().replaceAll("[ ]+", " ");
}
- protected String getLabel(Term term) {
- return (new CssSwitch<String>() {
+ protected String getLabel(CssTok term) {
+ return (new CSSSwitch<String>() {
@Override
- public String caseHexColor(HexColor term) {
- return '#' + term.getValue();
+ public String caseColorTok(ColorTok token) {
+ return token.getValue();
}
@Override
- public String caseName(Name term) {
- return term.getValue();
+ public String caseIdentifierTok(IdentifierTok token) {
+ return token.getName();
}
@Override
- public String caseStringValue(StringValue term) {
- return "\"" + term.getValue() + "\"";
+ public String caseStringTok(StringTok token) {
+ return token.getValue();
}
@Override
- public String caseNumber(Number term) {
- String label = "";
- if (term.getOp() != null) {
- label += term.getOp().getOperator();
- }
- label += term.getValue();
+ public String caseNumberTok(NumberTok token) {
+ return Double.toString(token.getVal());
+ }
+
+ @Override
+ public String caseUrlTok(UrlTok token) {
+ String label = "url('";
+ label += token.getUrl().getUrl();
+ label += "')";
return label;
}
+
}).doSwitch(term);
}
@@ -461,12 +466,11 @@ public abstract class AbstractStyleDialog extends TrayDialog {
selectorText += useSelectorName ? selectorName : "*";
- for (Entry<Attribute, Boolean> selectorEntry : conditions.entrySet()) {
+ for (Entry<AttributeSelector, Boolean> selectorEntry : conditions.entrySet()) {
if (selectorEntry.getValue()) {
- Attribute condition = selectorEntry.getKey();
- Attribute attribute = condition;
- AttributeValue value = attribute.getValue();
- selectorText += "[" + attribute.getName() + value.getOperator() + value.getValue() + "]";
+ AttributeSelector condition = selectorEntry.getKey();
+
+ selectorText += "[" + condition.getName() + condition.getOp() + condition.getValue() + "]";
}
}
@@ -496,5 +500,16 @@ public abstract class AbstractStyleDialog extends TrayDialog {
return diagramRestriction;
}
+ protected final boolean equals(css_property p1, css_property p2) {
+ return p1.getName().equals(p2.getName());
+ }
+
+ protected final String getElementName(simple_selector simpleSelector) {
+ if (simpleSelector.getElement() != null) {
+ return simpleSelector.getElement().getName();
+ } else {
+ return "*";
+ }
+ }
}
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 a433250fa35..5b1ae8f64d8 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
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
@@ -44,20 +45,22 @@ import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusC
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramHelper;
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;
-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.engine.BaseCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.provider.CustomStyle;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CSSFactory;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ClassSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ElementSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.charset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_property;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.selector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.simple_selector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.stylesheet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Event;
@@ -66,6 +69,7 @@ import org.eclipse.swt.widgets.Shell;
public abstract class AbstractStyleHandler extends AbstractHandler {
+ @Override
public Object execute(ExecutionEvent event) {
ISelection selection;
try {
@@ -98,8 +102,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return null;
}
- Map<Declaration, Boolean> declarations = handleStyles(view);
- Map<Attribute, Boolean> conditions = handleSemantic(view);
+ Map<css_declaration, Boolean> declarations = handleStyles(view);
+ Map<AttributeSelector, Boolean> conditions = handleSemantic(view);
String selectorName = view.getElement().eClass().getName();
@@ -109,49 +113,47 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return null;
}
- Ruleset ruleset = getRuleset(dialog);
- SimpleSelector selector = CssFactory.eINSTANCE.createSimpleSelector();
+ ruleset ruleset = getRuleset(dialog);
+ selector baseSelector = CSSFactory.eINSTANCE.createselector();
+ simple_selector simple_selector = createSimpleElementSelector(selectorName, dialog.useSelectorName());
- if (dialog.useSelectorName()) {
- selector.setElementName(selectorName);
- } else {
- selector.setElementName("*"); //$NON-NLS-1$
- }
+ baseSelector.getSimpleselectors().add(simple_selector);
if (dialog.getDiagramRestriction()) {
String diagramType = getDiagramType(view.getDiagram());
- CompositeSelector compositeSelector = CssFactory.eINSTANCE.createCompositeSelector();
- compositeSelector.setRight(selector);
+ selector compositeSelector = CSSFactory.eINSTANCE.createselector();
+ compositeSelector.setSelector(baseSelector);
+
- SimpleSelector diagramSelector = CssFactory.eINSTANCE.createSimpleSelector();
- diagramSelector.setElementName(diagramType);
- compositeSelector.setLeft(diagramSelector);
+ simple_selector diagramSelector = createSimpleElementSelector(diagramType, false);
+
+ compositeSelector.getSimpleselectors().add(diagramSelector);
ruleset.getSelectors().add(compositeSelector);
} else {
- ruleset.getSelectors().add(selector);
+ ruleset.getSelectors().add(baseSelector);
}
if (dialog.getCSSClass() != null) {
String cssClass = dialog.getCSSClass();
- org.eclipse.papyrus.infra.gmfdiag.css.Class classCondition = CssFactory.eINSTANCE.createClass();
- classCondition.setClass(cssClass);
- selector.getCondition().add(classCondition);
+ ClassSelector classCondition = CSSFactory.eINSTANCE.createClassSelector();
+ classCondition.setName(cssClass);
+ simple_selector.getSubSelectors().add(classCondition);
}
- for (SelectorCondition condition : conditions.keySet()) {
+ for (CssSelector condition : conditions.keySet()) {
if (conditions.get(condition)) {
- selector.getCondition().add(condition);
+ simple_selector.getSubSelectors().add(condition);
}
}
- for (Declaration declaration : declarations.keySet()) {
+ for (css_declaration declaration : declarations.keySet()) {
if (declarations.get(declaration)) {
- ruleset.getProperties().add(declaration);
+ ruleset.getDeclarations().add(declaration);
}
}
- Stylesheet xtextStylesheet = getStyleSheet(dialog, view);
+ stylesheet xtextStylesheet = getStyleSheet(dialog, view);
if (xtextStylesheet == null) {
return null;
@@ -159,8 +161,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
Resource resource = xtextStylesheet.eResource();
- if (!xtextStylesheet.getContents().contains(ruleset)) {
- xtextStylesheet.getContents().add(ruleset);
+ if (!xtextStylesheet.getRuleset().contains(ruleset)) {
+ xtextStylesheet.getRuleset().add(ruleset);
}
try {
@@ -179,14 +181,28 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return null;
}
- protected abstract AbstractStyleDialog createStyleDialog(Shell shell, Map<Declaration, Boolean> declarations, Map<Attribute, Boolean> conditions, String selectorName, View context);
+ protected simple_selector createSimpleElementSelector(String elementName, boolean universal) {
+ simple_selector simple_selector = CSSFactory.eINSTANCE.createsimple_selector();
- protected abstract Ruleset getRuleset(AbstractStyleDialog dialog);
+ if (universal) {
+ simple_selector.setUniversal(CSSFactory.eINSTANCE.createUniversalSelector());
+ } else {
+ ElementSelector elementSelector = CSSFactory.eINSTANCE.createElementSelector();
+ elementSelector.setName(elementName);
+ simple_selector.setElement(elementSelector);
+ }
- protected abstract Stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView);
+ return simple_selector;
+ }
+
+ protected abstract AbstractStyleDialog createStyleDialog(Shell shell, Map<css_declaration, Boolean> declarations, Map<AttributeSelector, Boolean> conditions, String selectorName, View context);
+
+ protected abstract ruleset getRuleset(AbstractStyleDialog dialog);
- protected Map<Declaration, Boolean> handleStyles(View view) {
- Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
+ protected abstract stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView);
+
+ protected Map<css_declaration, Boolean> handleStyles(View view) {
+ Map<css_declaration, Boolean> declarations = new LinkedHashMap<css_declaration, Boolean>();
for (Object styleObject : view.getStyles()) {
Style style = (Style) styleObject;
@@ -204,20 +220,18 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return declarations;
}
- protected Map<Attribute, Boolean> handleSemantic(View view) {
- Map<Attribute, Boolean> result = new LinkedHashMap<Attribute, Boolean>();
+ protected Map<AttributeSelector, Boolean> handleSemantic(View view) {
+ Map<AttributeSelector, Boolean> result = new LinkedHashMap<AttributeSelector, Boolean>();
EObject semanticElement = view.getElement();
for (EStructuralFeature feature : semanticElement.eClass().getEAllStructuralFeatures()) {
if (isBoolean(feature) || isInteger(feature) || feature.getEType() instanceof EEnum) {
- Attribute attributeCondition = CssFactory.eINSTANCE.createAttribute();
- attributeCondition.setName(feature.getName());
+ AttributeSelector attributeCondition = CSSFactory.eINSTANCE.createAttributeSelector();
- AttributeValue attributeValue = CssFactory.eINSTANCE.createAttributeValue();
- attributeValue.setOperator(ATTRIBUTE_OP.EQUALS);
- attributeValue.setValue(semanticElement.eGet(feature).toString());
- attributeCondition.setValue(attributeValue);
+ attributeCondition.setName(feature.getName());
+ attributeCondition.setOp("=");
+ attributeCondition.setValue(semanticElement.eGet(feature).toString());
boolean check = semanticElement.eGet(feature) != feature.getDefaultValue();
@@ -258,12 +272,12 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return false;
}
- protected Map<Declaration, Boolean> handleStyle(Style style) {
+ protected Map<css_declaration, Boolean> handleStyle(Style style) {
if (style instanceof NamedStyle) {
return Collections.emptyMap();
}
- Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
+ Map<css_declaration, Boolean> declarations = new LinkedHashMap<css_declaration, Boolean>();
for (EStructuralFeature feature : style.eClass().getEAllStructuralFeatures()) {
if (NotationPackage.eINSTANCE.getStyle().isSuperTypeOf(feature.getEContainingClass())) {
@@ -271,8 +285,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
Object defaultValue = feature.getDefaultValue();
boolean check = currentValue == null ? currentValue != defaultValue : !currentValue.equals(defaultValue);
- Declaration declaration = handleStyleFeature(style, feature);
- if (declaration.getExpression() != null) { // If expression is null, the type of this property is not supported
+ css_declaration declaration = handleStyleFeature(style, feature);
+ if (!declaration.getValueTokens().isEmpty()) { // If expression is null, the type of this property is not supported
declarations.put(declaration, check);
}
}
@@ -283,8 +297,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
// 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>();
+ protected Map<css_declaration, Boolean> handleCustomStyle(CustomStyle customStyle, View view) {
+ Map<css_declaration, Boolean> declarations = new LinkedHashMap<css_declaration, Boolean>();
GMFToCSSConverter converter = GMFToCSSConverter.instance;
@@ -295,48 +309,67 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
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);
+ protected void handleCustomStyle(View view, String cssProperty, String eAnnotationName, Map<css_declaration, Boolean> result, List<CssTok> expression) {
+ css_declaration cssDeclaration = CSSFactory.eINSTANCE.createcss_declaration();
+
+ setProperty(cssDeclaration, cssProperty);
+
+ setValueTokens(cssDeclaration, expression);
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());
+ protected css_declaration handleStyleFeature(Style style, EStructuralFeature feature) {
+ css_declaration declaration = CSSFactory.eINSTANCE.createcss_declaration();
+
+ setProperty(declaration, feature.getName());
GMFToCSSConverter converter = GMFToCSSConverter.instance;
if (isString(feature)) {
- declaration.setExpression(converter.convert((String) style.eGet(feature)));
+ setValueTokens(declaration, converter.convert((String) style.eGet(feature)));
}
if (isInteger(feature)) {
if (feature.getName().endsWith("Color")) {
Color color = FigureUtilities.integerToColor((Integer) style.eGet(feature));
- declaration.setExpression(converter.convert(color));
+ setValueTokens(declaration, converter.convert(color));
color.dispose();
} else {
- declaration.setExpression(converter.convert((Integer) style.eGet(feature)));
+ setValueTokens(declaration, converter.convert((Integer) style.eGet(feature)));
}
}
if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
- declaration.setExpression(converter.convert((GradientData) style.eGet(feature)));
+ setValueTokens(declaration, converter.convert((GradientData) style.eGet(feature)));
}
if (feature.getEType() instanceof EEnum) {
- declaration.setExpression(converter.convert((Enumerator) style.eGet(feature)));
+ setValueTokens(declaration, converter.convert((Enumerator) style.eGet(feature)));
}
if (isBoolean(feature)) {
- declaration.setExpression(converter.convert((Boolean) style.eGet(feature)));
+ setValueTokens(declaration, converter.convert((Boolean) style.eGet(feature)));
}
return declaration;
}
+ protected final void setProperty(css_declaration declaration, String property) {
+ css_property cssProperty = CSSFactory.eINSTANCE.createcss_property();
+ cssProperty.setName(property);
+ declaration.setProperty(cssProperty);
+ }
+
+ protected final void setValueTokens(css_declaration declaration, List<CssTok> tokens) {
+ declaration.getValueTokens().clear();
+ declaration.getValueTokens().addAll(tokens);
+ }
+
+ protected final void setCharset(stylesheet stylesheet, String charset) {
+ charset cssCharset = CSSFactory.eINSTANCE.createcharset();
+ cssCharset.setCharset(charset);
+ }
+
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
index 7fb52426147..6cf970b662d 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
@@ -16,14 +16,14 @@ import java.util.Map;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
-import org.eclipse.papyrus.infra.gmfdiag.css.CssFactory;
-import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
-import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
-import org.eclipse.papyrus.infra.gmfdiag.css.Stylesheet;
import org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.XtextStylesheetHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CSSFactory;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.stylesheet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
@@ -31,17 +31,17 @@ import org.eclipse.swt.widgets.Shell;
public class CreateStyleHandler extends AbstractStyleHandler {
@Override
- protected AbstractStyleDialog createStyleDialog(Shell shell, Map<Declaration, Boolean> declarations, Map<Attribute, Boolean> conditions, String selectorName, View context) {
+ protected AbstractStyleDialog createStyleDialog(Shell shell, Map<css_declaration, Boolean> declarations, Map<AttributeSelector, Boolean> conditions, String selectorName, View context) {
return new StyleCreationDialog(shell, conditions, declarations, selectorName, context);
}
@Override
- protected Ruleset getRuleset(AbstractStyleDialog dialog) {
- return CssFactory.eINSTANCE.createRuleset();
+ protected ruleset getRuleset(AbstractStyleDialog dialog) {
+ return CSSFactory.eINSTANCE.createruleset();
}
@Override
- protected Stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
+ protected stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
StyleSheet styleSheet = ((StyleCreationDialog) dialog).getStyleSheet();
if (styleSheet == null) {
@@ -61,14 +61,14 @@ public class CreateStyleHandler extends AbstractStyleHandler {
return null;
}
- Stylesheet xtextStylesheet;
+ stylesheet xtextStylesheet;
if (resource.getContents().isEmpty()) {
- xtextStylesheet = CssFactory.eINSTANCE.createStylesheet();
- xtextStylesheet.setCharset("UTF-8");
+ xtextStylesheet = CSSFactory.eINSTANCE.createstylesheet();
+ setCharset(xtextStylesheet, "UTF-8");
resource.getContents().add(xtextStylesheet);
} else {
- xtextStylesheet = (Stylesheet) resource.getContents().get(0);
+ xtextStylesheet = (stylesheet) resource.getContents().get(0);
}
return xtextStylesheet;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
index a7c4d66f481..a38ee96831e 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
@@ -14,30 +14,30 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
import java.util.Map;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
-import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
-import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
-import org.eclipse.papyrus.infra.gmfdiag.css.Stylesheet;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.stylesheet;
import org.eclipse.swt.widgets.Shell;
public class EditStyleHandler extends AbstractStyleHandler {
@Override
- protected AbstractStyleDialog createStyleDialog(Shell shell, Map<Declaration, Boolean> declarations, Map<Attribute, Boolean> conditions, String selectorName, View context) {
+ protected AbstractStyleDialog createStyleDialog(Shell shell, Map<css_declaration, Boolean> declarations, Map<AttributeSelector, Boolean> conditions, String selectorName, View context) {
return new StyleEditionDialog(shell, conditions, declarations, selectorName, context);
}
@Override
- protected Ruleset getRuleset(AbstractStyleDialog dialog) {
- Ruleset ruleset = ((StyleEditionDialog) dialog).getSelectedRuleset();
+ protected ruleset getRuleset(AbstractStyleDialog dialog) {
+ ruleset ruleset = ((StyleEditionDialog) dialog).getSelectedRuleset();
ruleset.getSelectors().clear();
- ruleset.getProperties().clear();
+ ruleset.getDeclarations().clear();
return ruleset;
}
@Override
- protected Stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
+ protected stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
return ((StyleEditionDialog) dialog).getStylesheet();
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
index 315e3e65de5..d9935897fe3 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
@@ -11,20 +11,19 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
+import java.util.LinkedList;
+import java.util.List;
+
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.notation.GradientStyle;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
-import org.eclipse.papyrus.infra.gmfdiag.css.CssFactory;
-import org.eclipse.papyrus.infra.gmfdiag.css.Expression;
-import org.eclipse.papyrus.infra.gmfdiag.css.HexColor;
-import org.eclipse.papyrus.infra.gmfdiag.css.Name;
-import org.eclipse.papyrus.infra.gmfdiag.css.Number;
-import org.eclipse.papyrus.infra.gmfdiag.css.StringValue;
-import org.eclipse.papyrus.infra.gmfdiag.css.Subterm;
-import org.eclipse.papyrus.infra.gmfdiag.css.Term;
-import org.eclipse.papyrus.infra.gmfdiag.css.UNARY;
-import org.eclipse.papyrus.infra.gmfdiag.css.UnaryOperator;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CSSFactory;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ColorTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.IdentifierTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.NumberTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.StringTok;
import org.eclipse.swt.graphics.Color;
@@ -36,22 +35,22 @@ public class GMFToCSSConverter {
}
- public Expression convert(Color color) {
- HexColor hexColor = getColor(color);
+ public List<CssTok> convert(Color color) {
+ ColorTok hexColor = getColor(color);
return getExpression(hexColor);
}
- private HexColor getColor(Color color) {
- HexColor hexColor = CssFactory.eINSTANCE.createHexColor();
+ private ColorTok getColor(Color color) {
+ ColorTok hexColor = CSSFactory.eINSTANCE.createColorTok();
String hexString = twoDigitsHexString(color.getRed()) + twoDigitsHexString(color.getGreen()) + twoDigitsHexString(color.getBlue());
- hexColor.setValue(hexString.toUpperCase());
+ hexColor.setValue("#" + hexString.toUpperCase());
return hexColor;
}
- private HexColor getColor(int color) {
+ private ColorTok getColor(int color) {
Color swtColor = FigureUtilities.integerToColor(color);
- HexColor result = getColor(swtColor);
+ ColorTok result = getColor(swtColor);
swtColor.dispose();
return result;
}
@@ -64,73 +63,67 @@ public class GMFToCSSConverter {
return hexString;
}
- public Expression convert(GradientData gradient) {
+ public List<CssTok> convert(GradientData gradient) {
if (gradient == null) {
- Name noGradient = CssFactory.eINSTANCE.createName();
- noGradient.setValue("none");
+ IdentifierTok noGradient = CSSFactory.eINSTANCE.createIdentifierTok();
+ noGradient.setName("none");
return getExpression(noGradient);
}
- HexColor gradientColor = getColor(gradient.getGradientColor1());
+ ColorTok gradientColor = getColor(gradient.getGradientColor1());
- Name gradientStyle = CssFactory.eINSTANCE.createName();
+ IdentifierTok gradientStyle = CSSFactory.eINSTANCE.createIdentifierTok();
int style = gradient.getGradientStyle();
if (style == GradientStyle.HORIZONTAL) {
- gradientStyle.setValue("horizontal");
+ gradientStyle.setName("horizontal");
} else {
- gradientStyle.setValue("vertical");
+ gradientStyle.setName("vertical");
}
return getExpression(gradientColor, gradientStyle);
}
- public Expression convert(String string) {
- StringValue stringValue = CssFactory.eINSTANCE.createStringValue();
- stringValue.setValue(string);
+ public List<CssTok> convert(String string) {
+ StringTok stringValue = CSSFactory.eINSTANCE.createStringTok();
+ stringValue.setValue("\"" + string + "\"");
return getExpression(stringValue);
}
- public Expression convert(Integer intValue) {
- Number numberValue = CssFactory.eINSTANCE.createNumber();
- numberValue.setValue(Integer.toString(Math.abs(intValue)));
- if (intValue < 0) {
- UnaryOperator operator = CssFactory.eINSTANCE.createUnaryOperator();
- operator.setOperator(UNARY.NEG);
- numberValue.setOp(operator);
- }
+ public List<CssTok> convert(Integer intValue) {
+ NumberTok numberValue = CSSFactory.eINSTANCE.createNumberTok();
+ numberValue.setVal(intValue);
+ // if (intValue < 0) {
+ // UnaryOperator operator = CssFactory.eINSTANCE.createUnaryOperator();
+ // operator.setOperator(UNARY.NEG);
+ // numberValue.setOp(operator);
+ // }
return getExpression(numberValue);
}
- public Expression convert(Enumerator enumerated) {
- Name literalValue = CssFactory.eINSTANCE.createName();
+ public List<CssTok> convert(Enumerator enumerated) {
+ IdentifierTok literalValue = CSSFactory.eINSTANCE.createIdentifierTok();
- literalValue.setValue(enumerated.getName());
+ literalValue.setName(enumerated.getName());
return getExpression(literalValue);
}
- private Expression getExpression(Term... values) {
- if (values.length == 0) {
- throw new IllegalArgumentException("An expression must contain at least one value");
- }
-
- Expression result = CssFactory.eINSTANCE.createExpression();
- result.setTerms(values[0]);
-
- for (int i = 1; i < values.length; i++) {
- Subterm subterm = CssFactory.eINSTANCE.createSubterm();
- subterm.setTerm(values[i]);
- result.getSubterms().add(subterm);
+ private List<CssTok> getExpression(CssTok... values) {
+ List<CssTok> result = new LinkedList<CssTok>();
+ for (CssTok value : values) {
+ if (!result.isEmpty()) {
+ result.add(CSSFactory.eINSTANCE.createWSTok());
+ }
+ result.add(value);
}
-
return result;
}
- public Expression convert(boolean booleanValue) {
- Name nameValue = CssFactory.eINSTANCE.createName();
- nameValue.setValue(booleanValue ? "true" : "false");
+ public List<CssTok> convert(boolean booleanValue) {
+ IdentifierTok nameValue = CSSFactory.eINSTANCE.createIdentifierTok();
+ nameValue.setName(booleanValue ? "true" : "false");
return getExpression(nameValue);
}
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
index 017a8d46c46..8a991ac6fc7 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
@@ -14,14 +14,14 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
import java.util.Map;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
-import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetContentProvider;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetLabelProvider;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsFactory;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
import org.eclipse.papyrus.infra.widgets.editors.ReferenceDialog;
@@ -59,7 +59,7 @@ public class StyleCreationDialog extends AbstractStyleDialog {
* inout
* @param selectorName
*/
- public StyleCreationDialog(Shell shell, Map<Attribute, Boolean> conditions, Map<Declaration, Boolean> declarations, String selectorName, View context) {
+ public StyleCreationDialog(Shell shell, Map<AttributeSelector, Boolean> conditions, Map<css_declaration, Boolean> declarations, String selectorName, View context) {
super(shell, conditions, declarations, selectorName, context);
}
@@ -116,6 +116,7 @@ public class StyleCreationDialog extends AbstractStyleDialog {
externalStylesheetEditor.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
externalStylesheetEditor.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
String path = (String) ((StringEditor) editor).getValue();
@@ -150,6 +151,7 @@ public class StyleCreationDialog extends AbstractStyleDialog {
embeddedStylesheetEditor.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
embeddedStylesheetEditor.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
// TODO: Check empty names & set the stylesheet to null when the name is null/empty
String name = (String) ((StringEditor) editor).getValue();
@@ -173,6 +175,7 @@ public class StyleCreationDialog extends AbstractStyleDialog {
appliedStylesheetEditor.setLabelProvider(new CSSStyleSheetLabelProvider());
appliedStylesheetEditor.addCommitListener(new ICommitListener() {
+ @Override
public void commit(AbstractEditor editor) {
StyleSheet value = (StyleSheet) ((ReferenceDialog) editor).getValue();
if (!(ignoreEvents && value == null)) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
index 2ad53e45167..18adf894298 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
@@ -22,17 +22,16 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.infra.gmfdiag.css.Attribute;
-import org.eclipse.papyrus.infra.gmfdiag.css.CompositeSelector;
-import org.eclipse.papyrus.infra.gmfdiag.css.CssPackage;
-import org.eclipse.papyrus.infra.gmfdiag.css.Declaration;
-import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
-import org.eclipse.papyrus.infra.gmfdiag.css.Selector;
-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.providers.ExistingStyleContentProvider;
import org.eclipse.papyrus.infra.gmfdiag.css.configuration.providers.StylesheetLabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.AttributeSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ClassSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.selector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.simple_selector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.stylesheet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
@@ -60,7 +59,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
protected Composite styleEditionPanel;
- protected Ruleset ruleset;
+ protected ruleset ruleset;
/**
*
@@ -71,7 +70,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
* inout
* @param selectorName
*/
- public StyleEditionDialog(Shell shell, Map<Attribute, Boolean> conditions, Map<Declaration, Boolean> declarations, String selectorName, View context) {
+ public StyleEditionDialog(Shell shell, Map<AttributeSelector, Boolean> conditions, Map<css_declaration, Boolean> declarations, String selectorName, View context) {
super(shell, conditions, declarations, selectorName, context);
}
@@ -126,17 +125,18 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
styleSelectionPanel.getParent().layout();
}
- protected Stylesheet getStylesheet() {
+ protected stylesheet getStylesheet() {
if (ruleset != null) {
- return (Stylesheet) ruleset.eContainer();
+ return (stylesheet) ruleset.eContainer();
}
return null;
}
- public Ruleset getSelectedRuleset() {
+ public ruleset getSelectedRuleset() {
return ruleset;
}
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
@@ -146,8 +146,8 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
if (selection instanceof IStructuredSelection) {
IStructuredSelection sSelection = (IStructuredSelection) selection;
Object selectedElement = sSelection.getFirstElement();
- if (selectedElement instanceof Ruleset) {
- handleSelectionChanged((Ruleset) selectedElement);
+ if (selectedElement instanceof ruleset) {
+ handleSelectionChanged((ruleset) selectedElement);
} else {
ruleset = null;
}
@@ -156,16 +156,16 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
updateButtons();
}
- protected void handleSelectionChanged(Ruleset selectedRuleset) {
+ protected void handleSelectionChanged(ruleset selectedRuleset) {
this.ruleset = selectedRuleset;
// Sets all conditions to false. They will be set to true if the selected style contains the same condition
- for (Attribute attribute : conditions.keySet()) {
+ for (AttributeSelector attribute : conditions.keySet()) {
conditions.put(attribute, false);
}
// Sets all properties to false. They will be set to true if the selected style contains the same property
- for (Declaration declaration : declarations.keySet()) {
+ for (css_declaration declaration : declarations.keySet()) {
declarations.put(declaration, false);
}
@@ -175,20 +175,20 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
cssClass = null;
- for (Selector selector : selectedRuleset.getSelectors()) {
+ for (selector selector : selectedRuleset.getSelectors()) {
handleSelector(selector);
}
- handleDeclarations(selectedRuleset.getProperties());
+ handleDeclarations(selectedRuleset.getDeclarations());
updateContents();
updateSelectorLabel();
}
- protected void handleDeclarations(List<Declaration> declarations) {
- for (Declaration declaration : declarations) {
- for (Declaration currentDeclaration : this.declarations.keySet()) {
- if (currentDeclaration.getProperty().equals(declaration.getProperty())) {
+ protected void handleDeclarations(List<css_declaration> declarations) {
+ for (css_declaration declaration : declarations) {
+ for (css_declaration currentDeclaration : this.declarations.keySet()) {
+ if (equals(currentDeclaration.getProperty(), declaration.getProperty())) {
this.declarations.put(currentDeclaration, true);
break;
}
@@ -196,34 +196,26 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
}
- protected void handleSelector(Selector selector) {
- if (selector instanceof SimpleSelector) {
- handleSelector((SimpleSelector) selector);
- } else if (selector instanceof CompositeSelector) {
- handleSelector((CompositeSelector) selector);
- }
- }
-
- protected void handleSelector(SimpleSelector selector) {
- if (getDiagramType(contextView.getDiagram()).equals(selector.getElementName())) {
+ protected void handleSelector(simple_selector selector) {
+ if (getDiagramType(contextView.getDiagram()).equals(getElementName(selector))) {
diagramRestriction = true;
}
- if (contextView.getElement().eClass().getName().equals(selector.getElementName())) {
+ if (contextView.getElement().eClass().getName().equals(getElementName(selector))) {
useSelectorName = true;
}
- for (SelectorCondition condition : selector.getCondition()) {
- if (condition instanceof Attribute) {
- Attribute existingAttribute = (Attribute) condition;
- for (Attribute selectedAttribute : conditions.keySet()) {
+ for (CssSelector condition : selector.getSubSelectors()) {
+ if (condition instanceof AttributeSelector) {
+ AttributeSelector existingAttribute = (AttributeSelector) condition;
+ for (AttributeSelector selectedAttribute : conditions.keySet()) {
if (existingAttribute.getName().equals(selectedAttribute.getName())) {
conditions.put(selectedAttribute, true);
break;
}
}
- } else if (condition.eClass() == CssPackage.eINSTANCE.getClass_()) {
- cssClass = ((org.eclipse.papyrus.infra.gmfdiag.css.Class) condition).getClass_();
+ } else if (condition instanceof ClassSelector) {
+ cssClass = ((ClassSelector) condition).getName();
}
}
}
@@ -247,9 +239,16 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
}
- protected void handleSelector(CompositeSelector selector) {
- handleSelector(selector.getLeft());
- handleSelector(selector.getRight());
+ protected void handleSelector(selector selector) {
+ if (selector == null) {
+ return;
+ }
+
+ for (simple_selector simpleSelector : selector.getSimpleselectors()) {
+ handleSelector(simpleSelector);
+ }
+
+ handleSelector(selector.getSelector());
}
@Override
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
index fb54c330335..c4fc5919385 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
@@ -13,7 +13,6 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.providers;
import java.util.Collection;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -21,20 +20,19 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.gmfdiag.css.Content;
-import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
-import org.eclipse.papyrus.infra.gmfdiag.css.Stylesheet;
import org.eclipse.papyrus.infra.gmfdiag.css.configuration.helper.XtextStylesheetHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.stylesheet;
import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
public class ExistingStyleContentProvider implements IHierarchicContentProvider {
- protected Map<StyleSheet, Stylesheet> stylesheets;
+ protected Map<StyleSheet, stylesheet> stylesheets;
protected final View context;
@@ -42,6 +40,7 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
this.context = context;
}
+ @Override
public Object[] getElements(Object inputElement) {
Collection<StyleSheet> stylesheets = getStyleSheets();
if (stylesheets.isEmpty()) {
@@ -51,55 +50,53 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
return stylesheets.toArray();
}
+ @Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof StyleSheet) {
- Stylesheet xtextStylesheet = stylesheets.get(parentElement);
+ stylesheet xtextStylesheet = stylesheets.get(parentElement);
- List<Ruleset> result = new LinkedList<Ruleset>();
-
- for (Content stylesheetElement : xtextStylesheet.getContents()) {
- if (stylesheetElement instanceof Ruleset) {
- result.add((Ruleset) stylesheetElement);
- }
- }
-
- return result.toArray();
+ return xtextStylesheet.getRuleset().toArray();
} else {
return new Object[0];
}
}
+ @Override
public Object getParent(Object element) {
- if (element instanceof Stylesheet) {
+ if (element instanceof stylesheet) {
return null;
}
- if (element instanceof Ruleset) {
- return ((Ruleset) element).eContainer();
+ if (element instanceof ruleset) {
+ return ((ruleset) element).eContainer();
}
return null;
}
+ @Override
public boolean hasChildren(Object element) {
return getChildren(element).length > 0;
}
+ @Override
public void dispose() {
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
+ @Override
public boolean isValidValue(Object element) {
- return element instanceof Ruleset;
+ return element instanceof ruleset;
}
protected Collection<StyleSheet> getStyleSheets() {
if (stylesheets == null) {
- stylesheets = new LinkedHashMap<StyleSheet, Stylesheet>();
+ stylesheets = new LinkedHashMap<StyleSheet, stylesheet>();
if (context.getDiagram() instanceof CSSDiagram) {
CSSDiagram diagram = (CSSDiagram) context.getDiagram();
parseStyleSheets(diagram.getStyleSheets());
@@ -125,8 +122,8 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
}
for (EObject rootElement : resource.getContents()) {
- if (rootElement instanceof Stylesheet) {
- stylesheets.put(stylesheet, (Stylesheet) rootElement);
+ if (rootElement instanceof stylesheet) {
+ stylesheets.put(stylesheet, (stylesheet) rootElement);
}
}
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
index 976617b27e6..cd5f351fbd5 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
@@ -12,10 +12,10 @@
package org.eclipse.papyrus.infra.gmfdiag.css.configuration.providers;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.infra.gmfdiag.CSSRuntimeModule;
-import org.eclipse.papyrus.infra.gmfdiag.css.Ruleset;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
+import org.eclipse.papyrus.infra.gmfdiag.css3.CSSRuntimeModule;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ruleset;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -40,8 +40,8 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
@Override
public String getText(Object element) {
- if (element instanceof Ruleset) {
- return getText((Ruleset) element);
+ if (element instanceof ruleset) {
+ return getText((ruleset) element);
}
if (element instanceof StyleSheetReference) {
@@ -55,7 +55,7 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
return super.getText(element);
}
- public String getText(Ruleset ruleset) {
+ public String getText(ruleset ruleset) {
// Delegate the label to XText serialization
String label = "";
@@ -80,7 +80,7 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
@Override
public Color getForeground(Object element) {
- if (!(element instanceof Ruleset)) {
+ if (!(element instanceof ruleset)) {
return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
}
return super.getForeground(element);

Back to the top