Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-12-01 09:16:49 +0000
committercletavernie2011-12-01 09:16:49 +0000
commita38b8e70fe810d2a11fa30b9be98017ab342ed28 (patch)
treeb8ca7564e4f3385db54b35b3607f02b1fe5930c6
parentea39f8e808d02e44d836fbd7fe6a246eea0114e8 (diff)
downloadorg.eclipse.papyrus-a38b8e70fe810d2a11fa30b9be98017ab342ed28.tar.gz
org.eclipse.papyrus-a38b8e70fe810d2a11fa30b9be98017ab342ed28.tar.xz
org.eclipse.papyrus-a38b8e70fe810d2a11fa30b9be98017ab342ed28.zip
365281: [Property view] The constraints should be able to handle a global selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=365281 365282: [UML - Property View] Edit the provided and required interfaces from the property view https://bugs.eclipse.org/bugs/show_bug.cgi?id=365282
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/AbstractConstraint.java47
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/Constraint.java11
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/modelelement/DataSourceFactory.java6
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/runtime/DefaultConstraintEngine.java24
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/MultiReferenceEditorWithPropertyView.java7
-rw-r--r--plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/xwt/XWTSection.java42
-rw-r--r--plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/util/FileUtil.java34
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/constraints/HasStereotypeConstraint.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/PapyrusObservableList.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/ProvidedInterfaceObservableList.java78
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/RequiredInterfaceObservableList.java76
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java37
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/util/UMLUtil.java41
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/TypeReferenceDialog.java9
-rw-r--r--plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/UMLReferenceDialog.java9
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/ServiceEditFilteredUMLContentProvider.java12
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/util/HistoryUtil.java36
19 files changed, 402 insertions, 82 deletions
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/AbstractConstraint.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/AbstractConstraint.java
index 5b6616c140b..0d650fdbb5a 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/AbstractConstraint.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/AbstractConstraint.java
@@ -11,6 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.properties.constraints;
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.properties.Activator;
import org.eclipse.papyrus.properties.contexts.ConfigProperty;
import org.eclipse.papyrus.properties.contexts.ConstraintDescriptor;
@@ -181,4 +184,48 @@ public abstract class AbstractConstraint implements Constraint {
//Implementors may override
}
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation matches a selection iff the constraint matches
+ * each object of the selection.
+ */
+ public boolean match(IStructuredSelection selection) {
+ if(selection.isEmpty()) {
+ return false;
+ }
+
+
+ int elementMultiplicity;
+
+ if(display instanceof View) {
+ elementMultiplicity = ((View)display).getElementMultiplicity();
+ } else {
+ //FIXME : The dynamic sections were initially not supposed to be used on multi-selection
+ //Thus, they don't have an elementMultiplicity criteria.
+ elementMultiplicity = -1; //Arbitrary number of elements for Sections
+ }
+
+ int selectionSize = selection.size();
+ if(elementMultiplicity == 1) {
+ if(selectionSize == 1) {
+ if(match(selection.getFirstElement())) {
+ return true;
+ }
+ }
+ } else if(elementMultiplicity == selectionSize || elementMultiplicity < 0) {
+ Iterator<?> selectionIterator = selection.iterator();
+ while(selectionIterator.hasNext()) {
+ Object selectedItem = selectionIterator.next();
+ if(!match(selectedItem)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
}
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/Constraint.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/Constraint.java
index f8e337a2cb7..f1cd9ca4ed9 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/Constraint.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/constraints/Constraint.java
@@ -11,6 +11,7 @@
*****************************************************************************/
package org.eclipse.papyrus.properties.constraints;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.properties.contexts.ConstraintDescriptor;
import org.eclipse.papyrus.properties.contexts.View;
@@ -47,6 +48,16 @@ public interface Constraint {
public boolean match(Object selection);
/**
+ * Tests if this constraint matches the given selection
+ *
+ * @param selection
+ * The selection to be tested against this constraint
+ * @return
+ * True if this constraint matches the given selection
+ */
+ public boolean match(IStructuredSelection selection);
+
+ /**
* Returns the view associated to this constraint, or null if the constraint is associated to another
* kind of display unit (e.g. a section)
*
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/modelelement/DataSourceFactory.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/modelelement/DataSourceFactory.java
index 778463423be..74256ba8310 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/modelelement/DataSourceFactory.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/modelelement/DataSourceFactory.java
@@ -30,9 +30,6 @@ import org.eclipse.papyrus.widgets.Activator;
*
* @author Camille Letavernier
*/
-// FIXME : sources is never cleared (Memory leak)
-// TODO : The DataSource probably don't need a factory. Most methods are related
-// to ModelElement.
public class DataSourceFactory {
/**
@@ -236,5 +233,8 @@ public class DataSourceFactory {
*
* The cache is cleaned when the sections are disposed.
*/
+ //TODO : More than one view can be displayed at the same time. The cache should only
+ //rely on a selection ; not on a selection-view pair.
+ //We may use a (ISelection, Context) key : the DataSource must be associated to a single context
private Map<SelectionEntry, DataSource> sources = new HashMap<SelectionEntry, DataSource>();
}
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/runtime/DefaultConstraintEngine.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/runtime/DefaultConstraintEngine.java
index c878ba5e530..6d18619ba74 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/runtime/DefaultConstraintEngine.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/runtime/DefaultConstraintEngine.java
@@ -13,7 +13,6 @@ package org.eclipse.papyrus.properties.runtime;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -75,27 +74,8 @@ public class DefaultConstraintEngine implements ConstraintEngine {
}
for(Constraint c : constraints) {
- int elementMultiplicity = c.getView().getElementMultiplicity();
- int selectionSize = selection.size();
- if(elementMultiplicity == 1) {
- if(selectionSize == 1) {
- if(c.match(selection.getFirstElement())) {
- matchedConstraints.add(c);
- }
- }
- } else if(elementMultiplicity == selectionSize || elementMultiplicity < 0) {
- boolean allMatch = true;
- Iterator<?> selectionIterator = selection.iterator();
- while(selectionIterator.hasNext()) {
- Object selectedItem = selectionIterator.next();
- if(!c.match(selectedItem)) {
- allMatch = false;
- break;
- }
- }
- if(allMatch) {
- matchedConstraints.add(c);
- }
+ if(c.match(selection)) {
+ matchedConstraints.add(c);
}
}
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/MultiReferenceEditorWithPropertyView.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/MultiReferenceEditorWithPropertyView.java
index e664556ef24..701b1d9dcd2 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/MultiReferenceEditorWithPropertyView.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/widgets/MultiReferenceEditorWithPropertyView.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.properties.contexts.View;
import org.eclipse.papyrus.properties.runtime.ConfigurationManager;
import org.eclipse.papyrus.properties.runtime.EmbeddedDisplayEngine;
@@ -100,7 +101,9 @@ public class MultiReferenceEditorWithPropertyView extends AbstractListEditor imp
@Override
public void setModelObservable(IObservableList modelObservable) {
multiReferenceEditor.setModelObservable(modelObservable);
- //TODO : Set the initial selection (first element) to the editor
+ if(!modelObservable.isEmpty()) {
+ multiReferenceEditor.getViewer().setSelection(new StructuredSelection(modelObservable.get(0)));
+ }
}
@Override
@@ -122,7 +125,7 @@ public class MultiReferenceEditorWithPropertyView extends AbstractListEditor imp
getParent().layout(); //This one works in the embedded editor
// In the Eclipse Tabbed Property View, we need to go this far...
- // getParent().getParent().getParent().getParent().layout();
+ getParent().getParent().getParent().getParent().layout();
}
public void setFactory(ReferenceValueFactory valueFactory) {
diff --git a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/xwt/XWTSection.java b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/xwt/XWTSection.java
index 0e70d0e0209..4c571a00f4e 100644
--- a/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/xwt/XWTSection.java
+++ b/plugins/core/org.eclipse.papyrus.properties/src/org/eclipse/papyrus/properties/xwt/XWTSection.java
@@ -11,7 +11,8 @@
*****************************************************************************/
package org.eclipse.papyrus.properties.xwt;
-import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
@@ -53,6 +54,8 @@ public class XWTSection extends AbstractPropertySection implements IChangeListen
private DisplayEngine display;
+ private Set<Constraint> constraints;
+
/**
* Constructor.
*
@@ -166,38 +169,35 @@ public class XWTSection extends AbstractPropertySection implements IChangeListen
* True if the section should be displayed
*/
protected boolean isApplied() {
- if(section.getConstraints().isEmpty()) {
+ if(getConstraints().isEmpty()) {
return true;
}
ISelection selection = getSelection();
- //Return true only if at least one constraint matches all elements
+ //Return true only if at least one constraint matches the selection
- //Constraint loop
- boolean oneConstraintMatch = false;
- for(ConstraintDescriptor constraintDescriptor : section.getConstraints()) {
- Constraint constraint = ConstraintFactory.getInstance().createFromModel(constraintDescriptor);
+ for(Constraint constraint : getConstraints()) {
+ if(constraint.match((IStructuredSelection)selection)) {
+ return true;
+ }
+ }
- Iterator<?> it = ((IStructuredSelection)selection).iterator();
+ return false;
+ }
- //Selection loop
- boolean allObjectsMatch = true;
- while(it.hasNext()) {
- Object element = it.next();
- if(! constraint.match(element)) {
- allObjectsMatch = false;
- break;
+ protected Set<Constraint> getConstraints() {
+ if(constraints == null) {
+ constraints = new HashSet<Constraint>();
+ for(ConstraintDescriptor constraintDescriptor : section.getConstraints()) {
+ Constraint constraint = ConstraintFactory.getInstance().createFromModel(constraintDescriptor);
+ if(constraint != null) {
+ constraints.add(constraint);
}
}
-
- if (allObjectsMatch){
- oneConstraintMatch = true;
- break;
- }
}
- return oneConstraintMatch;
+ return constraints;
}
@Override
diff --git a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/util/FileUtil.java b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/util/FileUtil.java
index 3ee8b00b4a5..73549581b72 100644
--- a/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/util/FileUtil.java
+++ b/plugins/core/org.eclipse.papyrus.widgets/src/org/eclipse/papyrus/widgets/util/FileUtil.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2011 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
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.papyrus.widgets.Activator;
-import org.eclipse.papyrus.widgets.editors.StringFileSelector;
/**
* A helper class for resolving files and path, either in the workspace or
@@ -30,6 +29,14 @@ import org.eclipse.papyrus.widgets.editors.StringFileSelector;
*/
public class FileUtil {
+ /**
+ * Returns the path to the IFile. If absolute is true, returns the path
+ * from the FileSystem. Otherwise, returns the path from the workspace.
+ *
+ * @param file
+ * @param absolute
+ * @return
+ */
public static String getPath(IFile file, boolean absolute) {
if(absolute) {
return file.getLocation().toString();
@@ -37,6 +44,14 @@ public class FileUtil {
return file.getFullPath().toString();
}
+ /**
+ * Returns the IFile (Workspace file) from the given location.
+ * The location may be either absolute (From the FileSystem) or
+ * relative to the workspace root.
+ *
+ * @param location
+ * @return
+ */
public static IFile getIFile(String location) {
//Search the file in the workspace
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
@@ -56,6 +71,14 @@ public class FileUtil {
return currentFile;
}
+ /**
+ * Returns the Java File from the given location.
+ * The location may be either absolute (From the FileSystem) or
+ * relative to the workspace root.
+ *
+ * @param location
+ * @return
+ */
public static File getFile(String location) {
IFile iFile = getIFile(location);
if(iFile == null || !iFile.exists()) {
@@ -65,6 +88,13 @@ public class FileUtil {
return new File(iFile.getLocationURI());
}
+ /**
+ * Returns the Java File from the given location.
+ * The location is relative to the workspace root.
+ *
+ * @param location
+ * @return
+ */
public static File getWorkspaceFile(String location) {
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
IPath path = new Path(location);
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.properties.uml/META-INF/MANIFEST.MF
index abf7c558337..5567ffa9207 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui;bundle-version="3.6.1",
org.eclipse.papyrus.profile;bundle-version="0.8.0",
org.eclipse.papyrus.uml.modelexplorer.widgets;bundle-version="0.8.0",
- org.eclipse.emf.facet.infra.query.core;bundle-version="0.1.0"
+ org.eclipse.emf.facet.infra.query.core;bundle-version="0.1.0",
+ org.eclipse.papyrus.uml.service.types;bundle-version="0.8.2"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Export-Package: org.eclipse.papyrus.properties.uml.constraints,
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/constraints/HasStereotypeConstraint.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/constraints/HasStereotypeConstraint.java
index a81214fa212..f69e5cc3905 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/constraints/HasStereotypeConstraint.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/constraints/HasStereotypeConstraint.java
@@ -59,7 +59,11 @@ public class HasStereotypeConstraint extends AbstractConstraint {
HasStereotypeConstraint stereotypeConstraint = (HasStereotypeConstraint)constraint;
if(!stereotypeName.equals(stereotypeConstraint.stereotypeName)) {
Stereotype thisStereotype = umlElement.getApplicableStereotype(stereotypeName);
- Stereotype otherStereotype = umlElement.getApplicableStereotype(stereotypeConstraint.stereotypeName);
+
+ //The otherStereotype can match the constraint without being applicable (e.g. abstract stereotype...)
+ //We can't rely on "getApplicableStereotype"
+ Stereotype otherStereotype = UMLUtil.findStereotype(umlElement, stereotypeConstraint.stereotypeName);
+ //Stereotype otherStereotype = umlElement.getApplicableStereotype(stereotypeConstraint.stereotypeName);
if(UMLUtil.getAllSuperStereotypes(thisStereotype).contains(otherStereotype)) {
overrides = true;
}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/PapyrusObservableList.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/PapyrusObservableList.java
index f005cbdda38..dfec7aae658 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/PapyrusObservableList.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/PapyrusObservableList.java
@@ -29,7 +29,6 @@ import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.properties.databinding.EMFObservableList;
import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.service.edit.service.IElementEditService;
-import org.eclipse.papyrus.widgets.editors.ICommitListener;
/**
* An ObservableList used to edit collections of EObjects through
@@ -39,7 +38,7 @@ import org.eclipse.papyrus.widgets.editors.ICommitListener;
*
*/
@SuppressWarnings("unchecked")
-public class PapyrusObservableList extends EMFObservableList implements ICommitListener {
+public class PapyrusObservableList extends EMFObservableList {
/**
*
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/ProvidedInterfaceObservableList.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/ProvidedInterfaceObservableList.java
new file mode 100644
index 00000000000..cb928a9191e
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/ProvidedInterfaceObservableList.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.properties.uml.databinding;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * An IObservableList to edit the UML Derived feature {@link Port#getProvideds()}
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class ProvidedInterfaceObservableList extends PapyrusObservableList {
+
+ protected Port port;
+
+ public ProvidedInterfaceObservableList(Port source, EditingDomain domain) {
+ super(EMFProperties.list(UMLPackage.eINSTANCE.getPort_Provided()).observe(source), domain, source, UMLPackage.eINSTANCE.getPort_Provided());
+ this.port = source;
+ }
+
+ @Override
+ protected Command getRemoveCommand(Object value) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getRemoveAllCommand(Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddCommand(int index, Object value) {
+ if(!(value instanceof Interface)) {
+ throw new IllegalArgumentException("The value must be an Interface"); //$NON-NLS-1$
+ }
+ Interface providedInterface = (Interface)value;
+
+ //Pseudo code
+ //Use a command
+ //Use the Papyrus UML Layer
+ //InterfaceRealization realization = createInterfaceRealization(providedInterface);
+ //((org.eclipse.uml2.uml.Class)port.getType()).getInterfaceRealizations().add(realization);
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddCommand(Object value) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddAllCommand(Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddAllCommand(int index, Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/RequiredInterfaceObservableList.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/RequiredInterfaceObservableList.java
new file mode 100644
index 00000000000..9ba8df2ffae
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/databinding/RequiredInterfaceObservableList.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.properties.uml.databinding;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * An IObservableList to edit the UML Derived feature {@link Port#getRequireds()}
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class RequiredInterfaceObservableList extends PapyrusObservableList {
+
+ protected Port port;
+
+ public RequiredInterfaceObservableList(Port source, EditingDomain domain) {
+ super(EMFProperties.list(UMLPackage.eINSTANCE.getPort_Required()).observe(source), domain, source, UMLPackage.eINSTANCE.getPort_Required());
+ this.port = source;
+ }
+
+ @Override
+ protected Command getRemoveCommand(Object value) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getRemoveAllCommand(Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddCommand(int index, Object value) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ protected Interface getRequiredInterface(Object value) {
+ if(!(value instanceof Interface)) {
+ throw new IllegalArgumentException("The value must be an Interface"); //$NON-NLS-1$
+ }
+ Interface requiredInterface = (Interface)value;
+ return requiredInterface;
+ }
+
+ @Override
+ protected Command getAddCommand(Object value) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddAllCommand(Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+ @Override
+ protected Command getAddAllCommand(int index, Collection<?> values) {
+ throw new UnsupportedOperationException("TODO"); //TODO
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
index e640b418c4b..2d225626172 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/modelelement/UMLModelElement.java
@@ -43,11 +43,15 @@ import org.eclipse.papyrus.properties.uml.creation.UMLPropertyEditorFactory;
import org.eclipse.papyrus.properties.uml.databinding.ExtensionRequiredObservableValue;
import org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableList;
import org.eclipse.papyrus.properties.uml.databinding.PapyrusObservableValue;
+import org.eclipse.papyrus.properties.uml.databinding.ProvidedInterfaceObservableList;
+import org.eclipse.papyrus.properties.uml.databinding.RequiredInterfaceObservableList;
import org.eclipse.papyrus.properties.uml.databinding.SignatureObservableValue;
import org.eclipse.papyrus.properties.uml.providers.InstanceValueContentProvider;
import org.eclipse.papyrus.properties.uml.providers.SignatureContentProvider;
import org.eclipse.papyrus.properties.uml.providers.UMLLabelProvider;
import org.eclipse.papyrus.uml.modelexplorer.widgets.ServiceEditFilteredUMLContentProvider;
+import org.eclipse.papyrus.uml.modelexplorer.widgets.UMLElementMEBContentProvider;
+import org.eclipse.papyrus.uml.modelexplorer.widgets.util.HistoryUtil;
import org.eclipse.papyrus.umlutils.PackageUtil;
import org.eclipse.papyrus.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.widgets.providers.IStaticContentProvider;
@@ -58,6 +62,7 @@ import org.eclipse.uml2.uml.InstanceValue;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.UMLPackage;
/**
@@ -105,6 +110,18 @@ public class UMLModelElement extends EMFModelElement {
return new ExtensionRequiredObservableValue((Extension)source, domain);
}
+ if(feature == UMLPackage.eINSTANCE.getPort_Provided()) {
+ //TODO : Currently, this is read-only
+ //See #isEditable(String)
+ return new ProvidedInterfaceObservableList((Port)source, domain);
+ }
+
+ if(feature == UMLPackage.eINSTANCE.getPort_Required()) {
+ //TODO : Currently, this is read-only
+ //See #isEditable(String)
+ return new RequiredInterfaceObservableList((Port)source, domain);
+ }
+
if(feature == null) {
return null;
}
@@ -127,6 +144,14 @@ public class UMLModelElement extends EMFModelElement {
if(feature == UMLPackage.eINSTANCE.getExtension_IsRequired()) {
return true;
}
+ if(feature == UMLPackage.eINSTANCE.getPort_Provided()) {
+ return false;
+ //return true; //TODO : Unsupported yet
+ }
+ if(feature == UMLPackage.eINSTANCE.getPort_Required()) {
+ return false;
+ //return true; //TODO : Unsupported yet
+ }
return super.isEditable(propertyPath);
}
@@ -137,6 +162,18 @@ public class UMLModelElement extends EMFModelElement {
return new SignatureContentProvider(source);
}
+ if(feature == UMLPackage.eINSTANCE.getPort_Provided() || feature == UMLPackage.eINSTANCE.getPort_Required()) {
+ Package root = null;
+ if(((Element)source).getNearestPackage() != null) {
+ root = PackageUtil.getRootPackage((Element)source);
+ }
+
+ String historyId = HistoryUtil.getHistoryID(source, feature, root);
+ UMLElementMEBContentProvider contentProvider = new UMLElementMEBContentProvider(root, historyId);
+ contentProvider.setMetaClassWanted(feature.getEType());
+ return contentProvider;
+ }
+
if(feature instanceof EReference) {
Package root = null;
if(((Element)source).getNearestPackage() != null) {
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/util/UMLUtil.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/util/UMLUtil.java
index 58ba95d6156..e99732a33eb 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/util/UMLUtil.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/util/UMLUtil.java
@@ -154,19 +154,7 @@ public class UMLUtil {
//The parent stereotype is not always applicable...
//stereotype = umlElement.getApplicableStereotype(stereotypeName);
- org.eclipse.uml2.uml.Package umlPackage = umlElement.getNearestPackage();
- if(umlPackage == null) {
- stereotype = umlElement.getApplicableStereotype(stereotypeName);
- } else {
- outerLoop: for(Profile profile : umlPackage.getAllAppliedProfiles()) {
- for(Stereotype ownedStereotype : profile.getOwnedStereotypes()) {
- if(ownedStereotype.getQualifiedName().equals(stereotypeName)) {
- stereotype = ownedStereotype;
- break outerLoop;
- }
- }
- }
- }
+ stereotype = findStereotype(umlElement, stereotypeName);
//stereotype = umlElement.getApplicableStereotype(stereotypeName);
if(stereotype == null) {
@@ -198,6 +186,33 @@ public class UMLUtil {
}
/**
+ * Finds the Stereotype matching the given name.
+ * The search is done in the context of the given UML Element
+ * (i.e. the Profiles applied on the Element's nearest package)
+ *
+ * @param umlElement
+ * @param stereotypeName
+ * @return
+ */
+ public static Stereotype findStereotype(Element umlElement, String stereotypeName) {
+ Stereotype stereotype = null;
+ org.eclipse.uml2.uml.Package umlPackage = umlElement.getNearestPackage();
+ if(umlPackage == null) {
+ stereotype = umlElement.getApplicableStereotype(stereotypeName);
+ } else {
+ outerLoop: for(Profile profile : umlPackage.getAllAppliedProfiles()) {
+ for(Stereotype ownedStereotype : profile.getOwnedStereotypes()) {
+ if(ownedStereotype.getQualifiedName().equals(stereotypeName)) {
+ stereotype = ownedStereotype;
+ break outerLoop;
+ }
+ }
+ }
+ }
+ return stereotype;
+ }
+
+ /**
* Returns a collection of all super stereotypes of the given stereotype
* (Including itself)
*
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/TypeReferenceDialog.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/TypeReferenceDialog.java
index 6cbb9f7e655..0b049b6be28 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/TypeReferenceDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/TypeReferenceDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2011 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
@@ -14,7 +14,12 @@ package org.eclipse.papyrus.properties.uml.widgets;
import org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor;
import org.eclipse.swt.widgets.Composite;
-
+/**
+ *
+ * @author admin
+ * @Deprecated You should use the standard ReferenceDialog instead
+ */
+@Deprecated
public class TypeReferenceDialog extends AbstractPropertyEditor {
protected UMLReferenceDialog editor;
diff --git a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/UMLReferenceDialog.java b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/UMLReferenceDialog.java
index d6b63ebaf0e..38c97293864 100644
--- a/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/UMLReferenceDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.properties.uml/src/org/eclipse/papyrus/properties/uml/widgets/UMLReferenceDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2011 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
@@ -27,7 +27,12 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
-
+/**
+ *
+ * @author admin
+ * @deprecated You should use the generic ReferenceDialog instead
+ */
+@Deprecated
public class UMLReferenceDialog extends ReferenceDialog {
public UMLReferenceDialog(final Composite parent, final int style) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/META-INF/MANIFEST.MF
index 9f493fa8b1c..f5f9f7c7940 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/META-INF/MANIFEST.MF
@@ -1,5 +1,6 @@
Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.uml.modelexplorer.widgets
+Export-Package: org.eclipse.papyrus.uml.modelexplorer.widgets,
+ org.eclipse.papyrus.uml.modelexplorer.widgets.util
Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.eclipse.pa
pyrus.modelexplorer.widgets;bundle-version="0.8.0";visibility:=reexpo
rt,org.eclipse.uml2.uml;bundle-version="3.2.0",org.eclipse.papyrus.se
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/ServiceEditFilteredUMLContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/ServiceEditFilteredUMLContentProvider.java
index 8566ac15341..46d32e9be51 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/ServiceEditFilteredUMLContentProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/ServiceEditFilteredUMLContentProvider.java
@@ -14,25 +14,17 @@ package org.eclipse.papyrus.uml.modelexplorer.widgets;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.papyrus.modelexplorer.widgets.EditServiceValidator;
+import org.eclipse.papyrus.uml.modelexplorer.widgets.util.HistoryUtil;
public class ServiceEditFilteredUMLContentProvider extends UMLElementMEBContentProvider {
private EditServiceValidator validator;
public ServiceEditFilteredUMLContentProvider(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
- super(semanticRoot, getHistoryID(editedObject, feature, semanticRoot));
+ super(semanticRoot, HistoryUtil.getHistoryID(editedObject, feature, semanticRoot));
validator = new EditServiceValidator(editedObject, feature);
}
- private static String getHistoryID(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
- // return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
- if(editedObject.eResource() == null) {
- return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
- }
-
- return String.format("history_%s:%s:%s:%s", editedObject.eResource().getURI(), feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
- }
-
@Override
public boolean isValidValue(Object element) {
return super.isValidValue(element) && validator.isValidValue(getAdaptedValue(element));
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/util/HistoryUtil.java b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/util/HistoryUtil.java
new file mode 100644
index 00000000000..ab992516344
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.widgets/src/org/eclipse/papyrus/uml/modelexplorer/widgets/util/HistoryUtil.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.uml.modelexplorer.widgets.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+
+public class HistoryUtil {
+
+ /**
+ * Returns a String identifying the History of selected values for the given object/feature
+ *
+ * @param editedObject
+ * @param feature
+ * @param semanticRoot
+ * @return
+ */
+ public static String getHistoryID(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
+ // return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
+ if(editedObject.eResource() == null) {
+ return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
+ }
+
+ return String.format("history_%s:%s:%s:%s", editedObject.eResource().getURI(), feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
+ }
+}

Back to the top