diff options
author | Quentin Le Menez | 2018-01-09 10:09:46 +0000 |
---|---|---|
committer | Quentin Le Menez | 2018-01-09 13:18:15 +0000 |
commit | d98116b5b376f18b6cf626ba4158a35fe9a4a64e (patch) | |
tree | 4458c9c5ada0a216b385813a56ea9a9b8c7b6509 /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag | |
parent | 453e99bc2dcbd5fabad100f9d0d5f682013c3b19 (diff) | |
download | org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.gz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.xz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.zip |
Bug 515367 - [releng] Uniformization of the end of lines to Unix standard
- Format the EOL of all the files matched by: grep -rIUs . | xargs -Ifile dos2unix -k 'file'
Change-Id: I5c41d540a9a67b50de9b912ab35e16cc9a912961
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag')
18 files changed, 1408 insertions, 1408 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/Activator.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/Activator.java index 333942e1ee3..4ba29982eec 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/Activator.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/Activator.java @@ -1,69 +1,69 @@ -/*****************************************************************************
- * 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.properties;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.gmfdiag.css.properties"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
+/***************************************************************************** + * 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.properties; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.gmfdiag.css.properties"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllCSSStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllCSSStyleSheetCommand.java index 46362ca75d3..cc825d3a06e 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllCSSStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllCSSStyleSheetCommand.java @@ -1,65 +1,65 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AddAllCustomStyleListValueCommand;
-
-
-public class AddAllCSSStyleSheetCommand extends AddAllCustomStyleListValueCommand {
-
- protected final Set<EObject> createdEObjects = new HashSet<EObject>();
-
- public AddAllCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Collection<?> values, int index) {
- super(domain, view, styleName, styleClass, styleFeature, values, index);
- }
-
- public AddAllCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature feature, Collection<?> values) {
- super(domain, view, styleName, styleClass, feature, values);
- }
-
- @Override
- public void execute() {
- for (Object value : values) {
- if (value instanceof EObject) {
- EObject eObject = (EObject) value;
- if (eObject.eResource() == null) {
- view.eResource().getContents().add(eObject);
- createdEObjects.add(eObject);
- }
- }
- }
- super.execute();
- }
-
- @Override
- public void undo() {
- for (Object value : values) {
- if (value instanceof EObject) {
- EObject eObject = (EObject) value;
- if (createdEObjects.contains(eObject)) {
- eObject.eResource().getContents().remove(eObject);
- }
- }
- }
- super.undo();
- }
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AddAllCustomStyleListValueCommand; + + +public class AddAllCSSStyleSheetCommand extends AddAllCustomStyleListValueCommand { + + protected final Set<EObject> createdEObjects = new HashSet<EObject>(); + + public AddAllCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Collection<?> values, int index) { + super(domain, view, styleName, styleClass, styleFeature, values, index); + } + + public AddAllCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature feature, Collection<?> values) { + super(domain, view, styleName, styleClass, feature, values); + } + + @Override + public void execute() { + for (Object value : values) { + if (value instanceof EObject) { + EObject eObject = (EObject) value; + if (eObject.eResource() == null) { + view.eResource().getContents().add(eObject); + createdEObjects.add(eObject); + } + } + } + super.execute(); + } + + @Override + public void undo() { + for (Object value : values) { + if (value instanceof EObject) { + EObject eObject = (EObject) value; + if (createdEObjects.contains(eObject)) { + eObject.eResource().getContents().remove(eObject); + } + } + } + super.undo(); + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllModelStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllModelStyleSheetCommand.java index 61a780cef90..df8c98b7479 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllModelStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddAllModelStyleSheetCommand.java @@ -1,73 +1,73 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage;
-
-/**
- * Add stylesheet's model Command.
- *
- * @author Mickael ADAM
- */
-public class AddAllModelStyleSheetCommand extends RecordingCommand {
-
- /** The resource. */
- private Resource resource;
-
- /** The values. */
- private Collection<?> values;
-
- /**
- * Constructor.
- *
- * @param domain
- * the domain
- * @param resource
- * the resource
- * @param values
- * the values
- */
- public AddAllModelStyleSheetCommand(TransactionalEditingDomain domain, Resource resource, Collection<?> values) {
- super(domain);
- this.resource = resource;
- this.values = values;
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- public void doExecute() {
-
- // Get the model styleSheet on the resource
- Object modelStyleSheetObject = EcoreUtil.getObjectByType(resource.getContents(), StylesheetsPackage.Literals.MODEL_STYLE_SHEETS);
-
- // For each styleSheet
- for (Object styleSheetRef : values) {
- // Add it to the modelStyleSheet
- ((ModelStyleSheets) modelStyleSheetObject).getStylesheets().add((StyleSheet) styleSheetRef);
- }
- // Add the modelStyleSheet to the resource
- resource.getContents().add(((ModelStyleSheets) modelStyleSheetObject));
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import java.util.Collection; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage; + +/** + * Add stylesheet's model Command. + * + * @author Mickael ADAM + */ +public class AddAllModelStyleSheetCommand extends RecordingCommand { + + /** The resource. */ + private Resource resource; + + /** The values. */ + private Collection<?> values; + + /** + * Constructor. + * + * @param domain + * the domain + * @param resource + * the resource + * @param values + * the values + */ + public AddAllModelStyleSheetCommand(TransactionalEditingDomain domain, Resource resource, Collection<?> values) { + super(domain); + this.resource = resource; + this.values = values; + } + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + public void doExecute() { + + // Get the model styleSheet on the resource + Object modelStyleSheetObject = EcoreUtil.getObjectByType(resource.getContents(), StylesheetsPackage.Literals.MODEL_STYLE_SHEETS); + + // For each styleSheet + for (Object styleSheetRef : values) { + // Add it to the modelStyleSheet + ((ModelStyleSheets) modelStyleSheetObject).getStylesheets().add((StyleSheet) styleSheetRef); + } + // Add the modelStyleSheet to the resource + resource.getContents().add(((ModelStyleSheets) modelStyleSheetObject)); + } +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCSSStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCSSStyleSheetCommand.java index 214a02de491..a5aa6744209 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCSSStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddCSSStyleSheetCommand.java @@ -1,61 +1,61 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AddCustomStyleListValueCommand;
-
-
-public class AddCSSStyleSheetCommand extends AddCustomStyleListValueCommand implements Command {
-
- protected boolean createdEObject = false;
-
- public AddCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value) {
- super(domain, view, styleName, styleClass, styleFeature, value);
- }
-
- public AddCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value, int index) {
- super(domain, view, styleName, styleClass, styleFeature, value, index);
- }
-
- @Override
- public void execute() {
- if (value instanceof EObject) {
- EObject eObject = (EObject) value;
- if (eObject.eResource() == null) {
- view.eResource().getContents().add(eObject);
- createdEObject = true;
- }
- }
-
- super.execute();
- }
-
- @Override
- public void undo() {
- if (value instanceof EObject) {
- EObject eObject = (EObject) value;
- if (createdEObject) {
- eObject.eResource().getContents().remove(eObject);
- }
- }
- super.undo();
- }
-
-
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AddCustomStyleListValueCommand; + + +public class AddCSSStyleSheetCommand extends AddCustomStyleListValueCommand implements Command { + + protected boolean createdEObject = false; + + public AddCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value) { + super(domain, view, styleName, styleClass, styleFeature, value); + } + + public AddCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value, int index) { + super(domain, view, styleName, styleClass, styleFeature, value, index); + } + + @Override + public void execute() { + if (value instanceof EObject) { + EObject eObject = (EObject) value; + if (eObject.eResource() == null) { + view.eResource().getContents().add(eObject); + createdEObject = true; + } + } + + super.execute(); + } + + @Override + public void undo() { + if (value instanceof EObject) { + EObject eObject = (EObject) value; + if (createdEObject) { + eObject.eResource().getContents().remove(eObject); + } + } + super.undo(); + } + + + +} 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 index 1041bab9e02..00b912a4ade 100644 --- 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 @@ -1,72 +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);
- }
-
-
- }
-
-}
+/***************************************************************************** + * 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); + } + + + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddModelStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddModelStyleSheetCommand.java index 2cb0fb92415..2559c5ecfd9 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddModelStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/AddModelStyleSheetCommand.java @@ -1,58 +1,58 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- * Command to add a object to the resource.
- *
- * @author Mickael ADAM
- */
-public class AddModelStyleSheetCommand extends RecordingCommand {
-
- /** The resource. */
- private Resource resource;
-
- /** The object. */
- private EObject object;
-
- /**
- * Instantiates a new adds the model style sheet command.
- *
- * @param domain
- * the domain
- * @param resource
- * the resource
- * @param object
- * the object
- */
- public AddModelStyleSheetCommand(TransactionalEditingDomain domain, Resource resource, EObject object) {
- super(domain);
- this.resource = resource;
- this.object = object;
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
-
- @Override
- public void doExecute() {
- resource.getContents().add(object);
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + *****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +/** + * Command to add a object to the resource. + * + * @author Mickael ADAM + */ +public class AddModelStyleSheetCommand extends RecordingCommand { + + /** The resource. */ + private Resource resource; + + /** The object. */ + private EObject object; + + /** + * Instantiates a new adds the model style sheet command. + * + * @param domain + * the domain + * @param resource + * the resource + * @param object + * the object + */ + public AddModelStyleSheetCommand(TransactionalEditingDomain domain, Resource resource, EObject object) { + super(domain); + this.resource = resource; + this.object = object; + } + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + + @Override + public void doExecute() { + resource.getContents().add(object); + } +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/CustomModelStyleSheetListener.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/CustomModelStyleSheetListener.java index 02c67061ebf..5ddac5db99f 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/CustomModelStyleSheetListener.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/CustomModelStyleSheetListener.java @@ -1,93 +1,93 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage;
-
-/**
- * A Listener for ModelStyleSheet List
- *
- * @author Mickaël ADAM
- */
-public class CustomModelStyleSheetListener extends AdapterImpl {
-
- private final IChangeListener listener;
-
- private boolean disposed;
-
- /**
- * Instantiates a new custom model styleSheet listener.
- *
- * @param notationResource
- * the notation resource
- * @param source
- * the source
- * @param listener
- * the listener
- */
- public CustomModelStyleSheetListener(Resource notationResource, ModelStyleSheets source, IChangeListener listener) {
-
- this.listener = listener;
-
- // add an eAdapter on it
- source.eAdapters().add(this);
- // Get all StyleSheets from the modelStyleSheet
- EList<StyleSheet> objectsFromModelSS = source.getStylesheets();
-
- for (StyleSheet styleSheet : objectsFromModelSS) {
- styleSheet.eAdapters().add(this);
- }
- }
-
- /**
- * Notify changed.
- *
- * @param notification
- * the notification
- * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
- */
- @Override
- public void notifyChanged(Notification notification) {
- // The listener has been disposed: remove it from the notifier
- // and ignore the notification
- if (disposed) {
- ((Notifier) notification.getNotifier()).eAdapters().remove(this);
- return;
- }
-
- if (notification.getFeature() == StylesheetsPackage.eINSTANCE.getModelStyleSheets_Stylesheets()) {
- if (!notification.isTouch()) {
- handleChange(notification.getNotifier());
- }
- }
- }
-
- private void handleChange(Object value) {
- if (value instanceof ModelStyleSheets) {
- listener.handleChange(null);
- }
- }
-
- public void dispose() {
- this.disposed = true;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage; + +/** + * A Listener for ModelStyleSheet List + * + * @author Mickaël ADAM + */ +public class CustomModelStyleSheetListener extends AdapterImpl { + + private final IChangeListener listener; + + private boolean disposed; + + /** + * Instantiates a new custom model styleSheet listener. + * + * @param notationResource + * the notation resource + * @param source + * the source + * @param listener + * the listener + */ + public CustomModelStyleSheetListener(Resource notationResource, ModelStyleSheets source, IChangeListener listener) { + + this.listener = listener; + + // add an eAdapter on it + source.eAdapters().add(this); + // Get all StyleSheets from the modelStyleSheet + EList<StyleSheet> objectsFromModelSS = source.getStylesheets(); + + for (StyleSheet styleSheet : objectsFromModelSS) { + styleSheet.eAdapters().add(this); + } + } + + /** + * Notify changed. + * + * @param notification + * the notification + * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) + */ + @Override + public void notifyChanged(Notification notification) { + // The listener has been disposed: remove it from the notifier + // and ignore the notification + if (disposed) { + ((Notifier) notification.getNotifier()).eAdapters().remove(this); + return; + } + + if (notification.getFeature() == StylesheetsPackage.eINSTANCE.getModelStyleSheets_Stylesheets()) { + if (!notification.isTouch()) { + handleChange(notification.getNotifier()); + } + } + } + + private void handleChange(Object value) { + if (value instanceof ModelStyleSheets) { + listener.handleChange(null); + } + } + + public void dispose() { + this.disposed = true; + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/DiagramStyleSheetObservableList.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/DiagramStyleSheetObservableList.java index 079230ec4eb..5c925730610 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/DiagramStyleSheetObservableList.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/DiagramStyleSheetObservableList.java @@ -1,75 +1,75 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableList;
-
-/**
- * An ObservableList for manipulating CSS StyleSheets in a Diagram. The styleSheets
- * are stored in the view's Resource, and added as a CustomStyle (GMF NamedStyle)
- * in the view. When the last reference to a CSS Stylesheet is removed, it is
- * removed from the view's resource.
- *
- * A Stylesheet will only be deleted if it is contained in the same resource as
- * the argument View (A Model B referencing a StyleSheet from a Model A cannot
- * delete it).
- *
- *
- * @author Camille Letavernier
- */
-public class DiagramStyleSheetObservableList extends CustomEObjectStyleObservableList {
-
- public DiagramStyleSheetObservableList(View view, EditingDomain domain, String styleName) {
- super(view, domain, styleName);
- }
-
- @Override
- public Command getAddCommand(int index, Object value) {
- return new AddCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value, index);
- }
-
- @Override
- public Command getAddCommand(Object value) {
- return new AddCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value);
- }
-
- @Override
- public Command getAddAllCommand(Collection<?> values) {
- return new AddAllCSSStyleSheetCommand(domain, view, styleName, eClass, feature, values);
- }
-
- @Override
- public Command getAddAllCommand(int index, Collection<?> values) {
- return new AddAllCSSStyleSheetCommand(domain, view, styleName, eClass, feature, values, index);
- }
-
- @Override
- public Command getRemoveCommand(Object value) {
- return new RemoveCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value);
- }
-
- @Override
- public Command getRemoveAllCommand(Collection<?> values) {
- return new RemoveAllCSSStyleSheetValueCommand(domain, view, styleName, eClass, feature, values);
- }
-
- @Override
- public Command getSetCommand(int index, Object value) {
- return new SetCSSStyleSheetCommand(domain, view, styleName, eClass, feature, index, value);
- }
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import java.util.Collection; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableList; + +/** + * An ObservableList for manipulating CSS StyleSheets in a Diagram. The styleSheets + * are stored in the view's Resource, and added as a CustomStyle (GMF NamedStyle) + * in the view. When the last reference to a CSS Stylesheet is removed, it is + * removed from the view's resource. + * + * A Stylesheet will only be deleted if it is contained in the same resource as + * the argument View (A Model B referencing a StyleSheet from a Model A cannot + * delete it). + * + * + * @author Camille Letavernier + */ +public class DiagramStyleSheetObservableList extends CustomEObjectStyleObservableList { + + public DiagramStyleSheetObservableList(View view, EditingDomain domain, String styleName) { + super(view, domain, styleName); + } + + @Override + public Command getAddCommand(int index, Object value) { + return new AddCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value, index); + } + + @Override + public Command getAddCommand(Object value) { + return new AddCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value); + } + + @Override + public Command getAddAllCommand(Collection<?> values) { + return new AddAllCSSStyleSheetCommand(domain, view, styleName, eClass, feature, values); + } + + @Override + public Command getAddAllCommand(int index, Collection<?> values) { + return new AddAllCSSStyleSheetCommand(domain, view, styleName, eClass, feature, values, index); + } + + @Override + public Command getRemoveCommand(Object value) { + return new RemoveCSSStyleSheetCommand(domain, view, styleName, eClass, feature, value); + } + + @Override + public Command getRemoveAllCommand(Collection<?> values) { + return new RemoveAllCSSStyleSheetValueCommand(domain, view, styleName, eClass, feature, values); + } + + @Override + public Command getSetCommand(int index, Object value) { + return new SetCSSStyleSheetCommand(domain, view, styleName, eClass, feature, index, value); + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/ModelStyleSheetObservableList.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/ModelStyleSheetObservableList.java index 9069087ccbc..d34cf0500f4 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/ModelStyleSheetObservableList.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/ModelStyleSheetObservableList.java @@ -1,215 +1,215 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Micka�l Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.EObjectListValueStyle;
-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.resource.CSSNotationResource;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets;
-import org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList;
-
-
-/**
- *
- * EMFObservableList containing stylesheets of the model.
- *
- * @author Mickael ADAM
- *
- */
-public class ModelStyleSheetObservableList extends EMFObservableList implements IChangeListener {
-
- /** The notation resource. */
- private Resource notationResource;
-
- /** The domain. */
- private TransactionalEditingDomain domain;
-
- /** The listener. */
- private CustomModelStyleSheetListener listener;
-
- /**
- * Constructor.
- *
- * @param notationResource
- * the notation resource
- * @param wrappedList
- * the wrapped list
- * @param domain
- * the domain
- * @param source
- * the source
- * @param feature
- * the feature
- */
- public ModelStyleSheetObservableList(Resource notationResource, List<?> wrappedList, TransactionalEditingDomain domain, EObject source, EStructuralFeature feature) {
- super(wrappedList, domain, source, feature);
- this.notationResource = notationResource;
- this.domain = domain;
-
- source.eAdapters().add(listener = new CustomModelStyleSheetListener(notationResource, (ModelStyleSheets) source, this));
- }
-
- /**
- * Used to add manually.
- *
- * @param values
- * the values
- * @return the command to add values
- * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getAddAllCommand(java.util.Collection)
- */
- @Override
- public Command getAddAllCommand(Collection<?> values) {
- CompoundCommand compoundCommand = new CompoundCommand();
-
- if (source.eResource() == null) {
- compoundCommand.append(new RecordingCommand(domain, "Create ModelStylesheet") {
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- notationResource.getContents().add(source);
- }
-
- });
-
- compoundCommand.append(new AbstractCommand("Initialize ModelCSSEngine Adapter") {
-
- public void redo() {
- execute();
- }
-
- public void execute() {
- ExtendedCSSEngine engine = CSSNotationResource.getEngine(notationResource);
- if (engine instanceof ModelCSSEngine) {
- ((ModelCSSEngine) engine).initAdapter();
- }
- }
-
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
- *
- * @return
- */
- @Override
- public boolean canUndo() {
- return true;
- }
-
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#undo()
- *
- */
- @Override
- public void undo() {
- ExtendedCSSEngine engine = CSSNotationResource.getEngine(notationResource);
- if (engine instanceof ModelCSSEngine) {
- ((ModelCSSEngine) engine).disposeAdapter();
- }
- }
-
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
- *
- * @return
- */
- @Override
- protected boolean prepare() {
- return true;
- }
- });
- }
-
- compoundCommand.append(super.getAddAllCommand(values));
- compoundCommand.append(new AddAllModelStyleSheetCommand(domain, notationResource, values));
- return compoundCommand;
- }
-
- /**
- * Used to remove manually styleSheet.
- *
- * @param value
- * the value
- * @return the removes command
- * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getRemoveCommand(java.lang.Object)
- */
- @Override
- public Command getRemoveCommand(Object value) {
- CompoundCommand compoundCommand = new CompoundCommand();
- compoundCommand.append(super.getRemoveCommand(value));
-
- // Retrieve all instance of EObjectListValueStyleImpl on all CSSDiagramImpl to
- EList<EObject> objectsFromResource = notationResource.getContents();
- for (Object objectFromResource : objectsFromResource) {
- // For each CSSDiagramImpl of the resource look for EObjectListValueStyleImpl
- if (objectFromResource instanceof CSSDiagram) {
- EList<EObject> objectsFromDiagram = ((CSSDiagram) objectFromResource).getStyles();
- for (Object objectFromDiagram : objectsFromDiagram) {
- // For each EObjectListValueStyleImpl of each diagram
- if (objectFromDiagram instanceof EObjectListValueStyle) {
- for (Object styleSheetReference : ((EObjectListValueStyle) objectFromDiagram).getEObjectListValue()) {
- // If the current style sheet to delete from model exist on a diagram, add it on the root
- if (value == styleSheetReference) {
- compoundCommand.append(new RemoveObjectCommand(domain, (EObject) styleSheetReference));
- compoundCommand.append(new AddModelStyleSheetCommand(domain, notationResource, (EObject) styleSheetReference));
- }
- }
- }
- }
- }
- }
- return compoundCommand;
- }
-
- /**
- * Used to remove all StyleSheets before replace the new list.
- *
- * @param values
- * the values
- * @return the removes the all command
- * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getRemoveAllCommand(java.util.Collection)
- */
- @Override
- public Command getRemoveAllCommand(Collection<?> values) {
- return new RemoveAllModelStyleSheetValueCommand(domain, notationResource, values);
- }
-
- /**
- * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#dispose()
- *
- */
- @Override
- public void dispose() {
- source.eAdapters().remove(listener);
- listener.dispose();
- listener = null;
- super.dispose();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Micka�l Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.EObjectListValueStyle; +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.resource.CSSNotationResource; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets; +import org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList; + + +/** + * + * EMFObservableList containing stylesheets of the model. + * + * @author Mickael ADAM + * + */ +public class ModelStyleSheetObservableList extends EMFObservableList implements IChangeListener { + + /** The notation resource. */ + private Resource notationResource; + + /** The domain. */ + private TransactionalEditingDomain domain; + + /** The listener. */ + private CustomModelStyleSheetListener listener; + + /** + * Constructor. + * + * @param notationResource + * the notation resource + * @param wrappedList + * the wrapped list + * @param domain + * the domain + * @param source + * the source + * @param feature + * the feature + */ + public ModelStyleSheetObservableList(Resource notationResource, List<?> wrappedList, TransactionalEditingDomain domain, EObject source, EStructuralFeature feature) { + super(wrappedList, domain, source, feature); + this.notationResource = notationResource; + this.domain = domain; + + source.eAdapters().add(listener = new CustomModelStyleSheetListener(notationResource, (ModelStyleSheets) source, this)); + } + + /** + * Used to add manually. + * + * @param values + * the values + * @return the command to add values + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getAddAllCommand(java.util.Collection) + */ + @Override + public Command getAddAllCommand(Collection<?> values) { + CompoundCommand compoundCommand = new CompoundCommand(); + + if (source.eResource() == null) { + compoundCommand.append(new RecordingCommand(domain, "Create ModelStylesheet") { + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + protected void doExecute() { + notationResource.getContents().add(source); + } + + }); + + compoundCommand.append(new AbstractCommand("Initialize ModelCSSEngine Adapter") { + + public void redo() { + execute(); + } + + public void execute() { + ExtendedCSSEngine engine = CSSNotationResource.getEngine(notationResource); + if (engine instanceof ModelCSSEngine) { + ((ModelCSSEngine) engine).initAdapter(); + } + } + + /** + * @see org.eclipse.emf.common.command.AbstractCommand#canUndo() + * + * @return + */ + @Override + public boolean canUndo() { + return true; + } + + /** + * @see org.eclipse.emf.common.command.AbstractCommand#undo() + * + */ + @Override + public void undo() { + ExtendedCSSEngine engine = CSSNotationResource.getEngine(notationResource); + if (engine instanceof ModelCSSEngine) { + ((ModelCSSEngine) engine).disposeAdapter(); + } + } + + /** + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + * + * @return + */ + @Override + protected boolean prepare() { + return true; + } + }); + } + + compoundCommand.append(super.getAddAllCommand(values)); + compoundCommand.append(new AddAllModelStyleSheetCommand(domain, notationResource, values)); + return compoundCommand; + } + + /** + * Used to remove manually styleSheet. + * + * @param value + * the value + * @return the removes command + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getRemoveCommand(java.lang.Object) + */ + @Override + public Command getRemoveCommand(Object value) { + CompoundCommand compoundCommand = new CompoundCommand(); + compoundCommand.append(super.getRemoveCommand(value)); + + // Retrieve all instance of EObjectListValueStyleImpl on all CSSDiagramImpl to + EList<EObject> objectsFromResource = notationResource.getContents(); + for (Object objectFromResource : objectsFromResource) { + // For each CSSDiagramImpl of the resource look for EObjectListValueStyleImpl + if (objectFromResource instanceof CSSDiagram) { + EList<EObject> objectsFromDiagram = ((CSSDiagram) objectFromResource).getStyles(); + for (Object objectFromDiagram : objectsFromDiagram) { + // For each EObjectListValueStyleImpl of each diagram + if (objectFromDiagram instanceof EObjectListValueStyle) { + for (Object styleSheetReference : ((EObjectListValueStyle) objectFromDiagram).getEObjectListValue()) { + // If the current style sheet to delete from model exist on a diagram, add it on the root + if (value == styleSheetReference) { + compoundCommand.append(new RemoveObjectCommand(domain, (EObject) styleSheetReference)); + compoundCommand.append(new AddModelStyleSheetCommand(domain, notationResource, (EObject) styleSheetReference)); + } + } + } + } + } + } + return compoundCommand; + } + + /** + * Used to remove all StyleSheets before replace the new list. + * + * @param values + * the values + * @return the removes the all command + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#getRemoveAllCommand(java.util.Collection) + */ + @Override + public Command getRemoveAllCommand(Collection<?> values) { + return new RemoveAllModelStyleSheetValueCommand(domain, notationResource, values); + } + + /** + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#dispose() + * + */ + @Override + public void dispose() { + source.eAdapters().remove(listener); + listener.dispose(); + listener = null; + super.dispose(); + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllCSSStyleSheetValueCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllCSSStyleSheetValueCommand.java index c2bf8504376..f9d58cbaa00 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllCSSStyleSheetValueCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllCSSStyleSheetValueCommand.java @@ -1,67 +1,67 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.RemoveAllCustomStyleListValueCommand;
-
-
-public class RemoveAllCSSStyleSheetValueCommand extends RemoveAllCustomStyleListValueCommand {
-
- protected final Set<EObject> deletedEObjects = new HashSet<EObject>();
-
- public RemoveAllCSSStyleSheetValueCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Collection<?> values) {
- super(domain, view, styleName, eClass, feature, values);
- }
-
- @Override
- public void execute() {
- for (Object value : values) {
- if (value instanceof EObject) {
- EObject styleSheet = (EObject) value;
- Collection<EStructuralFeature.Setting> references = EMFHelper.getUsages(styleSheet);
- // We're removing the last reference to this styleSheet (Only if the stylesheet is contained
- // in the same resource as the view referencing it... We don't modify external models)
- if (references.size() == 1 && styleSheet.eResource() == view.eResource()) {
- deletedEObjects.add(styleSheet);
- styleSheet.eResource().getContents().remove(styleSheet);
- }
- }
- }
-
- super.execute();
- }
-
- @Override
- public void undo() {
- for (Object value : values) {
- if (value instanceof EObject) {
- EObject eObject = (EObject) value;
- if (deletedEObjects.contains(eObject)) {
- // We destroyed the StyleSheet EObject: recreate it in its previous resource
- view.eResource().getContents().add(eObject);
- }
- }
- }
- super.undo();
- }
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.RemoveAllCustomStyleListValueCommand; + + +public class RemoveAllCSSStyleSheetValueCommand extends RemoveAllCustomStyleListValueCommand { + + protected final Set<EObject> deletedEObjects = new HashSet<EObject>(); + + public RemoveAllCSSStyleSheetValueCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Collection<?> values) { + super(domain, view, styleName, eClass, feature, values); + } + + @Override + public void execute() { + for (Object value : values) { + if (value instanceof EObject) { + EObject styleSheet = (EObject) value; + Collection<EStructuralFeature.Setting> references = EMFHelper.getUsages(styleSheet); + // We're removing the last reference to this styleSheet (Only if the stylesheet is contained + // in the same resource as the view referencing it... We don't modify external models) + if (references.size() == 1 && styleSheet.eResource() == view.eResource()) { + deletedEObjects.add(styleSheet); + styleSheet.eResource().getContents().remove(styleSheet); + } + } + } + + super.execute(); + } + + @Override + public void undo() { + for (Object value : values) { + if (value instanceof EObject) { + EObject eObject = (EObject) value; + if (deletedEObjects.contains(eObject)) { + // We destroyed the StyleSheet EObject: recreate it in its previous resource + view.eResource().getContents().add(eObject); + } + } + } + super.undo(); + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllModelStyleSheetValueCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllModelStyleSheetValueCommand.java index 26eb1affb5e..239a19a2efd 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllModelStyleSheetValueCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveAllModelStyleSheetValueCommand.java @@ -1,84 +1,84 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import java.util.Collection;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
-
-/**
- *
- * Command to remove all styleSheets from the resource.
- *
- * @author Mickael ADAM
- *
- */
-public class RemoveAllModelStyleSheetValueCommand extends RecordingCommand {
-
- /** The values. */
- private Collection<?> values;
-
- /** The resource. */
- private Resource resource;
-
- /** The domain. */
- private TransactionalEditingDomain domain;
-
- /**
- * Constructor.
- *
- * @param domain
- * the domain
- * @param resource
- * the resource
- * @param values
- * the values
- */
- public RemoveAllModelStyleSheetValueCommand(TransactionalEditingDomain domain, Resource resource, Collection<?> values) {
- super(domain);
- this.resource = resource;
- this.values = values;
- this.domain = domain;
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- public void doExecute() {
- for (Object value : values) {
- if (value instanceof StyleSheetReference) {
- StyleSheetReference styleSheet = (StyleSheetReference) value;
-
- // Create a request to delete the styleSheet
- DestroyElementRequest request = new DestroyElementRequest(domain, styleSheet, false);
- // Get the command to delete the styleSheet
- DestroyElementCommand command = new DestroyElementCommand(request);
- try {
- // execute command
- command.execute(new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import java.util.Collection; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference; + +/** + * + * Command to remove all styleSheets from the resource. + * + * @author Mickael ADAM + * + */ +public class RemoveAllModelStyleSheetValueCommand extends RecordingCommand { + + /** The values. */ + private Collection<?> values; + + /** The resource. */ + private Resource resource; + + /** The domain. */ + private TransactionalEditingDomain domain; + + /** + * Constructor. + * + * @param domain + * the domain + * @param resource + * the resource + * @param values + * the values + */ + public RemoveAllModelStyleSheetValueCommand(TransactionalEditingDomain domain, Resource resource, Collection<?> values) { + super(domain); + this.resource = resource; + this.values = values; + this.domain = domain; + } + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + public void doExecute() { + for (Object value : values) { + if (value instanceof StyleSheetReference) { + StyleSheetReference styleSheet = (StyleSheetReference) value; + + // Create a request to delete the styleSheet + DestroyElementRequest request = new DestroyElementRequest(domain, styleSheet, false); + // Get the command to delete the styleSheet + DestroyElementCommand command = new DestroyElementCommand(request); + try { + // execute command + command.execute(new NullProgressMonitor(), null); + } catch (ExecutionException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCSSStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCSSStyleSheetCommand.java index 721eb5bd119..fd90e303291 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCSSStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveCSSStyleSheetCommand.java @@ -1,59 +1,59 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.RemoveCustomStyleListValueCommand;
-
-
-public class RemoveCSSStyleSheetCommand extends RemoveCustomStyleListValueCommand {
-
- protected Resource previousResource;
-
- public RemoveCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Object value) {
- super(domain, view, styleName, eClass, feature, value);
- }
-
- @Override
- public void execute() {
- if (value instanceof EObject) {
- EObject styleSheet = (EObject) value;
- Collection<EStructuralFeature.Setting> references = EMFHelper.getUsages(styleSheet);
- // We're removing the last reference to this styleSheet (Only if the stylesheet is contained
- // in the same resource as the view referencing it... We don't modify external models)
- if (references.size() == 1 && styleSheet.eResource() == view.eResource()) {
- previousResource = styleSheet.eResource();
- styleSheet.eResource().getContents().remove(styleSheet);
- }
- }
-
- super.execute();
- }
-
- @Override
- public void undo() {
- // We destroyed the StyleSheet EObject: recreate it in its previous resource
- if (previousResource != null) {
- previousResource.getContents().add((EObject) value);
- }
- super.undo();
- }
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.RemoveCustomStyleListValueCommand; + + +public class RemoveCSSStyleSheetCommand extends RemoveCustomStyleListValueCommand { + + protected Resource previousResource; + + public RemoveCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Object value) { + super(domain, view, styleName, eClass, feature, value); + } + + @Override + public void execute() { + if (value instanceof EObject) { + EObject styleSheet = (EObject) value; + Collection<EStructuralFeature.Setting> references = EMFHelper.getUsages(styleSheet); + // We're removing the last reference to this styleSheet (Only if the stylesheet is contained + // in the same resource as the view referencing it... We don't modify external models) + if (references.size() == 1 && styleSheet.eResource() == view.eResource()) { + previousResource = styleSheet.eResource(); + styleSheet.eResource().getContents().remove(styleSheet); + } + } + + super.execute(); + } + + @Override + public void undo() { + // We destroyed the StyleSheet EObject: recreate it in its previous resource + if (previousResource != null) { + previousResource.getContents().add((EObject) value); + } + super.undo(); + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveObjectCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveObjectCommand.java index 72637735fbc..888866dad50 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveObjectCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/RemoveObjectCommand.java @@ -1,71 +1,71 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-
-/**
- *
- * Command to remove an EObject from its containing resource and/or its containing object.
- *
- * @author Mickael ADAM
- *
- */
-public class RemoveObjectCommand extends RecordingCommand {
-
-
- /** The object. */
- private EObject object;
-
- /** The domain. */
- private TransactionalEditingDomain domain;
-
- /**
- * Constructor.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- */
- public RemoveObjectCommand(TransactionalEditingDomain domain, EObject object) {
- super(domain);
- this.domain = domain;
- this.object = object;
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- // Create a request to delete the object
- DestroyElementRequest request = new DestroyElementRequest(domain, object, false);
- // Get the command to delete the object
- DestroyElementCommand command = new DestroyElementCommand(request);
- try {
- // execute command
- command.execute(new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Mickaël Adam (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; + +/** + * + * Command to remove an EObject from its containing resource and/or its containing object. + * + * @author Mickael ADAM + * + */ +public class RemoveObjectCommand extends RecordingCommand { + + + /** The object. */ + private EObject object; + + /** The domain. */ + private TransactionalEditingDomain domain; + + /** + * Constructor. + * + * @param domain + * the domain + * @param object + * the object + */ + public RemoveObjectCommand(TransactionalEditingDomain domain, EObject object) { + super(domain); + this.domain = domain; + this.object = object; + } + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + protected void doExecute() { + // Create a request to delete the object + DestroyElementRequest request = new DestroyElementRequest(domain, object, false); + // Get the command to delete the object + DestroyElementCommand command = new DestroyElementCommand(request); + try { + // execute command + command.execute(new NullProgressMonitor(), null); + } catch (ExecutionException e) { + e.printStackTrace(); + } + } +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/SetCSSStyleSheetCommand.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/SetCSSStyleSheetCommand.java index 1e290bccd86..35b2d74806c 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/SetCSSStyleSheetCommand.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/databinding/SetCSSStyleSheetCommand.java @@ -1,45 +1,45 @@ -/*****************************************************************************
- * 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.properties.databinding;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.SetCustomStyleListValueCommand;
-
-//TODO: This a remove & add command
-//This command is currently never called in Papyrus
-//See DiagramStyleSheetObservableList#getSetCommand(int, Object)
-public class SetCSSStyleSheetCommand extends SetCustomStyleListValueCommand {
-
- public SetCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, int index, Object value) {
- super(domain, view, styleName, eClass, feature, index, value);
- // TODO: implement execute & undo
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void execute() {
- // TODO: Check whether we're removing an element. If so, remove it (And delete it, eventually).
- // In any case, create the new element and add it in the resource. Keep track of each.
- super.execute();
- }
-
- @Override
- public void undo() {
- // TODO: If an element has been removed, recreate it and add it in the view's resource
- // Remove the newly created element
- super.undo();
- }
-
-}
+/***************************************************************************** + * 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.properties.databinding; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.SetCustomStyleListValueCommand; + +//TODO: This a remove & add command +//This command is currently never called in Papyrus +//See DiagramStyleSheetObservableList#getSetCommand(int, Object) +public class SetCSSStyleSheetCommand extends SetCustomStyleListValueCommand { + + public SetCSSStyleSheetCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, int index, Object value) { + super(domain, view, styleName, eClass, feature, index, value); + // TODO: implement execute & undo + throw new UnsupportedOperationException(); + } + + @Override + public void execute() { + // TODO: Check whether we're removing an element. If so, remove it (And delete it, eventually). + // In any case, create the new element and add it in the resource. Keep track of each. + super.execute(); + } + + @Override + public void undo() { + // TODO: If an element has been removed, recreate it and add it in the view's resource + // Remove the newly created element + super.undo(); + } + +} 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 73818b6f88a..b8514f795c2 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 @@ -1,136 +1,136 @@ -/*****************************************************************************
- * Copyright (c) 2014 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
- * Micka�l Adam (ALL4TEC) mickael.adam@all4tec.net - bug 429642
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.modelelement;
-
-import org.eclipse.core.databinding.observable.IObservable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ILabelProvider;
-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.creation.StyleSheetFactory;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.DiagramStyleSheetObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.ModelStyleSheetObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetContentProvider;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetLabelProvider;
-import org.eclipse.papyrus.infra.gmfdiag.css.provider.CSSClassContentProvider;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsFactory;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage;
-import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement;
-import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
-import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
-import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-
-public class CSSModelElement extends CustomStyleModelElement {
-
- public CSSModelElement(View source, DataContextElement context) {
- super(source, context);
- }
-
- public CSSModelElement(View source, EditingDomain domain, DataContextElement element) {
- super(source, domain, element);
- }
-
- @Override
- public ReferenceValueFactory getValueFactory(String propertyPath) {
- if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) {
- return new StyleSheetFactory((View) this.source);
- }
- if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) {
- return new StyleSheetFactory((View) this.source);
- }
- if (CSSStyles.CSS_GMF_CLASS_KEY.equals(propertyPath)) {
- StringEditionFactory factory = new StringEditionFactory();
- factory.setContentProvider(getContentProvider(propertyPath));
- return factory;
- }
- return super.getValueFactory(propertyPath);
- }
-
- @Override
- public IObservable doGetObservable(String propertyPath) {
- if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) {
- if (source instanceof View) {
- return new DiagramStyleSheetObservableList((View) source, domain, propertyPath);
- }
- }
- if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) {
- // Get the resource
- final Resource notationResource = source.eResource();
- if (notationResource == null) { // May happen e.g. during deletion of the diagram
- return null;
- }
- // Get the model styleSheet Object
- Object modelStyleSheetObject = EcoreUtil.getObjectByType(notationResource.getContents(), StylesheetsPackage.Literals.MODEL_STYLE_SHEETS);
- // The model styleSheet
- final ModelStyleSheets modelStyleSheetsSource = modelStyleSheetObject instanceof ModelStyleSheets ? (ModelStyleSheets) modelStyleSheetObject : StylesheetsFactory.eINSTANCE.createModelStyleSheets();
- // If the modelStylesheet doesn't exist
-
- return new ModelStyleSheetObservableList(notationResource, modelStyleSheetsSource.getStylesheets(), (TransactionalEditingDomain) domain, modelStyleSheetsSource, StylesheetsPackage.Literals.MODEL_STYLE_SHEETS__STYLESHEETS);
- }
- return super.doGetObservable(propertyPath);
- }
-
- @Override
- public ILabelProvider getLabelProvider(String propertyPath) {
- if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) {
- return new CSSStyleSheetLabelProvider();
- }
- if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) {
- return new CSSStyleSheetLabelProvider();
- }
- return super.getLabelProvider(propertyPath);
- }
-
- @Override
- public IStaticContentProvider getContentProvider(String propertyPath) {
- if (propertyPath.equals(CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY)) {
- return new CSSStyleSheetContentProvider(source);
- }
- if (propertyPath.equals(CSSStyles.CSS_MODEL_STYLESHEETS_KEY)) {
- return new CSSStyleSheetContentProvider(source);
- }
- 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 (*)
- String elementName = source instanceof Diagram ? "*" : semanticElement.eClass().getName();
- 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);
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 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 + * Micka�l Adam (ALL4TEC) mickael.adam@all4tec.net - bug 429642 + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.properties.modelelement; + +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.viewers.ILabelProvider; +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.creation.StyleSheetFactory; +import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.DiagramStyleSheetObservableList; +import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.ModelStyleSheetObservableList; +import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetContentProvider; +import org.eclipse.papyrus.infra.gmfdiag.css.properties.provider.CSSStyleSheetLabelProvider; +import org.eclipse.papyrus.infra.gmfdiag.css.provider.CSSClassContentProvider; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsFactory; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage; +import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement; +import org.eclipse.papyrus.infra.properties.contexts.DataContextElement; +import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory; +import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory; +import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; + +public class CSSModelElement extends CustomStyleModelElement { + + public CSSModelElement(View source, DataContextElement context) { + super(source, context); + } + + public CSSModelElement(View source, EditingDomain domain, DataContextElement element) { + super(source, domain, element); + } + + @Override + public ReferenceValueFactory getValueFactory(String propertyPath) { + if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) { + return new StyleSheetFactory((View) this.source); + } + if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) { + return new StyleSheetFactory((View) this.source); + } + if (CSSStyles.CSS_GMF_CLASS_KEY.equals(propertyPath)) { + StringEditionFactory factory = new StringEditionFactory(); + factory.setContentProvider(getContentProvider(propertyPath)); + return factory; + } + return super.getValueFactory(propertyPath); + } + + @Override + public IObservable doGetObservable(String propertyPath) { + if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) { + if (source instanceof View) { + return new DiagramStyleSheetObservableList((View) source, domain, propertyPath); + } + } + if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) { + // Get the resource + final Resource notationResource = source.eResource(); + if (notationResource == null) { // May happen e.g. during deletion of the diagram + return null; + } + // Get the model styleSheet Object + Object modelStyleSheetObject = EcoreUtil.getObjectByType(notationResource.getContents(), StylesheetsPackage.Literals.MODEL_STYLE_SHEETS); + // The model styleSheet + final ModelStyleSheets modelStyleSheetsSource = modelStyleSheetObject instanceof ModelStyleSheets ? (ModelStyleSheets) modelStyleSheetObject : StylesheetsFactory.eINSTANCE.createModelStyleSheets(); + // If the modelStylesheet doesn't exist + + return new ModelStyleSheetObservableList(notationResource, modelStyleSheetsSource.getStylesheets(), (TransactionalEditingDomain) domain, modelStyleSheetsSource, StylesheetsPackage.Literals.MODEL_STYLE_SHEETS__STYLESHEETS); + } + return super.doGetObservable(propertyPath); + } + + @Override + public ILabelProvider getLabelProvider(String propertyPath) { + if (CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY.equals(propertyPath)) { + return new CSSStyleSheetLabelProvider(); + } + if (CSSStyles.CSS_MODEL_STYLESHEETS_KEY.equals(propertyPath)) { + return new CSSStyleSheetLabelProvider(); + } + return super.getLabelProvider(propertyPath); + } + + @Override + public IStaticContentProvider getContentProvider(String propertyPath) { + if (propertyPath.equals(CSSStyles.CSS_DIAGRAM_STYLESHEETS_KEY)) { + return new CSSStyleSheetContentProvider(source); + } + if (propertyPath.equals(CSSStyles.CSS_MODEL_STYLESHEETS_KEY)) { + return new CSSStyleSheetContentProvider(source); + } + 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 (*) + String elementName = source instanceof Diagram ? "*" : semanticElement.eClass().getName(); + 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); + } +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElementFactory.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElementFactory.java index b0b432daa46..21add7b604b 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElementFactory.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/modelelement/CSSModelElementFactory.java @@ -1,45 +1,45 @@ -/*****************************************************************************
- * Copyright (c) 2012, 2014 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 417409
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.css.properties.modelelement;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.Activator;
-import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement;
-import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory;
-import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
-
-
-public class CSSModelElementFactory extends CustomStyleModelElementFactory {
-
- @Override
- protected CustomStyleModelElement doCreateFromSource(Object sourceElement, DataContextElement context) {
- View view = NotationHelper.findView(sourceElement);
- if (view == null) {
- Activator.log.warn("The selected element cannot be resolved to a GMF View");
- return null;
- }
-
- EditingDomain domain = EMFHelper.resolveEditingDomain(view);
-
- if (domain == null) {
- return new CSSModelElement(view, context);
- } else {
- return new CSSModelElement(view, domain, context);
- }
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2012, 2014 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: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - bug 417409 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.properties.modelelement; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper; +import org.eclipse.papyrus.infra.gmfdiag.css.properties.Activator; +import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement; +import org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory; +import org.eclipse.papyrus.infra.properties.contexts.DataContextElement; + + +public class CSSModelElementFactory extends CustomStyleModelElementFactory { + + @Override + protected CustomStyleModelElement doCreateFromSource(Object sourceElement, DataContextElement context) { + View view = NotationHelper.findView(sourceElement); + if (view == null) { + Activator.log.warn("The selected element cannot be resolved to a GMF View"); + return null; + } + + EditingDomain domain = EMFHelper.resolveEditingDomain(view); + + if (domain == null) { + return new CSSModelElement(view, context); + } else { + return new CSSModelElement(view, domain, context); + } + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetContentProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetContentProvider.java index 6ec9d987cc0..67e8cacf2f5 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetContentProvider.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetContentProvider.java @@ -1,86 +1,86 @@ -/*****************************************************************************
- * 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.properties.provider;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage;
-import org.eclipse.papyrus.infra.ui.emf.providers.EMFContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
-
-
-public class CSSStyleSheetContentProvider extends EMFContentProvider {
-
- private EObject context;
-
- public CSSStyleSheetContentProvider(EObject sourceEObject) {
- super(sourceEObject, StylesheetsPackage.eINSTANCE.getModelStyleSheets_Stylesheets());
- this.context = sourceEObject;
- }
-
- /**
- * Returns the content provider associated to feature being edited
- *
- * @param editedEObject
- * The object being edited
- * @param feature
- * The object's feature being edited
- * @return
- * A content provider returning all the values valid for the given feature
- */
- @Override
- protected IStructuredContentProvider getSemanticProvider(EObject editedEObject, EStructuralFeature feature) {
-
- return new AbstractStaticContentProvider() {
-
- public Object[] getElements() {
- List<Object> result = new LinkedList<Object>();
- if (context == null || context.eResource() == null) {
- return new Object[0];
- }
- Resource contextResource = context.eResource();
- List<Resource> resources;
- if (contextResource.getResourceSet() == null) {
- resources = Collections.singletonList(contextResource);
- } else {
- resources = new ArrayList<Resource>(contextResource.getResourceSet().getResources());
- }
-
- for (Resource resource : resources) {
- for (Object object : resource.getContents()) {
- if (object instanceof ModelStyleSheets) {
- ModelStyleSheets styleSheets = (ModelStyleSheets) object;
- for (StyleSheet styleSheet : styleSheets.getStylesheets()) {
- result.add(styleSheet);
- }
- } else {
- if (object instanceof StyleSheet) {
- result.add(object);
- }
- }
- }
- }
- return result.toArray();
- }
- };
- }
-
-}
+/***************************************************************************** + * 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.properties.provider; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.ModelStyleSheets; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage; +import org.eclipse.papyrus.infra.ui.emf.providers.EMFContentProvider; +import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider; + + +public class CSSStyleSheetContentProvider extends EMFContentProvider { + + private EObject context; + + public CSSStyleSheetContentProvider(EObject sourceEObject) { + super(sourceEObject, StylesheetsPackage.eINSTANCE.getModelStyleSheets_Stylesheets()); + this.context = sourceEObject; + } + + /** + * Returns the content provider associated to feature being edited + * + * @param editedEObject + * The object being edited + * @param feature + * The object's feature being edited + * @return + * A content provider returning all the values valid for the given feature + */ + @Override + protected IStructuredContentProvider getSemanticProvider(EObject editedEObject, EStructuralFeature feature) { + + return new AbstractStaticContentProvider() { + + public Object[] getElements() { + List<Object> result = new LinkedList<Object>(); + if (context == null || context.eResource() == null) { + return new Object[0]; + } + Resource contextResource = context.eResource(); + List<Resource> resources; + if (contextResource.getResourceSet() == null) { + resources = Collections.singletonList(contextResource); + } else { + resources = new ArrayList<Resource>(contextResource.getResourceSet().getResources()); + } + + for (Resource resource : resources) { + for (Object object : resource.getContents()) { + if (object instanceof ModelStyleSheets) { + ModelStyleSheets styleSheets = (ModelStyleSheets) object; + for (StyleSheet styleSheet : styleSheets.getStylesheets()) { + result.add(styleSheet); + } + } else { + if (object instanceof StyleSheet) { + result.add(object); + } + } + } + } + return result.toArray(); + } + }; + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetLabelProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetLabelProvider.java index d32fe961370..ba69721e207 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetLabelProvider.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.properties/src/org/eclipse/papyrus/infra/gmfdiag/css/properties/provider/CSSStyleSheetLabelProvider.java @@ -1,34 +1,34 @@ -/*****************************************************************************
- * 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.properties.provider;
-
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet;
-import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
-import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
-
-
-public class CSSStyleSheetLabelProvider extends EMFLabelProvider {
-
- @Override
- public String getText(Object element) {
- if (element instanceof StyleSheetReference) {
- return ((StyleSheetReference) element).getPath();
- } else if (element instanceof EmbeddedStyleSheet) {
- EmbeddedStyleSheet styleSheet = (EmbeddedStyleSheet) element;
- if (styleSheet.getLabel() == null || "".equals(styleSheet.getLabel())) {
- return "EmbeddedStyleSheet";
- }
- return styleSheet.getLabel();
- }
- return super.getText(element);
- }
-}
+/***************************************************************************** + * 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.properties.provider; + +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference; +import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider; + + +public class CSSStyleSheetLabelProvider extends EMFLabelProvider { + + @Override + public String getText(Object element) { + if (element instanceof StyleSheetReference) { + return ((StyleSheetReference) element).getPath(); + } else if (element instanceof EmbeddedStyleSheet) { + EmbeddedStyleSheet styleSheet = (EmbeddedStyleSheet) element; + if (styleSheet.getLabel() == null || "".equals(styleSheet.getLabel())) { + return "EmbeddedStyleSheet"; + } + return styleSheet.getLabel(); + } + return super.getText(element); + } +} |