Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincent lorenzo2015-02-12 09:16:17 -0500
committerGerrit Code Review @ Eclipse.org2015-02-12 09:16:18 -0500
commit19da4f984562f280bb6bf5cbddb9e4aed62ecdd7 (patch)
tree4a100bbff89589d9a5542b4d4a9a527058ff5a16
parent625e76d2fe1234cd5528bd0664e1c6aa2531762b (diff)
parent7368bd7cc0fc1f7221cc2259849e29f6ca246591 (diff)
downloadorg.eclipse.papyrus-19da4f984562f280bb6bf5cbddb9e4aed62ecdd7.tar.gz
org.eclipse.papyrus-19da4f984562f280bb6bf5cbddb9e4aed62ecdd7.tar.xz
org.eclipse.papyrus-19da4f984562f280bb6bf5cbddb9e4aed62ecdd7.zip
Merge "459222: [Customization] bad stereotype property name on the right part of the property view https://bugs.eclipse.org/bugs/show_bug.cgi?id=459222" into streams/1.0-maintenance
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java510
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java540
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java272
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java232
4 files changed, 777 insertions, 777 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
index c00f9081c24..8422173c237 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
@@ -1,255 +1,255 @@
-/*****************************************************************************
- * Copyright (c) 2013 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 (camille.letavernier@cea.fr) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.widgets;
-
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
-import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
-import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
-import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
-import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * A Property Editor to display an instance of DataType
- * TODO: It could actually be used as a generic EObject property editor
- *
- * @author Camille Letavernier
- *
- */
-public class EObjectContentsEditor extends Composite {
-
- protected Composite contents;
-
- protected Composite buttonsBar;
-
- protected EReference reference;
-
- protected IObservableValue modelElementObservable;
-
- protected Button addButton;
-
- protected Button deleteButton;
-
- protected IChangeListener valueListener;
-
- protected Composite self;
-
- public EObjectContentsEditor(Composite parent, int style, EReference reference) {
- super(parent, style);
-
- setLayout(new FillLayout());
-
- self = new Group(this, SWT.NONE);
-
- ((Group) self).setText(reference.getName() + ": " + reference.getEType().getName());
- self.setLayout(new PropertiesLayout());
-
- buttonsBar = new Composite(self, SWT.NONE);
- buttonsBar.setLayout(new FillLayout());
- buttonsBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- createAddButton();
- createDeleteButton();
-
- updateButtonsBar();
-
- contents = new Composite(self, SWT.NONE);
- contents.setLayout(new PropertiesLayout());
- contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- this.reference = reference;
-
- valueListener = new IChangeListener() {
-
- public void handleChange(ChangeEvent event) {
- updateContents();
- }
- };
-
- parent.addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
- }
-
- public void setValue(IObservableValue observable) {
- if (this.modelElementObservable != null) {
- this.modelElementObservable.removeChangeListener(valueListener);
- }
-
- this.modelElementObservable = observable;
- this.modelElementObservable.addChangeListener(valueListener);
-
- updateContents();
- }
-
- @Override
- public void dispose() {
- if (this.modelElementObservable != null) {
- this.modelElementObservable.removeChangeListener(valueListener);
- }
- }
-
- protected void updateContents() {
- EObject dataTypeInstance = (EObject) modelElementObservable.getValue();
-
- for (Control child : contents.getChildren()) {
- child.dispose();
- }
-
- if (dataTypeInstance == null) {
- // Label label = new Label(contents, SWT.NONE);
- // label.setText("<<Unset>>");
- } else {
- EClass dataTypeDefinition = dataTypeInstance.eClass();
-
- ILabelProvider labelProvider;
- try {
- labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, dataTypeInstance).getLabelProvider();
- } catch (Exception ex) {
- Activator.log.error(ex);
- labelProvider = new UMLLabelProvider();
- }
-
- for (EStructuralFeature feature : dataTypeDefinition.getEAllStructuralFeatures()) {
- EStructuralFeatureEditor propertyEditor = new EStructuralFeatureEditor(contents, SWT.NONE);
-
- propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
- if (feature instanceof EReference) {
- propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
- }
-
- propertyEditor.setFeatureToEdit(feature, dataTypeInstance);
- }
- }
-
- updateButtonsBar();
-
- layout();
- }
-
- @Override
- public void layout() {
- contents.layout();
- self.layout();
- super.layout();
- getParent().layout();
- }
-
- protected void createAddButton() {
- addButton = new Button(buttonsBar, SWT.PUSH);
- addButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Add_12x12.gif"));
- addButton.setToolTipText("Create element");
-
- addButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- addAction();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- // Nothing
- }
- });
- }
-
- protected void addAction() {
- EClassifier classifier = reference.getEType();
- if (classifier instanceof EClass) {
- EClass classToInstantiate = (EClass) classifier;
- if (classToInstantiate.isAbstract()) {
- // TODO
- }
-
- EPackage ePackage = classToInstantiate.getEPackage();
- EObject value = ePackage.getEFactoryInstance().create(classToInstantiate);
-
- modelElementObservable.setValue(value);
- }
- }
-
- protected void createDeleteButton() {
- deleteButton = new Button(buttonsBar, SWT.PUSH);
- deleteButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Delete_12x12.gif"));
- deleteButton.setToolTipText("Unset value");
-
- deleteButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- deleteAction();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- //
- }
- });
- }
-
- protected void deleteAction() {
- modelElementObservable.setValue(null);
- }
-
- protected void updateButtonsBar() {
- deleteButton.setEnabled(modelElementObservable != null && modelElementObservable.getValue() != null);
- }
-
- protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject dataTypeInstance, EReference reference) {
- UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
- EClass type = reference.getEReferenceType();
-
- factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
- factory.setReferenceLabelProvider(new EMFLabelProvider());
-
- ITreeContentProvider contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
-
- EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container"));
-
- factory.setContainerContentProvider(provider);
- factory.setReferenceContentProvider(new FeatureContentProvider(type));
-
- return factory;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 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 (camille.letavernier@cea.fr) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
+import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.uml.properties.Activator;
+import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
+import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
+import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * A Property Editor to display an instance of DataType
+ * TODO: It could actually be used as a generic EObject property editor
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class EObjectContentsEditor extends Composite {
+
+ protected Composite contents;
+
+ protected Composite buttonsBar;
+
+ protected EReference reference;
+
+ protected IObservableValue modelElementObservable;
+
+ protected Button addButton;
+
+ protected Button deleteButton;
+
+ protected IChangeListener valueListener;
+
+ protected Composite self;
+
+ public EObjectContentsEditor(Composite parent, int style, EReference reference) {
+ super(parent, style);
+
+ setLayout(new FillLayout());
+
+ self = new Group(this, SWT.NONE);
+
+ ((Group) self).setText(reference.getName() + ": " + reference.getEType().getName());
+ self.setLayout(new PropertiesLayout());
+
+ buttonsBar = new Composite(self, SWT.NONE);
+ buttonsBar.setLayout(new FillLayout());
+ buttonsBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+ createAddButton();
+ createDeleteButton();
+
+ updateButtonsBar();
+
+ contents = new Composite(self, SWT.NONE);
+ contents.setLayout(new PropertiesLayout());
+ contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ this.reference = reference;
+
+ valueListener = new IChangeListener() {
+
+ public void handleChange(ChangeEvent event) {
+ updateContents();
+ }
+ };
+
+ parent.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
+ });
+ }
+
+ public void setValue(IObservableValue observable) {
+ if (this.modelElementObservable != null) {
+ this.modelElementObservable.removeChangeListener(valueListener);
+ }
+
+ this.modelElementObservable = observable;
+ this.modelElementObservable.addChangeListener(valueListener);
+
+ updateContents();
+ }
+
+ @Override
+ public void dispose() {
+ if (this.modelElementObservable != null) {
+ this.modelElementObservable.removeChangeListener(valueListener);
+ }
+ }
+
+ protected void updateContents() {
+ EObject dataTypeInstance = (EObject) modelElementObservable.getValue();
+
+ for (Control child : contents.getChildren()) {
+ child.dispose();
+ }
+
+ if (dataTypeInstance == null) {
+ // Label label = new Label(contents, SWT.NONE);
+ // label.setText("<<Unset>>");
+ } else {
+ EClass dataTypeDefinition = dataTypeInstance.eClass();
+
+ ILabelProvider labelProvider;
+ try {
+ labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, dataTypeInstance).getLabelProvider();
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ labelProvider = new UMLLabelProvider();
+ }
+
+ for (EStructuralFeature feature : dataTypeDefinition.getEAllStructuralFeatures()) {
+ EStructuralFeatureEditor propertyEditor = new EStructuralFeatureEditor(contents, SWT.NONE);
+
+ propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
+ if (feature instanceof EReference) {
+ propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
+ }
+
+ propertyEditor.setFeatureToEdit(feature.getName(), feature, dataTypeInstance);
+ }
+ }
+
+ updateButtonsBar();
+
+ layout();
+ }
+
+ @Override
+ public void layout() {
+ contents.layout();
+ self.layout();
+ super.layout();
+ getParent().layout();
+ }
+
+ protected void createAddButton() {
+ addButton = new Button(buttonsBar, SWT.PUSH);
+ addButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Add_12x12.gif"));
+ addButton.setToolTipText("Create element");
+
+ addButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ addAction();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing
+ }
+ });
+ }
+
+ protected void addAction() {
+ EClassifier classifier = reference.getEType();
+ if (classifier instanceof EClass) {
+ EClass classToInstantiate = (EClass) classifier;
+ if (classToInstantiate.isAbstract()) {
+ // TODO
+ }
+
+ EPackage ePackage = classToInstantiate.getEPackage();
+ EObject value = ePackage.getEFactoryInstance().create(classToInstantiate);
+
+ modelElementObservable.setValue(value);
+ }
+ }
+
+ protected void createDeleteButton() {
+ deleteButton = new Button(buttonsBar, SWT.PUSH);
+ deleteButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Delete_12x12.gif"));
+ deleteButton.setToolTipText("Unset value");
+
+ deleteButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ deleteAction();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //
+ }
+ });
+ }
+
+ protected void deleteAction() {
+ modelElementObservable.setValue(null);
+ }
+
+ protected void updateButtonsBar() {
+ deleteButton.setEnabled(modelElementObservable != null && modelElementObservable.getValue() != null);
+ }
+
+ protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject dataTypeInstance, EReference reference) {
+ UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
+ EClass type = reference.getEReferenceType();
+
+ factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
+ factory.setReferenceLabelProvider(new EMFLabelProvider());
+
+ ITreeContentProvider contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
+
+ EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container"));
+
+ factory.setContainerContentProvider(provider);
+ factory.setReferenceContentProvider(new FeatureContentProvider(type));
+
+ return factory;
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
index 65aa6742028..0da9550f3d8 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
@@ -1,270 +1,270 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 Atos, CEA, 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:
- * Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
- * Christian W. Damus (CEA) - bug 323802
- * Christian W. Damus (CEA) - bug 448139
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.widgets;
-
-import java.util.List;
-
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.core.databinding.observable.list.IListChangeListener;
-import org.eclipse.core.databinding.observable.list.ListChangeEvent;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFEnumeratorContentProvider;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
-import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor;
-import org.eclipse.papyrus.infra.widgets.editors.BooleanCombo;
-import org.eclipse.papyrus.infra.widgets.editors.DoubleEditor;
-import org.eclipse.papyrus.infra.widgets.editors.EnumCombo;
-import org.eclipse.papyrus.infra.widgets.editors.FloatEditor;
-import org.eclipse.papyrus.infra.widgets.editors.IntegerEditor;
-import org.eclipse.papyrus.infra.widgets.editors.LongEditor;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleIntegerEditor;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleStringEditor;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor;
-import org.eclipse.papyrus.infra.widgets.editors.ReferenceDialog;
-import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.papyrus.uml.tools.utils.DataTypeUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.PageBook;
-
-
-public class EStructuralFeatureEditor implements IValueChangeListener, IListChangeListener {
-
- protected PageBook pageBook;
-
- protected Composite currentPage;
-
- protected int style = 0;
-
- protected IStaticContentProvider contentProvider;
-
- protected ILabelProvider labelProvider;
-
- protected ReferenceValueFactory valueFactory;
-
- protected IChangeListener changeListener;
-
- public EStructuralFeatureEditor(Composite parent, int style) {
- this.style = style;
- pageBook = new PageBook(parent, style);
- currentPage = createEmptyPage();
- pageBook.showPage(currentPage);
- }
-
- public void setProviders(IStaticContentProvider contentProvider, ILabelProvider labelProvider) {
- this.contentProvider = contentProvider;
- this.labelProvider = labelProvider;
- }
-
- public void setValueFactory(ReferenceValueFactory valueFactory) {
- this.valueFactory = valueFactory;
- }
-
- public void setChangeListener(IChangeListener changeListener) {
- this.changeListener = changeListener;
- }
-
- protected Composite createEmptyPage() {
- return new Composite(pageBook, style);
- }
-
- public void setFeatureToEdit(EStructuralFeature feature, EObject element) {
- if (currentPage != null) {
- currentPage.dispose();
- currentPage = null;
- }
-
- if (feature instanceof EReference) {
- if (feature.isMany()) {
- MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, feature);
-
- editor.setProviders(contentProvider, labelProvider);
- editor.setFactory(valueFactory);
- currentPage = editor;
- } else {
- EClassifier featureType = feature.getEType();
- if (featureType instanceof EClass && DataTypeUtil.isDataTypeDefinition((EClass) featureType, element)) {
- EObjectContentsEditor editor = new EObjectContentsEditor(pageBook, style, (EReference) feature);
- editor.setValue(new PapyrusObservableValue(element, feature, EMFHelper.resolveEditingDomain(element)));
- currentPage = editor;
- } else {
- ReferenceDialog editor = new ReferenceDialog(pageBook, style);
- setValueEditorProperties(editor, element, feature);
-
- editor.setContentProvider(contentProvider);
- editor.setLabelProvider(labelProvider);
- editor.setValueFactory(valueFactory);
-
- editor.setDirectCreation(((EReference) feature).isContainment());
- currentPage = editor;
- }
- }
- }
-
- if (feature instanceof EAttribute) {
- EClassifier type = feature.getEType();
- if (type instanceof EEnum) {
- if (feature.isMany()) {
- MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, feature);
-
- editor.setProviders(contentProvider, labelProvider);
- editor.setFactory(valueFactory);
- currentPage = editor;
-
- } else {
- EnumCombo editor = new EnumCombo(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- editor.setContentProvider(new EMFEnumeratorContentProvider(feature));
- currentPage = editor;
- }
- } else if (type instanceof EDataType) {
- String instanceClassName = ((EDataType) type).getInstanceClassName();
- if ("java.lang.String".equalsIgnoreCase(instanceClassName) || "string".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- MultipleStringEditor editor = new MultipleStringEditor(pageBook, style, true);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, feature);
- currentPage = editor;
- } else {
- StringEditor editor = new StringEditor(pageBook, style | SWT.MULTI);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- } else if ("java.lang.Integer".equalsIgnoreCase(instanceClassName) || "integer".equalsIgnoreCase(instanceClassName) || "int".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- MultipleIntegerEditor editor = new MultipleIntegerEditor(pageBook, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, feature);
- currentPage = editor;
- } else {
- IntegerEditor editor = new IntegerEditor(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- } else if ("java.lang.Boolean".equals(instanceClassName) || "boolean".equalsIgnoreCase(instanceClassName) || "bool".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- // TODO widget not available
- } else {
- BooleanCombo editor = new BooleanCombo(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- } else if ("java.lang.Float".equals(instanceClassName) || "float".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- // TODO widget not available
- } else {
- FloatEditor editor = new FloatEditor(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- } else if ("java.lang.Double".equals(instanceClassName) || "double".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- // TODO widget not available
- } else {
- DoubleEditor editor = new DoubleEditor(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- } else if ("java.lang.Long".equals(instanceClassName) || "long".equalsIgnoreCase(instanceClassName)) {
- if (feature.isMany()) {
- // TODO widget not available
- } else {
- LongEditor editor = new LongEditor(pageBook, style);
- setValueEditorProperties(editor, element, feature);
- currentPage = editor;
- }
- }
- }
- }
-
- if (currentPage == null) {
- currentPage = createEmptyPage();
- }
-
- pageBook.showPage(currentPage);
- }
-
- protected void setValueEditorProperties(AbstractValueEditor editor, EObject stereotypeApplication, EStructuralFeature feature) {
- editor.setLabel(feature.getName());
-
- if (!isEditable(stereotypeApplication, feature)) {
- editor.setReadOnly(true);
- }
-
- PapyrusObservableValue observable = new PapyrusObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication));
-
- editor.setModelObservable(observable);
-
- observable.addValueChangeListener(this);
- }
-
- protected void setMultipleValueEditorProperties(MultipleValueEditor editor, List<?> initialList, EObject stereotypeApplication, EStructuralFeature feature) {
- editor.setLabel(feature.getName());
- editor.setUnique(feature.isUnique());
- editor.setOrdered(feature.isOrdered());
- editor.setUpperBound(feature.getUpperBound());
- if (feature instanceof EReference) {
- editor.setDirectCreation(((EReference) feature).isContainment());
- }
-
- if (!isEditable(stereotypeApplication, feature)) {
- editor.setReadOnly(true);
- }
-
- PapyrusObservableList observable = new PapyrusObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature);
-
- editor.setModelObservable(observable);
- editor.addCommitListener(observable);
-
- observable.addListChangeListener(this);
- }
-
- protected boolean isEditable(EObject object, EStructuralFeature feature) {
- return !feature.isDerived() && feature.isChangeable() && !EMFHelper.isReadOnly(object);
- }
-
- public void setLayoutData(GridData data) {
- pageBook.setLayoutData(data);
- }
-
- public void handleValueChange(ValueChangeEvent event) {
- if (changeListener != null) {
- changeListener.handleChange(new ChangeEvent(event.getObservable()));
- }
- }
-
- public void handleListChange(ListChangeEvent event) {
- if (changeListener != null) {
- changeListener.handleChange(new ChangeEvent(event.getObservable()));
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 Atos, CEA, 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:
+ * Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ * Christian W. Damus (CEA) - bug 448139
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import java.util.List;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.list.IListChangeListener;
+import org.eclipse.core.databinding.observable.list.ListChangeEvent;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
+import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFEnumeratorContentProvider;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor;
+import org.eclipse.papyrus.infra.widgets.editors.BooleanCombo;
+import org.eclipse.papyrus.infra.widgets.editors.DoubleEditor;
+import org.eclipse.papyrus.infra.widgets.editors.EnumCombo;
+import org.eclipse.papyrus.infra.widgets.editors.FloatEditor;
+import org.eclipse.papyrus.infra.widgets.editors.IntegerEditor;
+import org.eclipse.papyrus.infra.widgets.editors.LongEditor;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleIntegerEditor;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleStringEditor;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor;
+import org.eclipse.papyrus.infra.widgets.editors.ReferenceDialog;
+import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
+import org.eclipse.papyrus.uml.tools.utils.DataTypeUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.PageBook;
+
+
+public class EStructuralFeatureEditor implements IValueChangeListener, IListChangeListener {
+
+ protected PageBook pageBook;
+
+ protected Composite currentPage;
+
+ protected int style = 0;
+
+ protected IStaticContentProvider contentProvider;
+
+ protected ILabelProvider labelProvider;
+
+ protected ReferenceValueFactory valueFactory;
+
+ protected IChangeListener changeListener;
+
+ public EStructuralFeatureEditor(Composite parent, int style) {
+ this.style = style;
+ pageBook = new PageBook(parent, style);
+ currentPage = createEmptyPage();
+ pageBook.showPage(currentPage);
+ }
+
+ public void setProviders(IStaticContentProvider contentProvider, ILabelProvider labelProvider) {
+ this.contentProvider = contentProvider;
+ this.labelProvider = labelProvider;
+ }
+
+ public void setValueFactory(ReferenceValueFactory valueFactory) {
+ this.valueFactory = valueFactory;
+ }
+
+ public void setChangeListener(IChangeListener changeListener) {
+ this.changeListener = changeListener;
+ }
+
+ protected Composite createEmptyPage() {
+ return new Composite(pageBook, style);
+ }
+
+ public void setFeatureToEdit(String title, EStructuralFeature feature, EObject element) {
+ if (currentPage != null) {
+ currentPage.dispose();
+ currentPage = null;
+ }
+
+ if (feature instanceof EReference) {
+ if (feature.isMany()) {
+ MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
+ setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+
+ editor.setProviders(contentProvider, labelProvider);
+ editor.setFactory(valueFactory);
+ currentPage = editor;
+ } else {
+ EClassifier featureType = feature.getEType();
+ if (featureType instanceof EClass && DataTypeUtil.isDataTypeDefinition((EClass) featureType, element)) {
+ EObjectContentsEditor editor = new EObjectContentsEditor(pageBook, style, (EReference) feature);
+ editor.setValue(new PapyrusObservableValue(element, feature, EMFHelper.resolveEditingDomain(element)));
+ currentPage = editor;
+ } else {
+ ReferenceDialog editor = new ReferenceDialog(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+
+ editor.setContentProvider(contentProvider);
+ editor.setLabelProvider(labelProvider);
+ editor.setValueFactory(valueFactory);
+
+ editor.setDirectCreation(((EReference) feature).isContainment());
+ currentPage = editor;
+ }
+ }
+ }
+
+ if (feature instanceof EAttribute) {
+ EClassifier type = feature.getEType();
+ if (type instanceof EEnum) {
+ if (feature.isMany()) {
+ MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
+ setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+
+ editor.setProviders(contentProvider, labelProvider);
+ editor.setFactory(valueFactory);
+ currentPage = editor;
+
+ } else {
+ EnumCombo editor = new EnumCombo(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ editor.setContentProvider(new EMFEnumeratorContentProvider(feature));
+ currentPage = editor;
+ }
+ } else if (type instanceof EDataType) {
+ String instanceClassName = ((EDataType) type).getInstanceClassName();
+ if ("java.lang.String".equalsIgnoreCase(instanceClassName) || "string".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ MultipleStringEditor editor = new MultipleStringEditor(pageBook, style, true);
+ setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+ currentPage = editor;
+ } else {
+ StringEditor editor = new StringEditor(pageBook, style | SWT.MULTI);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ } else if ("java.lang.Integer".equalsIgnoreCase(instanceClassName) || "integer".equalsIgnoreCase(instanceClassName) || "int".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ MultipleIntegerEditor editor = new MultipleIntegerEditor(pageBook, style);
+ setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+ currentPage = editor;
+ } else {
+ IntegerEditor editor = new IntegerEditor(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ } else if ("java.lang.Boolean".equals(instanceClassName) || "boolean".equalsIgnoreCase(instanceClassName) || "bool".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ // TODO widget not available
+ } else {
+ BooleanCombo editor = new BooleanCombo(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ } else if ("java.lang.Float".equals(instanceClassName) || "float".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ // TODO widget not available
+ } else {
+ FloatEditor editor = new FloatEditor(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ } else if ("java.lang.Double".equals(instanceClassName) || "double".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ // TODO widget not available
+ } else {
+ DoubleEditor editor = new DoubleEditor(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ } else if ("java.lang.Long".equals(instanceClassName) || "long".equalsIgnoreCase(instanceClassName)) {
+ if (feature.isMany()) {
+ // TODO widget not available
+ } else {
+ LongEditor editor = new LongEditor(pageBook, style);
+ setValueEditorProperties(editor, element, title, feature);
+ currentPage = editor;
+ }
+ }
+ }
+ }
+
+ if (currentPage == null) {
+ currentPage = createEmptyPage();
+ }
+
+ pageBook.showPage(currentPage);
+ }
+
+ protected void setValueEditorProperties(AbstractValueEditor editor, EObject stereotypeApplication, String title, EStructuralFeature feature) {
+ editor.setLabel(title);
+
+ if (!isEditable(stereotypeApplication, feature)) {
+ editor.setReadOnly(true);
+ }
+
+ PapyrusObservableValue observable = new PapyrusObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication));
+
+ editor.setModelObservable(observable);
+
+ observable.addValueChangeListener(this);
+ }
+
+ protected void setMultipleValueEditorProperties(MultipleValueEditor editor, List<?> initialList, EObject stereotypeApplication, String title, EStructuralFeature feature) {
+ editor.setLabel(title);
+ editor.setUnique(feature.isUnique());
+ editor.setOrdered(feature.isOrdered());
+ editor.setUpperBound(feature.getUpperBound());
+ if (feature instanceof EReference) {
+ editor.setDirectCreation(((EReference) feature).isContainment());
+ }
+
+ if (!isEditable(stereotypeApplication, feature)) {
+ editor.setReadOnly(true);
+ }
+
+ PapyrusObservableList observable = new PapyrusObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature);
+
+ editor.setModelObservable(observable);
+ editor.addCommitListener(observable);
+
+ observable.addListChangeListener(this);
+ }
+
+ protected boolean isEditable(EObject object, EStructuralFeature feature) {
+ return !feature.isDerived() && feature.isChangeable() && !EMFHelper.isReadOnly(object);
+ }
+
+ public void setLayoutData(GridData data) {
+ pageBook.setLayoutData(data);
+ }
+
+ public void handleValueChange(ValueChangeEvent event) {
+ if (changeListener != null) {
+ changeListener.handleChange(new ChangeEvent(event.getObservable()));
+ }
+ }
+
+ public void handleListChange(ListChangeEvent event) {
+ if (changeListener != null) {
+ changeListener.handleChange(new ChangeEvent(event.getObservable()));
+ }
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
index 62e7f8690a1..7c93a929877 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
@@ -1,136 +1,136 @@
-/*****************************************************************************
- * Copyright (c) 2013 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 (camille.letavernier@cea.fr) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.widgets;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
-import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
-import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
-import org.eclipse.papyrus.views.properties.modelelement.DataSource;
-import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
-import org.eclipse.papyrus.views.properties.widgets.AbstractPropertyEditor;
-import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A Property Editor to display an instance of DataType
- * TODO: It could actually be used as a generic EObject property editor
- *
- * @author Camille Letavernier
- *
- */
-public class GenericUMLDatatypeEditor extends AbstractPropertyEditor {
-
- protected Composite self;
-
- public GenericUMLDatatypeEditor(Composite parent, int style) {
- super();
- self = new Composite(parent, SWT.NONE);
- self.setLayout(new PropertiesLayout(false));
- }
-
- @Override
- public void setProperty(String path) {
- this.propertyPath = path;
- // Do not check input, to avoid calling doBinding() twice
- }
-
- /**
- * This widget is used to edit a full EObject. It does not need a property, nor a ModelElement.
- *
- * It retrieves all the EStructuralFeatures reflexively
- */
- @Override
- protected void checkInput() {
- if (input != null) {
- try {
- doBinding();
- } catch (Exception ex) {
- // TODO : Handle the exception here. Display something ?
- Activator.log.error(ex);
- }
- }
- }
-
- /**
- * This widget is used to edit a full object. It does not need a property.
- */
- @Override
- protected void doBinding() {
- DataSource input = getInput();
- IStructuredSelection selection = input.getSelection();
- if (selection.isEmpty()) {
- return;
- }
-
- Object element = selection.getFirstElement();
-
- if (element instanceof EObject) {
- EObject dataTypeInstance = ((EObject) element);
- EClass dataTypeDefinition = dataTypeInstance.eClass();
-
- ILabelProvider labelProvider;
- try {
- labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, dataTypeInstance).getLabelProvider();
- } catch (Exception ex) {
- Activator.log.error(ex);
- labelProvider = new UMLLabelProvider();
- }
-
- for (EStructuralFeature feature : dataTypeDefinition.getEAllStructuralFeatures()) {
- EStructuralFeatureEditor propertyEditor = new EStructuralFeatureEditor(self, SWT.NONE);
-
- propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
- if (feature instanceof EReference) {
- propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
- }
-
- propertyEditor.setFeatureToEdit(feature, dataTypeInstance);
- }
- }
- }
-
- protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject dataTypeInstance, EReference reference) {
- UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
- EClass type = reference.getEReferenceType();
-
- factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
- factory.setReferenceLabelProvider(new EMFLabelProvider());
-
- ITreeContentProvider contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
-
- EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container"));
-
- factory.setContainerContentProvider(provider);
- factory.setReferenceContentProvider(new FeatureContentProvider(type));
-
- return factory;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 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 (camille.letavernier@cea.fr) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
+import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.uml.properties.Activator;
+import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
+import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.papyrus.views.properties.modelelement.DataSource;
+import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
+import org.eclipse.papyrus.views.properties.widgets.AbstractPropertyEditor;
+import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A Property Editor to display an instance of DataType
+ * TODO: It could actually be used as a generic EObject property editor
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class GenericUMLDatatypeEditor extends AbstractPropertyEditor {
+
+ protected Composite self;
+
+ public GenericUMLDatatypeEditor(Composite parent, int style) {
+ super();
+ self = new Composite(parent, SWT.NONE);
+ self.setLayout(new PropertiesLayout(false));
+ }
+
+ @Override
+ public void setProperty(String path) {
+ this.propertyPath = path;
+ // Do not check input, to avoid calling doBinding() twice
+ }
+
+ /**
+ * This widget is used to edit a full EObject. It does not need a property, nor a ModelElement.
+ *
+ * It retrieves all the EStructuralFeatures reflexively
+ */
+ @Override
+ protected void checkInput() {
+ if (input != null) {
+ try {
+ doBinding();
+ } catch (Exception ex) {
+ // TODO : Handle the exception here. Display something ?
+ Activator.log.error(ex);
+ }
+ }
+ }
+
+ /**
+ * This widget is used to edit a full object. It does not need a property.
+ */
+ @Override
+ protected void doBinding() {
+ DataSource input = getInput();
+ IStructuredSelection selection = input.getSelection();
+ if (selection.isEmpty()) {
+ return;
+ }
+
+ Object element = selection.getFirstElement();
+
+ if (element instanceof EObject) {
+ EObject dataTypeInstance = ((EObject) element);
+ EClass dataTypeDefinition = dataTypeInstance.eClass();
+
+ ILabelProvider labelProvider;
+ try {
+ labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, dataTypeInstance).getLabelProvider();
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ labelProvider = new UMLLabelProvider();
+ }
+
+ for (EStructuralFeature feature : dataTypeDefinition.getEAllStructuralFeatures()) {
+ EStructuralFeatureEditor propertyEditor = new EStructuralFeatureEditor(self, SWT.NONE);
+
+ propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
+ if (feature instanceof EReference) {
+ propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
+ }
+
+ propertyEditor.setFeatureToEdit(feature.getName(), feature, dataTypeInstance);
+ }
+ }
+ }
+
+ protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject dataTypeInstance, EReference reference) {
+ UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
+ EClass type = reference.getEReferenceType();
+
+ factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
+ factory.setReferenceLabelProvider(new EMFLabelProvider());
+
+ ITreeContentProvider contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
+
+ EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container"));
+
+ factory.setContainerContentProvider(provider);
+ factory.setReferenceContentProvider(new FeatureContentProvider(type));
+
+ return factory;
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
index ddb91b37e63..56181142c05 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
@@ -1,116 +1,116 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 Atos, CEA, 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:
- * Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
- * Christian W. Damus (CEA) - bug 448139
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.widgets;
-
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
-import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
-import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
-import org.eclipse.papyrus.uml.properties.profile.ui.compositeforview.AppliedStereotypeCompositeWithView;
-import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
-import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.uml2.uml.Stereotype;
-
-public class StereotypePropertyEditor implements ISelectionChangedListener, IChangeListener {
-
- protected EStructuralFeatureEditor eStructuralFeatureEditor;
-
- protected AppliedStereotypeCompositeWithView stereotypeComposite;
-
- protected int style = 0;
-
- public StereotypePropertyEditor(Composite parent, int style, AppliedStereotypeCompositeWithView stereotypeComposite) {
- this.stereotypeComposite = stereotypeComposite;
- eStructuralFeatureEditor = new EStructuralFeatureEditor(parent, style);
- eStructuralFeatureEditor.setChangeListener(this);
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- if (event != null) {
- IStructuredSelection structSelection = (IStructuredSelection) event.getSelection();
- Object selection = structSelection.getFirstElement();
-
- if (selection instanceof AppliedStereotypePropertyTreeObject) {
- AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject) selection;
-
- EObject stereotypeApplication = pTO.getStereotypeApplication();
- EStructuralFeature feature = pTO.getFeature();
- Stereotype stereotype = pTO.getStereotype();
-
- ILabelProvider labelProvider;
- try {
- labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, stereotypeApplication).getLabelProvider();
- } catch (Exception ex) {
- labelProvider = new UMLLabelProvider();
- }
-
- eStructuralFeatureEditor.setProviders(new UMLContentProvider(stereotypeApplication, feature, stereotype), labelProvider);
- if (feature instanceof EReference) {
- eStructuralFeatureEditor.setValueFactory(getUMLPropertyEditorFactory(stereotypeApplication, (EReference) feature));
- }
-
- eStructuralFeatureEditor.setFeatureToEdit(feature, stereotypeApplication);
- } else {
- eStructuralFeatureEditor.setFeatureToEdit(null, null);
- }
- }
- }
-
- protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject stereotypeApplication, EReference reference) {
- UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
- EClass type = reference.getEReferenceType();
-
- factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
- factory.setReferenceLabelProvider(new EMFLabelProvider());
-
- ITreeContentProvider contentProvider = new UMLContainerContentProvider(stereotypeApplication, reference);
-
- EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, stereotypeApplication.eResource().getResourceSet(), HistoryUtil.getHistoryID(stereotypeApplication, reference, "container"));
-
- factory.setContainerContentProvider(provider);
- factory.setReferenceContentProvider(new FeatureContentProvider(type));
-
- return factory;
- }
-
- public void setLayoutData(GridData data) {
- eStructuralFeatureEditor.setLayoutData(data);
- }
-
- public void handleChange(ChangeEvent event) {
- if (!stereotypeComposite.isDisposed()) {
- stereotypeComposite.refreshTreeViewer();
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 Atos, CEA, 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:
+ * Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 448139
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
+import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
+import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
+import org.eclipse.papyrus.uml.properties.profile.ui.compositeforview.AppliedStereotypeCompositeWithView;
+import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.uml2.uml.Stereotype;
+
+public class StereotypePropertyEditor implements ISelectionChangedListener, IChangeListener {
+
+ protected EStructuralFeatureEditor eStructuralFeatureEditor;
+
+ protected AppliedStereotypeCompositeWithView stereotypeComposite;
+
+ protected int style = 0;
+
+ public StereotypePropertyEditor(Composite parent, int style, AppliedStereotypeCompositeWithView stereotypeComposite) {
+ this.stereotypeComposite = stereotypeComposite;
+ eStructuralFeatureEditor = new EStructuralFeatureEditor(parent, style);
+ eStructuralFeatureEditor.setChangeListener(this);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (event != null) {
+ IStructuredSelection structSelection = (IStructuredSelection) event.getSelection();
+ Object selection = structSelection.getFirstElement();
+
+ if (selection instanceof AppliedStereotypePropertyTreeObject) {
+ AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject) selection;
+
+ EObject stereotypeApplication = pTO.getStereotypeApplication();
+ EStructuralFeature feature = pTO.getFeature();
+ Stereotype stereotype = pTO.getStereotype();
+
+ ILabelProvider labelProvider;
+ try {
+ labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, stereotypeApplication).getLabelProvider();
+ } catch (Exception ex) {
+ labelProvider = new UMLLabelProvider();
+ }
+
+ eStructuralFeatureEditor.setProviders(new UMLContentProvider(stereotypeApplication, feature, stereotype), labelProvider);
+ if (feature instanceof EReference) {
+ eStructuralFeatureEditor.setValueFactory(getUMLPropertyEditorFactory(stereotypeApplication, (EReference) feature));
+ }
+
+ eStructuralFeatureEditor.setFeatureToEdit(pTO.getProperty().getName(), feature, stereotypeApplication);
+ } else {
+ eStructuralFeatureEditor.setFeatureToEdit(null, null, null);
+ }
+ }
+ }
+
+ protected UMLPropertyEditorFactory getUMLPropertyEditorFactory(EObject stereotypeApplication, EReference reference) {
+ UMLPropertyEditorFactory factory = new UMLPropertyEditorFactory(reference);
+ EClass type = reference.getEReferenceType();
+
+ factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
+ factory.setReferenceLabelProvider(new EMFLabelProvider());
+
+ ITreeContentProvider contentProvider = new UMLContainerContentProvider(stereotypeApplication, reference);
+
+ EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, stereotypeApplication.eResource().getResourceSet(), HistoryUtil.getHistoryID(stereotypeApplication, reference, "container"));
+
+ factory.setContainerContentProvider(provider);
+ factory.setReferenceContentProvider(new FeatureContentProvider(type));
+
+ return factory;
+ }
+
+ public void setLayoutData(GridData data) {
+ eStructuralFeatureEditor.setLayoutData(data);
+ }
+
+ public void handleChange(ChangeEvent event) {
+ if (!stereotypeComposite.isDisposed()) {
+ stereotypeComposite.refreshTreeViewer();
+ }
+ }
+}

Back to the top