diff options
author | cletavernie | 2012-04-27 13:47:49 +0000 |
---|---|---|
committer | cletavernie | 2012-04-27 13:47:49 +0000 |
commit | f21f8a96c6e2acbd83ecb4325e5c03fb583dda9c (patch) | |
tree | cd1852ec5194352f10e707b16b7d91ddd73fab78 | |
parent | 989416ac77f5b988f788429175af86797946f2db (diff) | |
download | org.eclipse.papyrus-f21f8a96c6e2acbd83ecb4325e5c03fb583dda9c.tar.gz org.eclipse.papyrus-f21f8a96c6e2acbd83ecb4325e5c03fb583dda9c.tar.xz org.eclipse.papyrus-f21f8a96c6e2acbd83ecb4325e5c03fb583dda9c.zip |
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
37 files changed, 438 insertions, 70 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/BooleanConverter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/BooleanConverter.java index bf0dcd0ec79..ab0200b8969 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/BooleanConverter.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/BooleanConverter.java @@ -18,6 +18,7 @@ import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.CSSValue;
+@SuppressWarnings("restriction")
public class BooleanConverter extends AbstractCSSValueConverter {
public BooleanConverter() {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/IntegerConverter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/IntegerConverter.java index aa0f15ad206..186cd4626a1 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/IntegerConverter.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/IntegerConverter.java @@ -18,7 +18,7 @@ import org.eclipse.e4.ui.css.core.impl.dom.Measure; import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;
-
+@SuppressWarnings("restriction")
public class IntegerConverter extends AbstractCSSValueConverter {
public IntegerConverter() {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/StringConverter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/StringConverter.java index c17671ad762..56fee00a7ad 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/StringConverter.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/converters/StringConverter.java @@ -17,7 +17,7 @@ import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;
-
+@SuppressWarnings("restriction")
public class StringConverter extends AbstractCSSValueConverter {
public StringConverter() {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java index 759acf5eed0..ef241ec8f79 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java @@ -11,11 +11,10 @@ *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.dom;
-import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations.CSS_ANNOTATION;
-import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations.CSS_DIAGRAM_STYLESHEETS_KEY;
-import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations.CSS_GMF_CLASS_KEY;
-import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations.CSS_GMF_ID_KEY;
-import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSAnnotations.CSS_GMF_STYLE_KEY;
+import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY;
+import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles.CSS_GMF_CLASS_KEY;
+import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles.CSS_GMF_ID_KEY;
+import static org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles.CSS_GMF_STYLE_KEY;
import java.util.Arrays;
import java.util.Collection;
@@ -30,9 +29,7 @@ import org.eclipse.core.databinding.observable.IChangeListener; import org.eclipse.e4.ui.css.core.dom.ElementAdapter;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.notation.Diagram;
@@ -50,6 +47,11 @@ import org.eclipse.papyrus.infra.tools.util.ListHelper; import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+/**
+ * An Adapter for providing a CSS support to GMF Objects
+ *
+ * @author Camille Letavernier
+ */
@SuppressWarnings("restriction")
public class GMFElementAdapter extends ElementAdapter implements NodeList, IChangeListener {
@@ -108,31 +110,54 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan */
private Node parentNode;
+ /**
+ * A Listener for standard Style properties
+ */
private Adapter styleListener;
+ /**
+ * A Listener for custom Style properties
+ */
private CustomStyleListener cssStyleListener;
+ /**
+ * Returns the CSS ID of the selected element.
+ *
+ * @param sourceElement
+ * The source element must be a GMF notation object (View, Style, ...)
+ * @return
+ * The CSS ID associated to the source element, or null if it cannot be found
+ */
public static String getCSSID(EObject sourceElement) {
return getCSSValue(sourceElement, CSS_GMF_ID_KEY);
}
+ /**
+ * Returns the CSS Class of the selected element. If more than one CSS
+ * class is associated to the source elements, returns a String containing
+ * all classes, separated with spaces.
+ *
+ * @param sourceElement
+ * The source element must be a GMF notation object (View, Style, ...)
+ * @return
+ * The CSS Class associated to the source element, or null if it cannot be found
+ */
public static String getCSSClass(EObject sourceElement) {
List<String> allClasses = getCSSValues(sourceElement, CSS_GMF_CLASS_KEY);
return ListHelper.deepToString(allClasses, " "); //$NON-NLS-1$
}
+ /**
+ * Returns the source element's local CSS style.
+ *
+ * @param sourceElement
+ * The source element must be a GMF notation object (View, Style, ...)
+ * @return
+ */
public static String getCSSStyle(EObject sourceElement) {
return getCSSValue(sourceElement, CSS_GMF_STYLE_KEY);
}
- public static EAnnotation getStyleAnnotation(EModelElement modelElement) {
- if(modelElement == null) {
- return null;
- }
-
- return modelElement.getEAnnotation(CSS_ANNOTATION);
- }
-
private static String getCSSValue(EObject sourceElement, String key) {
StringValueStyle style = (StringValueStyle)findStyle(sourceElement, key, NotationPackage.eINSTANCE.getStringValueStyle());
if(style == null) {
@@ -142,12 +167,14 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan return style.getStringValue();
}
+ @SuppressWarnings("unchecked")
private static List<String> getCSSValues(EObject sourceElement, String key) {
StringListValueStyle style = (StringListValueStyle)findStyle(sourceElement, key, NotationPackage.eINSTANCE.getStringListValueStyle());
if(style == null) {
return Collections.emptyList();
}
+
return style.getStringListValue();
}
@@ -172,12 +199,27 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan return findView(sourceElement.eContainer());
}
+ /**
+ * Creates a new GMF Element Adapter for the requested view.
+ *
+ * @param view
+ * The view to be adapted
+ * @param engine
+ * The associated CSS Engine
+ */
public GMFElementAdapter(View view, ExtendedCSSEngine engine) {
super(view, engine);
notationElement = view;
listenNotationElement();
}
+ /**
+ * Returns the semantic element associated to this adapter. In case of a diagram,
+ * the diagram is itself the semantic element.
+ *
+ * @return
+ * The semantic element associated to this adapter
+ */
public EObject getSemanticElement() {
if(semanticElement == null) {
semanticElement = SemanticElementHelper.findSemanticElement(notationElement);
@@ -247,10 +289,16 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan return parentNode;
}
+ /**
+ * {@inheritDoc}
+ */
public NodeList getChildNodes() {
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public String getNamespaceURI() {
if(namespaceURI == null) {
namespaceURI = EMFHelper.getQualifiedName(getSemanticElement().eClass().getEPackage(), ".");
@@ -258,18 +306,33 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan return namespaceURI;
}
+ /**
+ * {@inheritDoc}
+ */
public String getCSSId() {
return getCSSID(notationElement);
}
+ /**
+ * {@inheritDoc}
+ */
public String getCSSClass() {
return getCSSClass(notationElement);
}
+ /**
+ * {@inheritDoc}
+ */
public String getCSSStyle() {
return getCSSStyle(notationElement);
}
+ /**
+ * {@inheritDoc}
+ *
+ * The local name is either the diagram type (For a Diagram) or the name of the semantic
+ * element's metaclass
+ */
@Override
public String getLocalName() {
if(localName == null) {
@@ -289,6 +352,11 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan return localName;
}
+ /**
+ * {@inheritDoc}
+ *
+ * The attributes are the semantic's element features
+ */
@Override
public String getAttribute(String attr) {
EStructuralFeature feature = getSemanticElement().eClass().getEStructuralFeature(attr);
@@ -320,10 +388,16 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan + /**
+ * {@inheritDoc}
+ */
public Node item(int index) {
return getChildren()[index];
}
+ /**
+ * {@inheritDoc}
+ */
public int getLength() {
return getChildren().length;
}
@@ -364,10 +438,18 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan // Handle events //
//////////////////////
- public EObject getNotationElement() {
+
+ /**
+ * The GMF View element associated to this adapter
+ */
+ public View getNotationElement() {
return notationElement;
}
+ /**
+ * Handles a notification for semantic element change.
+ * Source: styleListener
+ */
public void semanticElementChanged() {
if(semanticElement != null && semanticElement != notationElement) {
semanticElement.eAdapters().remove(styleListener);
@@ -381,6 +463,10 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan getEngine().notifyChange(this);
}
+ /**
+ * Handles a notification for Custom style change.
+ * Source: cssStyleListener
+ */
//Change incoming from one of the cssCustomStyles (class, id, local style or diagram stylesheets)
public void handleChange(ChangeEvent event) {
if(notationElement instanceof CSSDiagram) {
@@ -393,6 +479,9 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan getEngine().notifyChange(this);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void dispose() {
super.dispose();
@@ -406,16 +495,28 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan }
}
+ /**
+ * Handles a notification for notation property change
+ * Source : styleListener
+ */
public void notationPropertyChanged() {
//Notify the CSSEngine
getEngine().notifyChange(this);
}
+ /**
+ * Handles a notification for semantic property change
+ * Source : styleListener
+ */
public void semanticPropertyChanged() {
//Notify the CSSEngine
getEngine().notifyChange(this);
}
+ /**
+ * Handles a notification for notation element disposed
+ * Source : styleListener
+ */
public void notationElementDisposed() {
dispose();
//Notify the CSSEngine
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/StyleListener.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/StyleListener.java index cf290bc77bb..f6f4d29bcfa 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/StyleListener.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/StyleListener.java @@ -15,7 +15,11 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-
+/**
+ * A Listener for notation and semantic properties changes
+ *
+ * @author Camille Letavernier
+ */
public class StyleListener extends AdapterImpl {
private final GMFElementAdapter elementAdapter;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/BaseCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/BaseCSSEngine.java index f2a75e19974..083349e531f 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/BaseCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/BaseCSSEngine.java @@ -23,7 +23,11 @@ import org.w3c.dom.Element; * The base CSS Engine. It contains the default stylesheet, which will be applied
* in all cases (With the lowest priority).
*
+ * It should not be used directly.
+ *
* @author Camille Letavernier
+ *
+ * @see DiagramCSSEngine
*/
@SuppressWarnings("restriction")
public class BaseCSSEngine extends ExtendedCSSEngineImpl {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java index 50df1a436c3..503d28c0e06 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java @@ -28,6 +28,13 @@ import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
import org.w3c.dom.Element;
+/**
+ * A CSS Engine associated to a Diagram.
+ *
+ * This Engine is a child of a ModelCSSEngine.
+ *
+ * @author Camille Letavernier
+ */
@SuppressWarnings("restriction")
public class DiagramCSSEngine extends ExtendedCSSEngineImpl implements IChangeListener {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java index 82164db9688..82b1803ecc3 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java @@ -17,6 +17,11 @@ import org.eclipse.papyrus.infra.gmfdiag.css.lists.ExtendedStyleSheetList; import org.w3c.dom.Element;
import org.w3c.dom.css.CSSValue;
+/**
+ * An extended, lazy version of a CSSEngine
+ *
+ * @author Camille Letavernier
+ */
@SuppressWarnings("restriction")
public interface ExtendedCSSEngine extends LazyCSSEngine, CSSEngine {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java index 0015e8947bb..a3b8bb8c948 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java @@ -167,6 +167,11 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements fireStyleSheetChanged();
}
+ /**
+ * Reloads the CSS Stylesheets for this engine.
+ * The default implementation does nothing, because stylesheets are
+ * not added dynamically.
+ */
protected void reloadStyleSheets() {
//Do nothing
}
@@ -182,6 +187,9 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements availableClasses.clear();
}
+ /**
+ * Reloads and parses this engine's stylesheets
+ */
protected void parseStyleSheets() {
reloadStyleSheets();
for(URL styleSheet : styleSheetURLs) {
@@ -204,17 +212,11 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements }
}
- /**
- * @see #addStyleSheet(StyleSheet)
- */
private void parseStyleSheet(EmbeddedStyleSheet styleSheet) throws IOException {
Reader reader = new StringReader(styleSheet.getContent());
parseStyleSheet(reader);
}
- /**
- * @see #addStyleSheet(StyleSheet)
- */
protected void parseStyleSheet(StyleSheetReference styleSheet) throws IOException {
String path = styleSheet.getPath();
if(path.startsWith("/")) {
@@ -250,6 +252,11 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements return viewCSS;
}
+ /**
+ * Handles a notification from a parent CSS Engine: a parent stylesheet has
+ * changed. Resets this engine and forwards the event to children
+ * stylesheets
+ */
public void styleSheetChanged(ExtendedCSSEngine owner) {
reset();
}
@@ -270,10 +277,16 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements styleSheetListeners.add(listener);
}
+ /**
+ * {@inheritDoc}
+ */
public void removeStyleSheetChangedListener(StyleSheetChangeListener listener) {
styleSheetListeners.remove(listener);
}
+ /**
+ * {@inheritDoc}
+ */
public ExtendedStyleSheetList getAllStylesheets() {
if(styleSheetsList == null) {
parseStyleSheets();
@@ -287,6 +300,9 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements return styleSheetsList;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Object convert(CSSValue value, Object toType, Object context) {
try {
@@ -311,6 +327,9 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements return value;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void dispose() {
styleSheetListeners.clear();
@@ -322,6 +341,13 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements super.dispose();
}
+ /**
+ * {@inheritDoc}
+ *
+ * Handles a notification that an Element has changed.
+ *
+ * Source: GMFElementAdapter
+ */
public void notifyChange(Element elementAdapter) {
resetCache(); //TODO: We should only refresh a subset of the cache
Display.getCurrent().asyncExec(new Runnable() {
@@ -337,6 +363,13 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements }
+ /**
+ * {@inheritDoc}
+ *
+ * Handles a notification that a graphical widget has been disposed.
+ *
+ * Source: GMFElementAdapter
+ */
public void handleDispose(Object nativeWidget) {
super.handleWidgetDisposed(nativeWidget);
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFElementProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFElementProvider.java index 44415df8e83..8584cbbaf59 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFElementProvider.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFElementProvider.java @@ -25,6 +25,14 @@ import org.w3c.dom.Element; @SuppressWarnings("restriction")
public class GMFElementProvider implements IElementProvider {
+ /**
+ * {@inheritDoc}
+ *
+ * @param element
+ * A GMF View
+ * @param engine
+ * An ExtendedCSSEngine
+ */
public Element getElement(Object element, CSSEngine engine) {
if(!(element instanceof View)) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFErrorHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFErrorHandler.java index c238332735c..48aaa6ed2d5 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFErrorHandler.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/GMFErrorHandler.java @@ -14,9 +14,19 @@ package org.eclipse.papyrus.infra.gmfdiag.css.engine; import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
import org.eclipse.papyrus.infra.gmfdiag.css.Activator;
+/**
+ * A CSSErrorHandler which forwards exceptions to the Papyrus log
+ *
+ * @author Camille Letavernier
+ */
@SuppressWarnings("restriction")
public class GMFErrorHandler implements CSSErrorHandler {
+ /**
+ * {@inheritDoc}
+ *
+ * Forwards the exception to the Papyrus log
+ */
public void error(Exception ex) {
Activator.log.error("CSS Error", ex); //$NON-NLS-1$
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/LazyCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/LazyCSSEngine.java index 45cd8ec95cf..441674f1b39 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/LazyCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/LazyCSSEngine.java @@ -24,6 +24,13 @@ import org.w3c.dom.css.CSSValue; */
public interface LazyCSSEngine {
+ /**
+ * Lazily retrieves a property's value on the selected node
+ *
+ * @param node
+ * @param property
+ * @return
+ */
public CSSValue retrievePropertyValue(Object node, String property);
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ModelCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ModelCSSEngine.java index b7af7ab1cce..7aa2b85ba1b 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ModelCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ModelCSSEngine.java @@ -24,11 +24,26 @@ import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
import org.w3c.dom.Element;
+/**
+ * An extended CSS Engine for an EMF Resource (A Model). This engine
+ * is a child of the WorkspaceCSSEngine.
+ *
+ * It should not be used directly.
+ *
+ * @author Camille Letavernier
+ *
+ * @see DiagramCSSEngine
+ */
@SuppressWarnings("restriction")
public class ModelCSSEngine extends ExtendedCSSEngineImpl {
private final Resource model;
+ /**
+ * Creates a ModelCSSEngine for the requested resource.
+ *
+ * @param model
+ */
public ModelCSSEngine(Resource model) {
super(WorkspaceCSSEngine.instance);
this.model = model;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/WorkspaceCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/WorkspaceCSSEngine.java index f30219a8a9d..6ac7f335a79 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/WorkspaceCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/WorkspaceCSSEngine.java @@ -20,10 +20,15 @@ import org.w3c.dom.Element; /**
* A Singleton CSSEngine, handling the CSS stylesheets applied to the whole
- * workspace
+ * workspace.
+ *
+ * This Engine is a child of the BaseCSSEngine.
+ *
+ * It should not be used directly.
*
* @author Camille Letavernier
*
+ * @see DiagramCSSEngine
*/
@SuppressWarnings("restriction")
public class WorkspaceCSSEngine extends ExtendedCSSEngineImpl {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/CSSComputedStyleImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/CSSComputedStyleImpl.java index a4e6bab386e..a9852b884e2 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/CSSComputedStyleImpl.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/CSSComputedStyleImpl.java @@ -27,6 +27,7 @@ import org.w3c.dom.css.CSSStyleDeclaration; * styles coming from Condition Selector (ex : Label#MyId) and other selectors * (ex : Label). */ +//Copied from org.eclipse.e4.ui.css.core.impl.dom.CSSComputedStyleImpl @SuppressWarnings({ "serial", "restriction" }) public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements CSSStyleDeclaration { diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/ExtendedViewCSSImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/ExtendedViewCSSImpl.java index 367100010cb..4f5899ee445 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/ExtendedViewCSSImpl.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/ExtendedViewCSSImpl.java @@ -33,7 +33,7 @@ import org.w3c.dom.css.ViewCSS; import org.w3c.dom.stylesheets.StyleSheet;
import org.w3c.dom.views.DocumentView;
-
+//Implementation based on org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl
@SuppressWarnings("restriction")
public class ExtendedViewCSSImpl implements ViewCSS {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/StyleWrapper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/StyleWrapper.java index 3a0ef91f134..b443f5bf561 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/StyleWrapper.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/enginecopy/StyleWrapper.java @@ -18,6 +18,7 @@ import org.w3c.dom.css.CSSStyleDeclaration; * together with all the information needed to calculate a matching selector's * precedence. */ +//Copied from org.eclipse.e4.ui.css.core.impl.dom.StyleWrapper final class StyleWrapper { private static class StyleWrapperComparator implements Comparator<StyleWrapper> { diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSHelper.java index 7394859778f..322af19c50d 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSHelper.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSHelper.java @@ -14,9 +14,20 @@ package org.eclipse.papyrus.infra.gmfdiag.css.helper; import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.infra.gmfdiag.css.resource.CSSNotationResourceFactory;
-
+/**
+ * A Helper for CSS features
+ *
+ * @author Camille Letavernier
+ */
public class CSSHelper {
+ /**
+ * Makes the given resourceSet compatible with the ExtendedCSSEngines.
+ *
+ * This method should be called before loading resources from this resource set.
+ *
+ * @param resourceSet
+ */
public static void installCSSSupport(ResourceSet resourceSet) {
CSSNotationResourceFactory factory = new CSSNotationResourceFactory();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("notation", factory); //$NON-NLS-1$
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/GradientHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/GradientHelper.java index 8c933b7b617..af499fadba0 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/GradientHelper.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/GradientHelper.java @@ -20,7 +20,22 @@ import org.eclipse.papyrus.infra.gmfdiag.css.converters.ColorToGMFConverter; import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.w3c.dom.css.CSSValue;
-
+/**
+ * A Helper class for manipulating CSS Gradient properties.
+ *
+ * Gradient properties:
+ *
+ * - fillColor
+ * - gradientColor
+ * - gradientStyle
+ * - gradient (Composite property)
+ *
+ * The support is currently incomplete, especially when using both the
+ * composite property and the single ones in CSS files.
+ *
+ * @author Camille Letavernier
+ */
+@SuppressWarnings("restriction")
public class GradientHelper {
public static final String GRADIENT_VERTICAL = "vertical";
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/ParserHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/ParserHelper.java index 3c81614ac77..571535daa10 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/ParserHelper.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/ParserHelper.java @@ -18,6 +18,11 @@ import org.eclipse.papyrus.infra.gmfdiag.css.Activator; import org.w3c.dom.css.CSSValue;
import org.w3c.dom.css.CSSValueList;
+/**
+ * A Helper for parsing CSS property values.
+ *
+ * @author Camille Letavernier
+ */
@SuppressWarnings("restriction")
public class ParserHelper {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/SemanticElementHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/SemanticElementHelper.java index 0f8abdc840d..ce5251d822a 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/SemanticElementHelper.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/SemanticElementHelper.java @@ -16,6 +16,12 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.Activator;
+/**
+ * A Helper for retrieving Views and Semantic elements from a
+ * compatible object.
+ *
+ * @author Camille Letavernier
+ */
public class SemanticElementHelper {
/**
@@ -24,7 +30,7 @@ public class SemanticElementHelper { * The result element can also be a Diagram
*/
public static EObject findSemanticElement(EObject notationElement) {
- if (notationElement == null){
+ if(notationElement == null) {
return null;
}
if(notationElement instanceof Diagram) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/listener/StyleSheetChangeListener.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/listener/StyleSheetChangeListener.java index 5c4352eedad..afd20c7b3b2 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/listener/StyleSheetChangeListener.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/listener/StyleSheetChangeListener.java @@ -13,8 +13,18 @@ package org.eclipse.papyrus.infra.gmfdiag.css.listener; import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
-
+/**
+ * An interface for listening changes on a CSSEngine's stylesheets.
+ *
+ * @author Camille Letavernier
+ */
public interface StyleSheetChangeListener {
+ /**
+ * Notifies this listener that a stylesheet has changed on the CSSEngine
+ *
+ * @param owner
+ * The CSSEngine on which a stylesheet change has occured
+ */
public void styleSheetChanged(ExtendedCSSEngine owner);
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedCSSRuleList.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedCSSRuleList.java index ccb4a7e6e6d..60a0a4170d3 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedCSSRuleList.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedCSSRuleList.java @@ -17,7 +17,11 @@ import java.util.LinkedList; import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
-
+/**
+ * More usable implementation for CSSRuleList
+ *
+ * @author Camille Letavernier
+ */
public class ExtendedCSSRuleList extends LinkedList<CSSRule> implements CSSRuleList {
private static final long serialVersionUID = 1L;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedSelectorList.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedSelectorList.java index 4f227fe62c5..6ac2a957c64 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedSelectorList.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedSelectorList.java @@ -17,7 +17,11 @@ import java.util.LinkedList; import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SelectorList;
-
+/**
+ * More usable implementation for SelectorList
+ *
+ * @author Camille Letavernier
+ */
public class ExtendedSelectorList extends LinkedList<Selector> implements SelectorList {
private static final long serialVersionUID = 0;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedStyleSheetList.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedStyleSheetList.java index ae28bf25a59..64ec16cf0e2 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedStyleSheetList.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/lists/ExtendedStyleSheetList.java @@ -17,7 +17,11 @@ import java.util.LinkedList; import org.w3c.dom.stylesheets.StyleSheet;
import org.w3c.dom.stylesheets.StyleSheetList;
-
+/**
+ * More usable implementation for StyleSheetList
+ *
+ * @author Camille Letavernier
+ */
public class ExtendedStyleSheetList extends LinkedList<StyleSheet> implements StyleSheetList {
private static final long serialVersionUID = 1L;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSAnnotations.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSAnnotations.java index 05141e43bea..942d9baebcb 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSAnnotations.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSAnnotations.java @@ -11,38 +11,14 @@ *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.notation;
+/**
+ * Contains constants for the CSS-specific annotations
+ *
+ * @author Camille Letavernier
+ */
public interface CSSAnnotations {
/**
- * The css id property
- */
- public static final String CSS_GMF_ID_KEY = "cssId"; //$NON-NLS-1$
-
- /**
- * The css class property
- */
- public static final String CSS_GMF_CLASS_KEY = "cssClass"; //$NON-NLS-1$
-
- /**
- * The css style property
- */
- public static final String CSS_GMF_STYLE_KEY = "cssStyle"; //$NON-NLS-1$
-
- /**
- * The Diagram Stylesheets key
- */
- public static final String CSS_DIAGRAM_STYLESHEETS_KEY = "css_stylesheets"; //$NON-NLS-1$
-
- /**
- * The name of the EAnnotation containing css informations
- *
- * @see CSS_GMF_ID_KEY
- * @see CSS_GMF_CLASS_KEY
- * @see CSS_GMF_STYLE_KEY
- */
- public static final String CSS_ANNOTATION = "PapyrusCSS"; //$NON-NLS-1$
-
- /**
* The name of the EAnnotation containing the list of feature names
* for which the value has been forced by the user.
*/
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java index 50975bfe4ee..3b88e2a17cf 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java @@ -65,7 +65,7 @@ public class CSSDiagramImpl extends DiagramImpl implements CSSDiagram { NamedStyle style = (NamedStyle)styleObject; - if(CSSAnnotations.CSS_DIAGRAM_STYLESHEETS_KEY.equals(style.getName())) { + if(CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(style.getName())) { if(style instanceof EObjectListValueStyle) { EObjectListValueStyle stylesheetsStyle = (EObjectListValueStyle)style; diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java new file mode 100644 index 00000000000..57beb64bceb --- /dev/null +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java @@ -0,0 +1,41 @@ +/*****************************************************************************
+ * 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.notation;
+
+/**
+ * Constants for the CSS-specific properties
+ *
+ * @author Camille Letavernier
+ */
+public interface CSSStyles {
+
+ /**
+ * The css id property
+ */
+ public static final String CSS_GMF_ID_KEY = "cssId"; //$NON-NLS-1$
+
+ /**
+ * The css class property
+ */
+ public static final String CSS_GMF_CLASS_KEY = "cssClass"; //$NON-NLS-1$
+
+ /**
+ * The css style property
+ */
+ public static final String CSS_GMF_STYLE_KEY = "cssStyle"; //$NON-NLS-1$
+
+ /**
+ * The Diagram Stylesheets key
+ */
+ public static final String CSS_DIAGRAM_STYLESHEETS_KEY = "css_stylesheets"; //$NON-NLS-1$
+
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/preferences/ThemePreferencesPage.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/preferences/ThemePreferencesPage.java index 1a8c9de190f..db2f453f4e7 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/preferences/ThemePreferencesPage.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/preferences/ThemePreferencesPage.java @@ -26,7 +26,11 @@ import org.eclipse.papyrus.infra.gmfdiag.css.theme.ThemeManager; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
+/**
+ * A Preference page for selecting the Workspace CSS Theme
+ *
+ * @author Camille Letavernier
+ */
public class ThemePreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public boolean needsRefresh = false;
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 ceb08f4a7af..ab59c50ea25 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 @@ -14,7 +14,15 @@ package org.eclipse.papyrus.infra.gmfdiag.css.provider; import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
-
+/**
+ * An appearance provider based on CSS. It reuses the AnnotationStyleProvider:
+ * if a property is changed manually, a standard annotation will be used.
+ *
+ * @author Camille Letavernier
+ *
+ */
+//FIXME: Currently, manual changes on the appearance properties are not
+//correctly taken into account
public class CSSAppearanceProvider extends AnnotationStyleProvider {
@Override
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 34fb2aa1567..bcca3ea0809 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 @@ -33,6 +33,16 @@ 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 {
@@ -40,6 +50,13 @@ public class CSSClassContentProvider extends AbstractStaticContentProvider { 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;
@@ -49,6 +66,11 @@ public class CSSClassContentProvider extends AbstractStaticContentProvider { 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());
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CustomStyle.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CustomStyle.java index 6674a5033c2..d3e1ec1d8db 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CustomStyle.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CustomStyle.java @@ -11,7 +11,12 @@ *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.provider;
-
+/**
+ * An element which supports Papyrus custom styles (elementIcon,
+ * qualifiedNameDepth, shadow).
+ *
+ * @author Camille Letavernier
+ */
public interface CustomStyle {
public boolean showElementIcon();
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationModel.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationModel.java index dbd32d9df6e..e2eaac8a2fc 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationModel.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationModel.java @@ -15,6 +15,11 @@ import org.eclipse.papyrus.infra.core.resource.ModelSet; import org.eclipse.papyrus.infra.core.resource.notation.NotationModel;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper;
+/**
+ * A Papyrus Model for the Notation resource, with CSS Support
+ *
+ * @author Camille Letavernier
+ */
public class CSSNotationModel extends NotationModel {
@Override
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResource.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResource.java index a3261b76f8a..99903e3775b 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResource.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResource.java @@ -22,6 +22,12 @@ import org.eclipse.gmf.runtime.emf.core.resources.GMFResource; import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ModelCSSEngine;
+/**
+ * A GMF Resource with CSS support
+ *
+ * @author Camille Letavernier
+ *
+ */
@SuppressWarnings("restriction")
public class CSSNotationResource extends GMFResource {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResourceFactory.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResourceFactory.java index 4d6a38f38a8..525b87b98c4 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResourceFactory.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/resource/CSSNotationResourceFactory.java @@ -17,7 +17,14 @@ import org.eclipse.emf.ecore.xmi.XMIResource; import org.eclipse.gmf.runtime.emf.core.internal.util.EMFCoreConstants;
import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory;
-
+/**
+ * A GMFResourceFactory which installs CSS Support on the produced
+ * NotationResources.
+ *
+ * @author Camille Letavernier
+ *
+ */
+@SuppressWarnings("restriction")
public class CSSNotationResourceFactory extends GMFResourceFactory {
@Override
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/Theme.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/Theme.java index 39c19f2aee2..91e2172dc61 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/Theme.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/Theme.java @@ -17,7 +17,11 @@ import java.util.List; import org.eclipse.swt.graphics.Image;
-
+/**
+ * A CSS Theme descriptor
+ *
+ * @author Camille Letavernier
+ */
public class Theme {
private String label;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java index bbda16c9b82..945fe45ddbb 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/theme/ThemeManager.java @@ -29,7 +29,13 @@ import org.eclipse.papyrus.infra.gmfdiag.css.Activator; import org.eclipse.papyrus.infra.gmfdiag.css.preferences.ThemePreferences;
import org.eclipse.swt.graphics.Image;
-
+/**
+ * A Singleton to manage CSS Themes. Reads Themes from an extension point,
+ * and provides an access to them.
+ *
+ * @author Camille Letavernier
+ *
+ */
public class ThemeManager {
public static String EXTENSION_ID = Activator.PLUGIN_ID + ".theme";
@@ -38,12 +44,22 @@ public class ThemeManager { private Map<String, Theme> allThemes;
+ /**
+ * Returns all the Themes, sorted alphabetically
+ *
+ * @return
+ */
public List<Theme> getThemes() {
List<Theme> sortedThemes = new LinkedList<Theme>(getAllThemes().values());
Collections.sort(sortedThemes, ThemeComparator.instance);
return sortedThemes;
}
+ /**
+ * Returns the list of the workspace stylesheet's URLs.
+ *
+ * @return
+ */
public List<URL> getWorkspaceStyleSheets() {
Theme current = findCurrentTheme();
if(current == null) {
@@ -52,6 +68,13 @@ public class ThemeManager { return current.getStyleSheets();
}
+ /**
+ * Returns the theme associated to the given id, or null if it doesn't
+ * exist
+ *
+ * @param themeId
+ * @return
+ */
public Theme getTheme(String themeId) {
return getAllThemes().get(themeId);
}
@@ -163,6 +186,12 @@ public class ThemeManager { }
}
+ /**
+ * Sorts the Themes alphabetically (Based on their label). The Empty theme
+ * is always the first element.
+ *
+ * @author Camille Letavernier
+ */
private static class ThemeComparator implements Comparator<Theme> {
private ThemeComparator() {
|