Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2017-12-20 09:03:59 +0000
committerQuentin Le Menez2017-12-22 13:58:51 +0000
commit7f5906498b939c3023470fca214910cfe1373110 (patch)
treeaa6603ad96a2434995f681e9c5bb5274efa4ce27 /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus
parent4e52fa2d13ef92990c3b79af708d96b4a9c1d7b4 (diff)
downloadorg.eclipse.papyrus-7f5906498b939c3023470fca214910cfe1373110.tar.gz
org.eclipse.papyrus-7f5906498b939c3023470fca214910cfe1373110.tar.xz
org.eclipse.papyrus-7f5906498b939c3023470fca214910cfe1373110.zip
Bug 528992 - [CSS] There should be a way to remove a style
- Add a new remove style command Change-Id: I10086c959aee83239bd5198499a060663b6ae269 Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr> (cherry picked from commit 4da7dfa2a6d3d35a1e4f52289b669c710d300ebd)
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus')
-rwxr-xr-xplugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCssClassStyleCommand.java74
1 files changed, 74 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/RemoveCssClassStyleCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCssClassStyleCommand.java
new file mode 100755
index 00000000000..11ea8743fb9
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCssClassStyleCommand.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST 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:
+ * 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;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class RemoveCssClassStyleCommand extends RecordingCommand implements Command {
+
+ private Collection<View> views;
+
+ private String style;
+
+ /**
+ * Constructor.
+ *
+ * @param namedStyle
+ * @param newValue
+ */
+ public RemoveCssClassStyleCommand(TransactionalEditingDomain domain, View view, String newValue) {
+ this(domain, Collections.singleton(view), newValue);
+ }
+
+ public RemoveCssClassStyleCommand(TransactionalEditingDomain domain, Collection<View> views, String style) {
+ super(domain);
+ this.views = views;
+ this.style = style;
+ }
+
+
+ /**
+ * Remove the style to the existing list or do nothing if there are no styles applied
+ *
+ * @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) {
+ // there is no style applied to this view
+ return;
+ }
+ if (style != null && namedStyle.getStringListValue().contains(style)) {
+ namedStyle.getStringListValue().remove(style);
+ }
+ }
+ }
+
+}

Back to the top