diff options
author | Quentin Le Menez | 2017-12-20 09:03:59 +0000 |
---|---|---|
committer | Quentin Le Menez | 2017-12-21 15:25:10 +0000 |
commit | 4da7dfa2a6d3d35a1e4f52289b669c710d300ebd (patch) | |
tree | c734313f72e2b57d37a4d373d46c8326a9c672f9 /plugins/infra/gmfdiag/css | |
parent | c99482e96ae44e0cbd5d6db088619f3e68b936a8 (diff) | |
download | org.eclipse.papyrus-4da7dfa2a6d3d35a1e4f52289b669c710d300ebd.tar.gz org.eclipse.papyrus-4da7dfa2a6d3d35a1e4f52289b669c710d300ebd.tar.xz org.eclipse.papyrus-4da7dfa2a6d3d35a1e4f52289b669c710d300ebd.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>
Diffstat (limited to 'plugins/infra/gmfdiag/css')
-rwxr-xr-x | plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCssClassStyleCommand.java | 74 |
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); + } + } + } + +} |