summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratischenko2014-06-03 06:03:22 (EDT)
committeratischenko2014-06-03 12:04:10 (EDT)
commit533011594bb1a0f6ea2136d0fef151a99f9e5549 (patch)
tree27d379d2790205421764b5e3c5e4bb3fe82d2bdc
parent942b7304909eed3f22e6a75762b35ef2cd7bbad4 (diff)
downloadorg.eclipse.papyrus-533011594bb1a0f6ea2136d0fef151a99f9e5549.zip
org.eclipse.papyrus-533011594bb1a0f6ea2136d0fef151a99f9e5549.tar.gz
org.eclipse.papyrus-533011594bb1a0f6ea2136d0fef151a99f9e5549.tar.bz2
[412839] - Cannot set Element owner during Callbehavior creation refs/changes/44/27844/1
Signed-off-by: atischenko <ticher777@gmail.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateInvocationActionDialog.java25
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateParameterDialog.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/GetObjectsOfTypeListSelectionDialog.java62
3 files changed, 77 insertions, 37 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateInvocationActionDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateInvocationActionDialog.java
index 354f2bc..2812092 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateInvocationActionDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateInvocationActionDialog.java
@@ -32,10 +32,10 @@ import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
import org.eclipse.papyrus.uml.diagram.activity.part.CustomMessages;
@@ -45,7 +45,6 @@ import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.actions.LabelHelper;
import org.eclipse.papyrus.uml.diagram.common.ui.helper.HelpComponentFactory;
import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -69,6 +68,7 @@ import org.eclipse.ui.forms.widgets.ImageHyperlink;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.InvocationAction;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.UMLFactory;
@@ -558,17 +558,18 @@ public abstract class CreateInvocationActionDialog extends FormDialog {
*
*/
private void handleChooseParent() {
- /*
- * TODO BACKPORT
- */
- // UMLMultiEClassifierTreeSelectorDialog dialog = new UMLMultiEClassifierTreeSelectorDialog(getShell(), actionParent, getPossibleInvokedParents(actionParent),true);
- // dialog.setMessage(CustomMessages.UMLModelingAssistantProviderMessage);
- // dialog.setTitle(CustomMessages.UMLModelingAssistantProviderTitle);
- // if(dialog.open() == Window.OK) {
- // setInvokedParent((EObject)dialog.getTheResult());
- // }
+ GetObjectsOfTypeListSelectionDialog dialog = new GetObjectsOfTypeListSelectionDialog(getParentShell(), labelProvider, actionParent, false);
+ for (EClassifier type : getPossibleInvokedParents(actionParent)) {
+ dialog.addElementsOfType(type);
+ }
+ if(dialog.open() == Window.OK) {
+ Object firstResult = dialog.getFirstResult();
+ if(firstResult instanceof EObject) {
+ setInvokedParent((EObject)dialog.getFirstResult());
+ }
+ }
}
-
+
/**
* Define the object in which invoked object will be created (if creation
* mode is chosen)
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateParameterDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateParameterDialog.java
index ed58088..febb682 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateParameterDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/CreateParameterDialog.java
@@ -13,11 +13,8 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.edit.dialogs;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
@@ -30,10 +27,8 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.core.modelsetquery.ModelSetQuery;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.uml.diagram.activity.part.CustomMessages;
-import org.eclipse.papyrus.uml.diagram.activity.part.Messages;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.actions.LabelHelper;
@@ -53,7 +48,6 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -315,12 +309,8 @@ public class CreateParameterDialog extends FormDialog {
*
*/
private void handleChooseType() {
- Set<Object> types = getPossibleTypes();
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setMessage(Messages.UMLModelingAssistantProviderMessage);
- dialog.setTitle(Messages.UMLModelingAssistantProviderTitle);
- dialog.setMultipleSelection(false);
- dialog.setElements(types.toArray());
+ GetObjectsOfTypeListSelectionDialog dialog = new GetObjectsOfTypeListSelectionDialog(getShell(), labelProvider, parameterOwner, true);
+ dialog.addElementsOfType(UMLPackage.eINSTANCE.getTypedElement_Type().getEType());
if(dialog.open() == Window.OK) {
Object firstResult = dialog.getFirstResult();
if(firstResult instanceof EObject) {
@@ -366,19 +356,6 @@ public class CreateParameterDialog extends FormDialog {
}
/**
- * Gets the possible types for the parameter
- *
- * @return the possible types
- */
- private Set<Object> getPossibleTypes() {
- Collection<EObject> types = ModelSetQuery.getObjectsOfType(parameterOwner, UMLPackage.eINSTANCE.getTypedElement_Type().getEType());
- Set<Object> result = new HashSet<Object>();
- result.add("");
- result.addAll(types);
- return result;
- }
-
- /**
* Gets the possible directions.
*
* @return the possible directions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/GetObjectsOfTypeListSelectionDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/GetObjectsOfTypeListSelectionDialog.java
new file mode 100644
index 0000000..0a62a5b
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/dialogs/GetObjectsOfTypeListSelectionDialog.java
@@ -0,0 +1,62 @@
+package org.eclipse.papyrus.uml.diagram.activity.edit.dialogs;
+
+import java.util.HashSet;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.core.modelsetquery.ModelSetQuery;
+import org.eclipse.papyrus.uml.diagram.activity.part.Messages;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * Extends {@link ElementListSelectionDialog} with ability to add all elements of given type using {@link ModelSetQuery}
+ */
+public class GetObjectsOfTypeListSelectionDialog extends ElementListSelectionDialog {
+
+ private final HashSet<EObject> myElementsOfType = new HashSet<EObject>();
+
+ private final EObject mySourceObject;
+
+ private final boolean myNeedsNullObject;
+
+ /**
+ * Constructs the dialog instance with default generic message and title.
+ *
+ * @param renderer
+ * label provider to render the element options
+ * @param sourceObject
+ * fixed source object that will be used as an anchor for all type queries using {@link ModelSetQuery}
+ * @param needNullObject
+ * if <code>true</code>, the dialog will include additional null element (shown as empty string)
+ */
+ public GetObjectsOfTypeListSelectionDialog(Shell parent, ILabelProvider renderer, EObject sourceObject, boolean needNullObject) {
+ super(parent, renderer);
+ mySourceObject = sourceObject;
+ myNeedsNullObject = needNullObject;
+
+ setMessage(Messages.UMLModelingAssistantProviderMessage);
+ setTitle(Messages.UMLModelingAssistantProviderTitle);
+ setMultipleSelection(false);
+ }
+
+ /**
+ * Queries the {@link ModelSetQuery} for all elements of given type and adds them to the choices
+ */
+ public void addElementsOfType(EClassifier ofType) {
+ myElementsOfType.addAll(ModelSetQuery.getObjectsOfType(mySourceObject, ofType));
+ }
+
+ @Override
+ public int open() {
+ Object[] elements = myNeedsNullObject ? new Object[myElementsOfType.size() + 1] : new Object[myElementsOfType.size()];
+ myElementsOfType.toArray(elements);
+ if(myNeedsNullObject) {
+ elements[elements.length - 1] = "";
+ }
+ setElements(elements);
+ setInitialSelections(new Object[]{ mySourceObject });
+ return super.open();
+ }
+}