Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml2
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSClassContentProvider.java290
3 files changed, 148 insertions, 146 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF
index 2d026df0412..b107146f95f 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF
@@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.e4.ui.css.core;bundle-version="[0.11.0,1.0.0)",
org.eclipse.papyrus.infra.properties;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.css.Activator
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml
index 53faaef5c36..dad34a5ce59 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.gmfdiag.css</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSClassContentProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSClassContentProvider.java
index ecd7d1e95ed..ec0f067cfa7 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSClassContentProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSClassContentProvider.java
@@ -1,144 +1,146 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.provider;
-
-import java.text.Collator;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.e4.ui.css.core.impl.dom.CSSStyleRuleImpl;
-import org.eclipse.e4.ui.css.core.impl.sac.CSSClassConditionImpl;
-import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
-import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
-import org.w3c.css.sac.CombinatorCondition;
-import org.w3c.css.sac.Condition;
-import org.w3c.css.sac.ConditionalSelector;
-import org.w3c.css.sac.DescendantSelector;
-import org.w3c.css.sac.ElementSelector;
-import org.w3c.css.sac.Selector;
-import org.w3c.css.sac.SiblingSelector;
-import org.w3c.dom.css.CSSRule;
-import org.w3c.dom.css.CSSStyleSheet;
-
-/**
- * A ContentProvider which retrieves the available CSS Classes to be applied
- * on the selected element. The classes are retrieved from the current css
- * engine's stylesheets.
- *
- * The resulting classes are sorted alphabetically.
- *
- * @author Camille Letavernier
- *
- */
-@SuppressWarnings("restriction")
-public class CSSClassContentProvider extends AbstractStaticContentProvider {
-
- private String elementName;
-
- private ExtendedCSSEngine engine;
-
- /**
- *
- * @param elementName
- * The localName of the element (Typically, the semantic metaclass name or diagram type)
- * @param engine
- * The stylesheets of this CSS Engine will be used to retrieve compatible CSS Classes
- */
- public CSSClassContentProvider(String elementName, ExtendedCSSEngine engine) {
- this.elementName = elementName;
- this.engine = engine;
- }
-
- @Override
- public Object[] getElements() {
- return getAvailableClasses().toArray();
- }
-
- /**
- * Returns a sorted collection of CSS Classes compatible with the element
- *
- * @return
- */
- public Collection<String> getAvailableClasses() {
- Set<String> result = new TreeSet<String>(Collator.getInstance());
-
- for (org.w3c.dom.stylesheets.StyleSheet stylesheet : engine.getAllStylesheets()) {
- if (stylesheet instanceof CSSStyleSheet) {
- CSSStyleSheet cssStylesheet = (CSSStyleSheet) stylesheet;
- for (int i = 0; i < cssStylesheet.getCssRules().getLength(); i++) {
- CSSRule cssRule = cssStylesheet.getCssRules().item(i);
- if (cssRule instanceof CSSStyleRuleImpl) {
- CSSStyleRuleImpl rule = (CSSStyleRuleImpl) cssRule;
-
- for (int j = 0; j < rule.getSelectorList().getLength(); j++) {
- Selector selector = rule.getSelectorList().item(j);
-
- result.addAll(findClassesFromSelector(selector));
- }
- }
- }
- }
- }
-
- return result;
- }
-
- private List<String> findClassesFromSelector(Selector selector) {
- List<String> result = new LinkedList<String>();
- if (selector instanceof ConditionalSelector) {
- result.addAll(findClassesFromSelector((ConditionalSelector) selector));
- } else if (selector instanceof DescendantSelector) { // A B | A > B
- result.addAll(findClassesFromSelector(((DescendantSelector) selector).getSimpleSelector()));
- result.addAll(findClassesFromSelector(((DescendantSelector) selector).getAncestorSelector()));
- } else if (selector instanceof SiblingSelector) { // A + B
- result.addAll(findClassesFromSelector(((SiblingSelector) selector).getSelector()));
- result.addAll(findClassesFromSelector(((SiblingSelector) selector).getSiblingSelector()));
- }
- return result;
- }
-
- private List<String> findClassesFromSelector(ConditionalSelector selector) {
- List<String> result = new LinkedList<String>();
-
- Selector simpleSelector = selector.getSimpleSelector();
-
- if (simpleSelector instanceof ElementSelector) {
- ElementSelector elementSelector = (ElementSelector) simpleSelector;
- String localName = elementSelector.getLocalName();
- if ("*".equals(localName) || "*".equals(elementName) || elementName.equals(localName) || localName == null) {
- Condition condition = selector.getCondition();
- result.addAll(findClassesFromCondition(condition));
- }
- }
-
- return result;
- }
-
- private List<String> findClassesFromCondition(Condition condition) {
- if (condition instanceof CSSClassConditionImpl) {
- return Collections.singletonList(((CSSClassConditionImpl) condition).getValue());
- } else if (condition instanceof CombinatorCondition) {
- CombinatorCondition combinatorCondition = (CombinatorCondition) condition;
- List<String> result = new LinkedList<String>();
- result.addAll(findClassesFromCondition(combinatorCondition.getFirstCondition()));
- result.addAll(findClassesFromCondition(combinatorCondition.getSecondCondition()));
- return result;
- }
-
- return Collections.emptyList();
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2016 CEA LIST, Esterel Technologies SAS and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Sebastien Gabel (Esterel Technologies SAS) - Bug 497487
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.css.provider;
+
+import java.text.Collator;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.e4.ui.css.core.impl.dom.CSSStyleRuleImpl;
+import org.eclipse.e4.ui.css.core.impl.sac.CSSClassConditionImpl;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
+import org.w3c.css.sac.CombinatorCondition;
+import org.w3c.css.sac.Condition;
+import org.w3c.css.sac.ConditionalSelector;
+import org.w3c.css.sac.DescendantSelector;
+import org.w3c.css.sac.ElementSelector;
+import org.w3c.css.sac.Selector;
+import org.w3c.css.sac.SiblingSelector;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSStyleSheet;
+
+/**
+ * A ContentProvider which retrieves the available CSS Classes to be applied
+ * on the selected element. The classes are retrieved from the current css
+ * engine's stylesheets.
+ *
+ * The resulting classes are sorted alphabetically.
+ *
+ * @author Camille Letavernier
+ *
+ */
+@SuppressWarnings("restriction")
+public class CSSClassContentProvider extends AbstractStaticContentProvider {
+
+ private String elementName;
+
+ private ExtendedCSSEngine engine;
+
+ /**
+ *
+ * @param elementName
+ * The localName of the element (Typically, the semantic metaclass name or diagram type)
+ * @param engine
+ * The stylesheets of this CSS Engine will be used to retrieve compatible CSS Classes
+ */
+ public CSSClassContentProvider(String elementName, ExtendedCSSEngine engine) {
+ this.elementName = elementName;
+ this.engine = engine;
+ }
+
+ @Override
+ public Object[] getElements() {
+ return getAvailableClasses().toArray();
+ }
+
+ /**
+ * Returns a sorted collection of CSS Classes compatible with the element
+ *
+ * @return
+ */
+ public Collection<String> getAvailableClasses() {
+ Set<String> result = new TreeSet<String>(Collator.getInstance());
+
+ for (org.w3c.dom.stylesheets.StyleSheet stylesheet : engine.getAllStylesheets()) {
+ if (stylesheet instanceof CSSStyleSheet) {
+ CSSStyleSheet cssStylesheet = (CSSStyleSheet) stylesheet;
+ for (int i = 0; i < cssStylesheet.getCssRules().getLength(); i++) {
+ CSSRule cssRule = cssStylesheet.getCssRules().item(i);
+ if (cssRule instanceof CSSStyleRuleImpl) {
+ CSSStyleRuleImpl rule = (CSSStyleRuleImpl) cssRule;
+
+ for (int j = 0; j < rule.getSelectorList().getLength(); j++) {
+ Selector selector = rule.getSelectorList().item(j);
+
+ result.addAll(findClassesFromSelector(selector));
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ protected List<String> findClassesFromSelector(Selector selector) {
+ List<String> result = new LinkedList<String>();
+ if (selector instanceof ConditionalSelector) {
+ result.addAll(findClassesFromSelector((ConditionalSelector) selector));
+ } else if (selector instanceof DescendantSelector) { // A B | A > B
+ result.addAll(findClassesFromSelector(((DescendantSelector) selector).getSimpleSelector()));
+ result.addAll(findClassesFromSelector(((DescendantSelector) selector).getAncestorSelector()));
+ } else if (selector instanceof SiblingSelector) { // A + B
+ result.addAll(findClassesFromSelector(((SiblingSelector) selector).getSelector()));
+ result.addAll(findClassesFromSelector(((SiblingSelector) selector).getSiblingSelector()));
+ }
+ return result;
+ }
+
+ protected List<String> findClassesFromSelector(ConditionalSelector selector) {
+ List<String> result = new LinkedList<String>();
+
+ Selector simpleSelector = selector.getSimpleSelector();
+
+ if (simpleSelector instanceof ElementSelector) {
+ ElementSelector elementSelector = (ElementSelector) simpleSelector;
+ String localName = elementSelector.getLocalName();
+ if ("*".equals(localName) || "*".equals(elementName) || elementName.equals(localName) || localName == null) {
+ Condition condition = selector.getCondition();
+ result.addAll(findClassesFromCondition(condition));
+ }
+ }
+
+ return result;
+ }
+
+ protected List<String> findClassesFromCondition(Condition condition) {
+ if (condition instanceof CSSClassConditionImpl) {
+ return Collections.singletonList(((CSSClassConditionImpl) condition).getValue());
+ } else if (condition instanceof CombinatorCondition) {
+ CombinatorCondition combinatorCondition = (CombinatorCondition) condition;
+ List<String> result = new LinkedList<String>();
+ result.addAll(findClassesFromCondition(combinatorCondition.getFirstCondition()));
+ result.addAll(findClassesFromCondition(combinatorCondition.getSecondCondition()));
+ return result;
+ }
+
+ return Collections.emptyList();
+ }
+
+}

Back to the top