summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2014-05-06 07:18:48 (EDT)
committerCamille Letavernier2014-05-13 13:01:40 (EDT)
commit2da0a56b7c2d60edf43642ef2f27e2443c96f4a9 (patch)
tree2ad02fd44a8a80f8ff2573f68d00d2e32d3c0cd3
parent353d778d43908f6a77d4a5e7943b880c71eb944e (diff)
downloadorg.eclipse.papyrus-2da0a56b7c2d60edf43642ef2f27e2443c96f4a9.zip
org.eclipse.papyrus-2da0a56b7c2d60edf43642ef2f27e2443c96f4a9.tar.gz
org.eclipse.papyrus-2da0a56b7c2d60edf43642ef2f27e2443c96f4a9.tar.bz2
429642: [Model / CSS] Add properties view to define Model's stylesheets refs/changes/42/26042/2
Patch Set 1: - Remove com.google.common.base.Optional Change-Id: I49a646f2fe1a59530f32b4302f2df598de10fd7f Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=429642 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElement.java38
2 files changed, 17 insertions, 22 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/META-INF/MANIFEST.MF
index 08097e1..d57d4d3 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/META-INF/MANIFEST.MF
@@ -24,7 +24,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.0",
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.0",
- com.google.guava;bundle-version="11.0.0",
org.eclipse.e4.ui.css.core;bundle-version="0.10.0"
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElement.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElement.java
index 0e8635f..8a21c29 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElement.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElement.java
@@ -25,6 +25,7 @@ import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ModelCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles;
+import org.eclipse.papyrus.infra.gmfdiag.css.properties.Activator;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.creation.StyleSheetFactory;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.DiagramStyleSheetObservableList;
import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.ModelStyleSheetObservableList;
@@ -41,9 +42,6 @@ import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
-import com.google.common.base.Optional;
-
-
public class CSSModelElement extends CustomStyleModelElement {
public CSSModelElement(View source, DataContextElement context) {
@@ -67,7 +65,6 @@ public class CSSModelElement extends CustomStyleModelElement {
factory.setContentProvider(getContentProvider(propertyPath));
return factory;
}
-
return super.getValueFactory(propertyPath);
}
@@ -79,29 +76,22 @@ public class CSSModelElement extends CustomStyleModelElement {
if(CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) {
//Get the resource
final Resource notationResource = source.eResource();
- //The model styleSheet
- ModelStyleSheets modelStyleSheetsSource = null;
//Get the model styleSheet Object
Object modelStyleSheetObject = EcoreUtil.getObjectByType(notationResource.getContents(), StylesheetsPackage.Literals.MODEL_STYLE_SHEETS);
- //If the model styleSheet exist
- if(modelStyleSheetObject instanceof ModelStyleSheets) {
- // set modelStyleSheetsSource
- modelStyleSheetsSource = (ModelStyleSheets)modelStyleSheetObject;
- } else {
- //or create a model styleSheet
- modelStyleSheetsSource = StylesheetsFactory.eINSTANCE.createModelStyleSheets();
- //Optional used to pass the modelStyleSheetsSource on runnable without final
- final Optional<ModelStyleSheets> modelStyleSheetsOnOptional = Optional.of(modelStyleSheetsSource);
+ //The model styleSheet
+ final ModelStyleSheets modelStyleSheetsSource = modelStyleSheetObject instanceof ModelStyleSheets ? (ModelStyleSheets)modelStyleSheetObject : StylesheetsFactory.eINSTANCE.createModelStyleSheets();
+ //If the modelStylesheet doesn't exist
+ if(!(modelStyleSheetObject instanceof ModelStyleSheets)) {
try {
TransactionHelper.run(domain, new Runnable() {
public void run() {
//Add modelStylesheet to the resource without command
- notationResource.getContents().add(modelStyleSheetsOnOptional.get());
+ notationResource.getContents().add(modelStyleSheetsSource);
}
});
} catch (Exception e) {
- e.printStackTrace();
+ Activator.log.error(e);
}
//Initialize the adapter of the engine to listen model styleSheet
ExtendedCSSEngine engine = ((CSSNotationResource)notationResource).getModelEngine();
@@ -136,9 +126,7 @@ public class CSSModelElement extends CustomStyleModelElement {
if(propertyPath.equals(CSSStyles.CSS_GMF_CLASS_KEY)) {
Diagram diagram = ((View)source).getDiagram();
if(diagram instanceof CSSDiagram) {
-
EObject semanticElement = ((View)source).getElement();
-
if(semanticElement != null) {
//TODO: For Diagrams, we should use the right DiagramKind (See GMFElementAdapter)
//Until then, we list all available classes (*)
@@ -146,11 +134,19 @@ public class CSSModelElement extends CustomStyleModelElement {
return new CSSClassContentProvider(elementName, ((CSSDiagram)diagram).getEngine());
}
}
-
return null;
}
-
return null;
}
+ @Override
+ public boolean isUnique(String propertyPath) {
+ if(CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) {
+ return true;
+ }
+ if(CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) {
+ return true;
+ }
+ return super.isUnique(propertyPath);
+ }
}