Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2017-11-14 14:33:24 +0000
committerBenoit Maggi2017-11-20 11:33:22 +0000
commit5afa41f30f3f7a556cb3fdbee14a90733af607a6 (patch)
tree9bdb236ef76808d8044c5ba7cf9931ce48c73587 /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties
parent18b714785f83b6b86d8101397e5a092fefae09dd (diff)
downloadorg.eclipse.papyrus-5afa41f30f3f7a556cb3fdbee14a90733af607a6.tar.gz
org.eclipse.papyrus-5afa41f30f3f7a556cb3fdbee14a90733af607a6.tar.xz
org.eclipse.papyrus-5afa41f30f3f7a556cb3fdbee14a90733af607a6.zip
Bug 518305 - Apply a predefined Style directly from a diagram
- add apply style menu on right click - also works with multi-selection Change-Id: I445331e15aaf9a1bbdb1f2d229297b75bce8197f Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCssClassStyleCommand.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCssClassStyleCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCssClassStyleCommand.java
new file mode 100644
index 00000000000..1041bab9e02
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCssClassStyleCommand.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * Benoit Maggi (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringListValueStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles;
+
+
+/**
+ * EMF Command to add a new style
+ * Stored in Notation with CSSStyles.CSS_GMF_CLASS_KEY
+ */
+public class AddCssClassStyleCommand extends RecordingCommand implements Command {
+
+ private Collection<View> views;
+
+ private String style;
+
+ /**
+ * Constructor.
+ *
+ * @param namedStyle
+ * @param newValue
+ */
+ public AddCssClassStyleCommand(TransactionalEditingDomain domain, View view, String newValue) {
+ this(domain, Collections.singleton(view), newValue);
+ }
+
+ public AddCssClassStyleCommand(TransactionalEditingDomain domain, Collection<View> views, String style) {
+ super(domain);
+ this.views = views;
+ this.style = style;
+ }
+
+
+ /**
+ * Add the style to the existing list or initialize a new list with it
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ *
+ */
+ @Override
+ protected void doExecute() {
+ for (View view : views) {
+ StringListValueStyle namedStyle = (StringListValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getStringListValueStyle(), CSSStyles.CSS_GMF_CLASS_KEY);
+ if (namedStyle == null) {
+ namedStyle = (StringListValueStyle) view.createStyle(NotationPackage.eINSTANCE.getStringListValueStyle());
+ namedStyle.setName(CSSStyles.CSS_GMF_CLASS_KEY);
+ }
+ namedStyle.getStringListValue().add(style);
+ }
+
+
+ }
+
+}

Back to the top