Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2015-08-18 07:18:58 +0000
committerFlorian Noyrit2015-08-18 07:18:58 +0000
commitc2503a43bc19a3f4c68ace7d76b5a8fa7b418389 (patch)
tree38d9e510bf6a9ba93eaea2cc334d7a36d7e322f6
parent58cd829d612c08c57c89c1a44a00e180a31e0a97 (diff)
parent5683c01218622ba4543c8d21d6fd260600d66b90 (diff)
downloadorg.eclipse.papyrus-c2503a43bc19a3f4c68ace7d76b5a8fa7b418389.tar.gz
org.eclipse.papyrus-c2503a43bc19a3f4c68ace7d76b5a8fa7b418389.tar.xz
org.eclipse.papyrus-c2503a43bc19a3f4c68ace7d76b5a8fa7b418389.zip
Merge branch 'master' of ssh://fnoyrit@git.eclipse.org:29418/papyrus/org.eclipse.papyrus
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/sync/SyncCDTtoModel.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/META-INF/MANIFEST.MF1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/policy/InteractionOverviewDiagramDragDropEditPolicy.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/AbstractViewProvider.java328
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/CustomViewProvider.java3
5 files changed, 352 insertions, 22 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/sync/SyncCDTtoModel.java b/extraplugins/codegen/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/sync/SyncCDTtoModel.java
index d9c308be89d..c25b00ef4b0 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/sync/SyncCDTtoModel.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/sync/SyncCDTtoModel.java
@@ -268,6 +268,7 @@ public class SyncCDTtoModel implements Runnable {
}
}
else if (syncInfo.behavior != null) {
+ // operation is still null (=> does not enter operation != null case below)
behavior = syncInfo.behavior;
}
else if ((syncInfo.createBehaviorName != null) && (m_classifier instanceof Class)) {
@@ -297,12 +298,17 @@ public class SyncCDTtoModel implements Runnable {
behavior.setName(name);
}
}
- // Remove all parameters from the operation (they will be added later).
- // Calling parameters.clear() is not sufficient. Otherwise stereotype
- // applications to unresolved elements remain in the model
+ }
+
+ // assertions: operation can be null, behavior is always non-null
+
+ // Remove all parameters from operation / behavior (they will be added later).
+ // Calling parameters.clear() is not sufficient. Otherwise stereotype
+ // applications to unresolved elements remain in the model
+ if (operation != null) {
UMLUtil.destroyElements(operation.getOwnedParameters());
- UMLUtil.destroyElements(behavior.getOwnedParameters());
}
+ UMLUtil.destroyElements(behavior.getOwnedParameters());
for (IASTNode declaratorChild : declarator.getChildren()) {
if (declaratorChild instanceof IASTParameterDeclaration) {
@@ -357,22 +363,20 @@ public class SyncCDTtoModel implements Runnable {
} catch (ExpansionOverlapsBoundaryException e) {
}
- NamedElement umlParameterType = Utils.getQualifiedElement(Utils.getTop(m_classifier),
+ NamedElement namedElemParamType = Utils.getQualifiedElement(Utils.getTop(m_classifier),
parameterTypeName);
- if (umlParameterType == null) {
- umlParameterType = Utils.getQualifiedElement(Utils.getTop(m_classifier),
+ if (namedElemParamType == null) {
+ namedElemParamType = Utils.getQualifiedElement(Utils.getTop(m_classifier),
ansiCLib + Utils.nsSep + parameterTypeName);
}
if (parameterType.isRestrict()) {
}
Parameter umlParameter = null;
- if (umlParameterType instanceof Type) {
- umlParameter = operation.createOwnedParameter(parameterName.toString(), (Type) umlParameterType);
- behavior.createOwnedParameter(parameterName.toString(), (Type) umlParameterType);
- } else {
- umlParameter = operation.createOwnedParameter(parameterName.toString(), null);
- behavior.createOwnedParameter(parameterName.toString(), null);
+ Type paramType = namedElemParamType instanceof Type ? (Type) namedElemParamType : null;
+ if (operation != null) {
+ umlParameter = operation.createOwnedParameter(parameterName.toString(), paramType);
}
+ behavior.createOwnedParameter(parameterName.toString(), paramType);
if (parameterType.isConst()) {
StereotypeUtil.apply(umlParameter, Const.class);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/META-INF/MANIFEST.MF
index eb4bc05313d..476e953be8f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/META-INF/MANIFEST.MF
@@ -38,7 +38,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.navigator;bundle-version="3.5.200",
org.eclipse.papyrus.infra.extendedtypes;bundle-version="1.1.0",
com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.sysml.diagram.common;bundle-version="1.1.0",
org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.1.0",
org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="1.6.0",
org.eclipse.papyrus.uml.diagram.sequence;bundle-version="1.1.0";resolution:=optional,
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/policy/InteractionOverviewDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/policy/InteractionOverviewDiagramDragDropEditPolicy.java
index 2f5e8149e3d..48dbf21bfed 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/policy/InteractionOverviewDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/edit/policy/InteractionOverviewDiagramDragDropEditPolicy.java
@@ -16,24 +16,23 @@ import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CommonDiagramDragDropEditPolicy;
+
/**
* Customization of the DND edit policy for the InteractionOverviewDiagram
* Diagram
*/
-public class InteractionOverviewDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPolicy {
+@Deprecated // use CustomInteractionOverviewDiagramDragAndDropEditPolicy
+public class InteractionOverviewDiagramDragDropEditPolicy {
/** Default constructor. */
public InteractionOverviewDiagramDragDropEditPolicy() {
- super(null);
// registry = new CustomGraphicalTypeRegistry();
}
/**
* {@inheritDoc}
*/
- @Override
protected Set<String> getSpecificDropBehaviorTypes() {
return Collections.emptySet();
}
@@ -41,9 +40,8 @@ public class InteractionOverviewDiagramDragDropEditPolicy extends CommonDiagramD
/**
* {@inheritDoc}
*/
- @Override
protected ICommand getUnknownDropCommand(final DropObjectsRequest dropRequest, final EObject droppedEObject) {
-
- return super.getUnknownDropCommand(dropRequest, droppedEObject);
+ return null;
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/AbstractViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/AbstractViewProvider.java
new file mode 100644
index 00000000000..57a52ef4f76
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/AbstractViewProvider.java
@@ -0,0 +1,328 @@
+/*****************************************************************************
+ * 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:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.interactionoverview.provider;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.common.core.util.Log;
+import org.eclipse.gmf.runtime.diagram.core.internal.DiagramPlugin;
+import org.eclipse.gmf.runtime.diagram.core.internal.DiagramStatusCodes;
+import org.eclipse.gmf.runtime.diagram.core.internal.l10n.DiagramCoreMessages;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Implements of the <code>IViewProvider</code> interface. This
+ * implementations invokes the appropriate factory method by inspecting the
+ * supplied operation and provides the actual view creation functionality.
+ */
+public class AbstractViewProvider extends AbstractProvider implements IViewProvider {
+
+ private static String viewCreationMethodName = "createView"; //$NON-NLS-1$
+
+ private static String diagramCreationMethodName = "createDiagram"; //$NON-NLS-1$
+
+ static protected class ClassToCreationMethodMap extends HashMap {
+
+ static final long serialVersionUID = 1;
+
+ public void addMethod(Class clazz, Method method) {
+ if (get(clazz) == null) {
+ put(clazz, method);
+ }
+ }
+
+ public Method getCreationMethod(Class clazz) {
+ return (Method) get(clazz);
+ }
+ }
+
+ public static ClassToCreationMethodMap classToCreateMethod = new ClassToCreationMethodMap();
+
+ /**
+ * Determines whether this view provider can provide for the required
+ * operation It inspects the type of view operation and calls the
+ * corresponding <code>provides</code> method.
+ *
+ * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(IOperation)
+ */
+ @Override
+ public final boolean provides(IOperation operation) {
+ /* if this is the CreateViewForKindOperation operation */
+ if (operation instanceof CreateViewForKindOperation) {
+ return provides((CreateViewForKindOperation) operation);
+ }
+
+ /* Make sure it is a view operation */
+ assert operation instanceof CreateViewOperation : "operation is not CreateViewOperation in AbstractViewProvider";//$NON-NLS-1$
+
+ /* call the specific provides method */
+ if (operation instanceof CreateDiagramViewOperation) {
+ return provides((CreateDiagramViewOperation) operation);
+ } else if (operation instanceof CreateEdgeViewOperation) {
+ return provides((CreateEdgeViewOperation) operation);
+ } else if (operation instanceof CreateNodeViewOperation) {
+ return provides((CreateNodeViewOperation) operation);
+ }
+ return false;
+ }
+
+ @Override
+ public final Diagram createDiagram(IAdaptable contextElement, String diagramKind, PreferencesHint preferencesHint) {
+ return (Diagram) createNewView(getDiagramViewClass(contextElement, diagramKind), new Object[] { contextElement, diagramKind, preferencesHint });
+ }
+
+ // Papyrus - final statement removed
+ @Override
+ public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+
+ return (Edge) createNewView(getEdgeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint });
+ }
+
+ // Papyrus - final statement removed
+ @Override
+ public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+
+ return (Node) createNewView(getNodeViewClass(semanticAdapter, containerView, semanticHint), new Object[] { semanticAdapter, containerView, semanticHint, new Integer(index), Boolean.valueOf(persisted), preferencesHint });
+ }
+
+ /**
+ * Determines whether this provider can provide for the specified view
+ * creation operation
+ *
+ * @param operation
+ * Contains a semantic kind and a containerView
+ * @return boolean
+ */
+ protected boolean provides(CreateViewForKindOperation op) {
+ if (op.getViewKind() == Node.class) {
+ return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ }
+ if (op.getViewKind() == Edge.class) {
+ return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ }
+ return true;
+ }
+
+ /**
+ * Determines whether this provider can provide for the specified diagram
+ * view operation
+ *
+ * @param operation
+ * @return boolean
+ */
+ protected boolean provides(CreateDiagramViewOperation operation) {
+ return getDiagramViewClass(operation.getSemanticAdapter(), operation.getSemanticHint()) != null;
+ }
+
+ /**
+ * Determines whether this provider can provide for the specified edge view
+ * operation
+ *
+ * @param operation
+ * @return boolean
+ */
+ protected boolean provides(CreateEdgeViewOperation operation) {
+ return (getEdgeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null);
+ }
+
+ /**
+ * Determines whether this provider can provide for the specified node view
+ * operation
+ *
+ * @param operation
+ * @return boolean
+ */
+ protected boolean provides(CreateNodeViewOperation operation) {
+ return (getNodeViewClass(operation.getSemanticAdapter(), operation.getContainerView(), operation.getSemanticHint()) != null);
+ }
+
+ /**
+ * Returns the diagram view class to instantiate based on the passed params
+ *
+ * @param semanticAdapter
+ * TODO
+ * @param semanticAdapter
+ * @return Class
+ */
+ protected Class getDiagramViewClass(IAdaptable semanticAdapter, String diagramKind) {
+ return null;
+ }
+
+ /**
+ * Returns the edge view class to instantiate based on the passed params
+ *
+ * @param semanticAdapter
+ * @param containerView
+ * @param semanticHint
+ * @return Class
+ */
+ protected Class getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
+ return null;
+ }
+
+ /**
+ * Returns the node view class to instantiate based on the passed params
+ *
+ * @param semanticAdapter
+ * @param containerView
+ * @param semanticHint
+ * @return Class
+ */
+ protected Class getNodeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
+ return null;
+ }
+
+ /**
+ * creates a view instance via reflection.
+ *
+ * @param constructorParams
+ * the view's constructor parameters.
+ */
+ private View createNewView(Class viewClass, Object[] constructorParams) {
+ try {
+ assert null != viewClass : "Null viewClass in AbstractProvider";//$NON-NLS-1$
+ assert null != constructorParams : "Null constructorParams in AbstractProvider";//$NON-NLS-1$
+
+ Constructor constructor = getFactoryConstructor(viewClass);
+ if (constructor == null) {
+ Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$
+ return null;
+ }
+
+ Object factory = constructor.newInstance(new Object[] {});
+ Method method = getCreationMethod(viewClass, constructorParams);
+ if (method == null) {
+ Log.error(DiagramPlugin.getInstance(), DiagramStatusCodes.SERVICE_FAILURE, "View (" + viewClass + ") is missing a proper creation Factory"); //$NON-NLS-1$//$NON-NLS-2$
+ return null;
+ }
+ return (View) method.invoke(factory, constructorParams);
+ } catch (Throwable e) {
+ String eMsg = NLS.bind(DiagramCoreMessages.AbstractViewProvider_create_view_failed_ERROR_, viewClass.getName());
+ Log.warning(DiagramPlugin.getInstance(), IStatus.WARNING, eMsg, e);
+ return null;
+ }
+ }
+
+ private Constructor getFactoryConstructor(Class viewClass) {
+ if (viewClass != null) {
+ Constructor[] ctors = viewClass.getConstructors();
+ for (int i = 0; i < ctors.length; i++) {
+ if (ctors[i].getParameterTypes().length == 0) {
+ return ctors[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ /** Return the <i>creation</i> constructor for the cached view class. */
+ private Method getCreationMethod(Class viewClass, Object[] params) {
+ if (viewClass != null) {
+ Method method = classToCreateMethod.getCreationMethod(viewClass);
+ if (method != null) {
+ return method;
+ }
+
+ Method[] methods = viewClass.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ method = methods[i];
+ String methodName = method.getName();
+ if (methodName.equals(viewCreationMethodName) || methodName.equals(diagramCreationMethodName)) {
+ classToCreateMethod.addMethod(viewClass, method);
+ return method;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the EClass associated with the semantic adapter
+ *
+ * @param semanticAdapter
+ * @return EClass
+ */
+ protected EClass getSemanticEClass(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.getProxyClass(eObject);
+ }
+ IElementType type = (IElementType) semanticAdapter.getAdapter(IElementType.class);
+ if (type != null) {
+ return type.getEClass();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the semantic element associated with the semantic adapter
+ *
+ * @param semanticAdapter
+ * @return EClass
+ */
+ protected EObject getSemanticElement(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the semantic element associated with the semantic adapter
+ *
+ * @param semanticAdapter
+ * @return EClass
+ */
+ protected EObject getSemanticElement(IAdaptable semanticAdapter, TransactionalEditingDomain domain) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.resolve(domain, eObject);
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/CustomViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/CustomViewProvider.java
index 338df897bb8..539198c6017 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/CustomViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src/org/eclipse/papyrus/uml/diagram/interactionoverview/provider/CustomViewProvider.java
@@ -34,7 +34,8 @@ import org.eclipse.papyrus.uml.diagram.interactionoverview.utils.CallBehaviorUti
import org.eclipse.papyrus.uml.diagram.interactionoverview.utils.CallBehaviorUtil.CallBehaviorActionType;
import org.eclipse.uml2.uml.CallBehaviorAction;
-public class CustomViewProvider extends org.eclipse.papyrus.gmf.diagram.common.provider.AbstractViewProvider {
+
+public class CustomViewProvider extends AbstractViewProvider {
@Override
protected boolean provides(final CreateNodeViewOperation op) {

Back to the top