Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java356
1 files changed, 121 insertions, 235 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
index 6fd2b9f7c43..b1933d106f6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
@@ -82,7 +82,6 @@ import org.eclipse.uml2.uml.Type;
* The Class ClassDiagramDragDropEditPolicy.
*/
public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEditPolicy {
-
/**
* Instantiates a new class diagram drag drop edit policy.
*/
@@ -139,207 +138,129 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* binary association that is dropped.
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visualid
+ * the node visualid
*
* @return the command
*/
protected Command dropAssociation(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
- Collection endtypes = ProfileLinkMappingHelper.getInstance().getSource(semanticLink);
- if(endtypes.size() == 2) {
- Element source = (Element)endtypes.toArray()[0];
- Element target = (Element)endtypes.toArray()[1];
+ Collection<?> endtypes = ProfileLinkMappingHelper.getInstance().getSource(semanticLink);
+ if (endtypes.size() == 2) {
+ Element source = (Element) endtypes.toArray()[0];
+ Element target = (Element) endtypes.toArray()[1];
return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Association"), source, target, 4001, dropRequest.getLocation(), semanticLink)); //$NON-NLS-1$
}
- if(endtypes.size() > 2) {
+ if (endtypes.size() > 2) {
MultiAssociationHelper associationHelper = new MultiAssociationHelper(getEditingDomain());
- return associationHelper.dropMultiAssociation((Association)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
+ return associationHelper.dropMultiAssociation((Association) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView());
}
return UnexecutableCommand.INSTANCE;
-
}
/**
* this method send a Command that create views for associationClass
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visualid
+ * the node visualid
*
* @return the command
*/
- // protected Command dropAssociationClass(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
- // AssociationClassHelper associationClassHelper = new AssociationClassHelper(getEditingDomain());
- // return associationClassHelper.dropAssociationClass((AssociationClass)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
- // }
-
+ // protected Command dropAssociationClass(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
+ // AssociationClassHelper associationClassHelper = new AssociationClassHelper(getEditingDomain());
+ // return associationClassHelper.dropAssociationClass((AssociationClass)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
+ // }
/**
* this method send a command to create views to display
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visualid
+ * the node visualid
*
* @return the command
*/
protected Command dropDependency(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
- Collection sources = ProfileLinkMappingHelper.getInstance().getSource(semanticLink);
- Collection targets = ProfileLinkMappingHelper.getInstance().getTarget(semanticLink);
- if(sources.size() == 1 && targets.size() == 1) {
- Element source = (Element)sources.toArray()[0];
- Element target = (Element)targets.toArray()[0];
+ Collection<?> sources = ProfileLinkMappingHelper.getInstance().getSource(semanticLink);
+ Collection<?> targets = ProfileLinkMappingHelper.getInstance().getTarget(semanticLink);
+ if (sources.size() == 1 && targets.size() == 1) {
+ Element source = (Element) sources.toArray()[0];
+ Element target = (Element) targets.toArray()[0];
return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Association"), source, target, 4008, dropRequest.getLocation(), semanticLink)); //$NON-NLS-1$
}
- if(sources.size() > 1 || targets.size() > 1) {
+ if (sources.size() > 1 || targets.size() > 1) {
MultiDependencyHelper dependencyHelper = new MultiDependencyHelper(getEditingDomain());
- return dependencyHelper.dropMutliDependency((Dependency)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
+ return dependencyHelper.dropMutliDependency((Dependency) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView());
}
return UnexecutableCommand.INSTANCE;
}
- // protected Command outlineDropContainedClass(DropObjectsRequest dropRequest, Element semanticObject, int nodeVISUALID) {
- // ContainmentHelper containmentHelper = new ContainmentHelper(getEditingDomain());
- // Element owner = (Element)semanticObject.getOwner();
- // boolean ownerviewexist = false;
- // Collection<EditPart> editPartSet = getViewer().getEditPartRegistry().values();
- // Iterator<EditPart> editPartIterator = editPartSet.iterator();
- // while(editPartIterator.hasNext()) {
- // EditPart currentEditPart = editPartIterator.next();
- // if((currentEditPart instanceof ClassEditPart)) {
- // if(((GraphicalEditPart)currentEditPart).resolveSemanticElement().equals(owner)) {
- // ownerviewexist = true;
- // }
- // }
- // }
- //
- // if(ownerviewexist) {
- // return containmentHelper.outlineDropContainedClass((Class)semanticObject, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView());
- // } else {
- // return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticObject));
- // }
- //
- // }
-
- // protected Command compartmentDropContainedClass(DropObjectsRequest dropRequest, Element semanticObject, int nodeVISUALID) {
- // ContainmentHelper containmentHelper = new ContainmentHelper(getEditingDomain());
- // CompositeCommand cc = new CompositeCommand("compartmentDropContainedClass");
- // Point location = dropRequest.getLocation().getCopy();
- // ((GraphicalEditPart)getHost()).getContentPane().translateToRelative(location);
- // ((GraphicalEditPart)getHost()).getContentPane().translateFromParent(location);
- // location.translate(((GraphicalEditPart)getHost()).getContentPane().getClientArea().getLocation().getNegated());
- // cc = getDefaultDropNodeCommand(nodeVISUALID, location, semanticObject);
- // GraphicalEditPart owner = null;
- // Collection<EditPart> editPartSet = getViewer().getEditPartRegistry().values();
- // Iterator<EditPart> editPartIterator = editPartSet.iterator();
- // while(editPartIterator.hasNext()) {
- // EditPart currentEditPart = editPartIterator.next();
- // if(currentEditPart instanceof ClassEditPart) {
- // if(((GraphicalEditPart)currentEditPart).resolveSemanticElement().equals(semanticObject)) {
- // View view = (View)currentEditPart.getModel();
- // EList<ConnectorImpl> listlink = view.getTargetEdges();
- // Iterator<ConnectorImpl> addedlinkIterator = listlink.iterator();
- // while(addedlinkIterator.hasNext()) {
- // ConnectorImpl currentconnector = addedlinkIterator.next();
- // ShapeImpl containmenetshape = (ShapeImpl)currentconnector.getSource();
- // if(containmenetshape.getType().equals("3032")) {
- // /* The containment circle node is deleted only if any other link is connected */
- // if(containmenetshape.getSourceEdges().size() == 1) {
- // cc.compose(new DeleteCommand(getEditingDomain(), (View)containmenetshape));
- //
- // }
- // }
- // }
- // cc.add(new DeleteCommand(getEditingDomain(), (View)((GraphicalEditPart)currentEditPart).getModel()));
- //
- //
- // }
- // }
- // }
- //
- // return new ICommandProxy(cc);
- // }
-
/**
* {@inheritedDoc}
*/
@Override
protected Command getSpecificDropCommand(DropObjectsRequest dropRequest, Element semanticElement, int nodeVISUALID, int linkVISUALID) {
// /!\ Warning the order is important! test on the superclass and AssociationNode is a super class for ExtensionEditPart!
- switch(linkVISUALID) {
+ switch (linkVISUALID) {
case ElementImportEditPart.VISUAL_ID:
return dropElementImport(dropRequest, semanticElement, nodeVISUALID);
case ExtensionEditPart.VISUAL_ID:
return dropExtension(dropRequest, semanticElement, linkVISUALID);
default:
-
}
- switch(nodeVISUALID) {
+ switch (nodeVISUALID) {
case 2014:
return dropDependency(dropRequest, semanticElement, nodeVISUALID);
- // case 2013:
- // return dropAssociationClass(dropRequest, semanticLink, nodeVISUALID);
case 2015:
return dropAssociation(dropRequest, semanticElement, nodeVISUALID);
- // case 3014:
- // return compartmentDropContainedClass(dropRequest, semanticLink, nodeVISUALID);
- // case 2008:
- // return outlineDropContainedClass(dropRequest, semanticLink, nodeVISUALID);
-
case CommentEditPart.VISUAL_ID:
case CommentEditPartCN.VISUAL_ID:
return dropComment(dropRequest, semanticElement, nodeVISUALID);
-
case ConstraintEditPart.VISUAL_ID:
case ConstraintEditPartCN.VISUAL_ID:
return dropConstraint(dropRequest, semanticElement, nodeVISUALID);
-
case MetaclassEditPart.VISUAL_ID:
case MetaclassEditPartCN.VISUAL_ID:
return dropMetaclass(dropRequest, semanticElement, nodeVISUALID);
default:
return UnexecutableCommand.INSTANCE;
}
-
-
}
/**
* Returns the command to drop the metaclass
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticElement
- * the metaclass to drop
+ * the metaclass to drop
* @param nodeVISUALID
- * the node VISUAL ID
+ * the node VISUAL ID
* @return
* the command to drop the metaclass
*/
protected Command dropMetaclass(DropObjectsRequest dropRequest, Element semanticElement, int nodeVISUALID) {
- //we test if the element to drop is a Class or a Metaclass
- if(Util.isMetaclass((Type)semanticElement)) {
+ // we test if the element to drop is a Class or a Metaclass
+ if (Util.isMetaclass((Type) semanticElement)) {
CompositeCommand cc = new CompositeCommand("Drop"); //$NON-NLS-1$
CompositeCommand dropCommand = super.getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticElement);
cc.compose(dropCommand);
Object returnedValue = dropCommand.getCommandResult().getReturnValue();
- if(returnedValue instanceof ArrayList<?>) {//we look for the view descriptor of the created metaclass
- ViewDescriptor desc = (ViewDescriptor)((ArrayList<?>)returnedValue).get(0);
-
- //we set the stereotype to visible
+ if (returnedValue instanceof ArrayList<?>) {// we look for the view descriptor of the created metaclass
+ ViewDescriptor desc = (ViewDescriptor) ((ArrayList<?>) returnedValue).get(0);
+ // we set the stereotype to visible
SetStereotypeVisibleOnMetaclassCommand command = new SetStereotypeVisibleOnMetaclassCommand(getEditingDomain(), "Apply Stereotype", null, semanticElement, desc); //$NON-NLS-1$
- if(command.canExecute()) {
+ if (command.canExecute()) {
cc.compose(command);
}
-
}
return new ICommandProxy(cc);
} else {
@@ -351,25 +272,27 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* Returns the command to drop the Comment + the link to attach it to its annotated elements
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visual id
+ * the node visual id
*
* @return the command
*/
protected Command dropComment(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
// Test canvas element
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart)getHost();
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
- if(!(graphicalParentObject instanceof org.eclipse.uml2.uml.Package)) {
+ if (!(graphicalParentObject instanceof org.eclipse.uml2.uml.Package)) {
return UnexecutableCommand.INSTANCE;
}
- if(nodeVISUALID == CommentEditPart.VISUAL_ID) {
- return getDropCommentCommand((Comment)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Comment_1002, (IHintedType)UMLElementTypes.CommentAnnotatedElement_1022);
- } else if(nodeVISUALID == CommentEditPartCN.VISUAL_ID) {
- return getDropCommentCommand((Comment)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Comment_1007, (IHintedType)UMLElementTypes.CommentAnnotatedElement_1022);
+ if (nodeVISUALID == CommentEditPart.VISUAL_ID) {
+ return getDropCommentCommand((Comment) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Comment_1002,
+ (IHintedType) UMLElementTypes.CommentAnnotatedElement_1022);
+ } else if (nodeVISUALID == CommentEditPartCN.VISUAL_ID) {
+ return getDropCommentCommand((Comment) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Comment_1007,
+ (IHintedType) UMLElementTypes.CommentAnnotatedElement_1022);
}
return UnexecutableCommand.INSTANCE;
}
@@ -378,30 +301,31 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* Returns the command to drop the Constraint + the link to attach it to its contrainted elements
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param nodeVISUALID
- * the node visual id
+ * the node visual id
*
* @return the command
*/
protected Command dropConstraint(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
// Test canvas element
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart)getHost();
+ GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
- if(!(graphicalParentObject instanceof org.eclipse.uml2.uml.Package)) {
+ if (!(graphicalParentObject instanceof org.eclipse.uml2.uml.Package)) {
return UnexecutableCommand.INSTANCE;
}
- if(nodeVISUALID == ConstraintEditPart.VISUAL_ID) {
- return getDropConstraintCommand((Constraint)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Constraint_1014, (IHintedType)UMLElementTypes.ConstraintConstrainedElement_4014);
- } else if(nodeVISUALID == ConstraintEditPartCN.VISUAL_ID) {
- return getDropConstraintCommand((Constraint)semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart)getHost()).getNotationView(), (IHintedType)UMLElementTypes.Constraint_1028, (IHintedType)UMLElementTypes.ConstraintConstrainedElement_4014);
+ if (nodeVISUALID == ConstraintEditPart.VISUAL_ID) {
+ return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_1014,
+ (IHintedType) UMLElementTypes.ConstraintConstrainedElement_4014);
+ } else if (nodeVISUALID == ConstraintEditPartCN.VISUAL_ID) {
+ return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_1028,
+ (IHintedType) UMLElementTypes.ConstraintConstrainedElement_4014);
}
return UnexecutableCommand.INSTANCE;
}
-
/**
* Gets the editing domain.
*
@@ -409,7 +333,7 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
*/
@Override
protected TransactionalEditingDomain getEditingDomain() {
- return ((IGraphicalEditPart)getHost()).getEditingDomain();
+ return ((IGraphicalEditPart) getHost()).getEditingDomain();
}
/**
@@ -417,29 +341,24 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* this method send a command to create views to display to drop an extension link
*
* @param dropRequest
- * the drop request
+ * the drop request
* @param semanticLink
- * the semantic link
+ * the semantic link
* @param linkVISUALID
- * hte link visualid
+ * hte link visualid
* @return
*/
protected Command dropExtension(DropObjectsRequest dropRequest, Element semanticLink, int linkVISUALID) {
Collection<?> sources = ProfileLinkMappingHelper.getInstance().getSource(semanticLink);
Collection<?> targets = ProfileLinkMappingHelper.getInstance().getTarget(semanticLink);
-
- Element source = (Element)sources.toArray()[0];
- Element target = (Element)targets.toArray()[0];
-
- if(sources.size() != 1 && targets.size() != 1) {
+ Element source = (Element) sources.toArray()[0];
+ Element target = (Element) targets.toArray()[0];
+ if (sources.size() != 1 && targets.size() != 1) {
return UnexecutableCommand.INSTANCE;
}
-
return new ICommandProxy(dropBinaryLinkExtension(new CompositeCommand("drop Extension"), source, target, ExtensionEditPart.VISUAL_ID, dropRequest.getLocation(), semanticLink)); //$NON-NLS-1$
}
-
-
/**
* the drop is possible only if the container of the dropped element is the same that the host!!!
*
@@ -449,17 +368,13 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* @return
*/
protected Command dropElementImport(DropObjectsRequest dropRequest, Element semanticLink, int linkVISUALID) {
- if(semanticLink instanceof ElementImport) {
- if(((ElementImport)semanticLink).getImportedElement() instanceof Class) {
-
- Class metaclass = (Class)((ElementImport)semanticLink).getImportedElement();
-
+ if (semanticLink instanceof ElementImport) {
+ if (((ElementImport) semanticLink).getImportedElement() instanceof Class) {
+ Class metaclass = (Class) ((ElementImport) semanticLink).getImportedElement();
/**
* get the container for the element
*/
EObject container = semanticLink.eContainer();
-
-
/**
* get the view of the container
*/
@@ -467,25 +382,19 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
/**
* get the host's model
*/
-
CompositeCommand cc = new CompositeCommand("Drop"); //$NON-NLS-1$
IAdaptable elementAdapter = new EObjectAdapter(metaclass);
-
ViewDescriptor descriptor;
-
- //we create the view command
- if(containerView.get(0).equals(getHost().getModel())) {//we are on the diagram
- descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(MetaclassEditPart.VISUAL_ID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
+ // we create the view command
+ if (containerView.get(0).equals(getHost().getModel())) {// we are on the diagram
+ descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) getUMLElementType(MetaclassEditPart.VISUAL_ID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
} else {
- descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType)getUMLElementType(MetaclassEditPartCN.VISUAL_ID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
+ descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) getUMLElementType(MetaclassEditPartCN.VISUAL_ID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint());
}
-
- CreateCommand createCommand = new CreateCommand(getEditingDomain(), descriptor, ((View)(getHost().getModel())));
+ CreateCommand createCommand = new CreateCommand(getEditingDomain(), descriptor, ((View) (getHost().getModel())));
cc.compose(createCommand);
-
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable)createCommand.getCommandResult().getReturnValue(), dropRequest.getLocation()); //$NON-NLS-1$
+ SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable) createCommand.getCommandResult().getReturnValue(), dropRequest.getLocation()); //$NON-NLS-1$
cc.compose(setBoundsCommand);
-
/*
* we set the stereotype <<metaclass>> visible
* we can not call AppliedStereotypeHelper.getAddAppliedStereotypeCommand here,
@@ -493,18 +402,16 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* null :
* the view is not yet created!!!
*/
- if(createCommand.canExecute()) {
- SetStereotypeVisibleOnMetaclassCommand stereotypeCommand = new SetStereotypeVisibleOnMetaclassCommand(getEditingDomain(), "Set Stereotype Visible", null, semanticLink, (ViewDescriptor)createCommand.getCommandResult().getReturnValue()); //$NON-NLS-1$
- if(stereotypeCommand.canExecute()) {
+ if (createCommand.canExecute()) {
+ SetStereotypeVisibleOnMetaclassCommand stereotypeCommand = new SetStereotypeVisibleOnMetaclassCommand(getEditingDomain(), "Set Stereotype Visible", null, semanticLink, (ViewDescriptor) createCommand.getCommandResult().getReturnValue()); //$NON-NLS-1$
+ if (stereotypeCommand.canExecute()) {
cc.add(stereotypeCommand);
}
}
return new ICommandProxy(cc);
}
}
-
return UnexecutableCommand.INSTANCE;
-
}
/**
@@ -514,80 +421,67 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* target views do not exist, these views will be created.
*
* @param cc
- * the composite command that will contain the set of command to create the binary
- * link
+ * the composite command that will contain the set of command to create the binary
+ * link
* @param source
- * the source the element source of the link
+ * the source the element source of the link
* @param target
- * the target the element target of the link
+ * the target the element target of the link
* @param linkVISUALID
- * the link VISUALID used to create the view
+ * the link VISUALID used to create the view
* @param location
- * the location the location where the view will be be created
+ * the location the location where the view will be be created
* @param semanticLink
- * the semantic link that will be attached to the view
+ * the semantic link that will be attached to the view
*
* @return the composite command
*/
public CompositeCommand dropBinaryLinkExtension(CompositeCommand cc, Element source, Element target, int linkVISUALID, Point location, Element semanticLink) {
// look for editpart
-
- GraphicalEditPart sourceEditPart = (GraphicalEditPart)lookForEditPartSource(source);
- GraphicalEditPart targetEditPart = (GraphicalEditPart)lookForEditPartTarget(target, semanticLink);
-
+ GraphicalEditPart sourceEditPart = (GraphicalEditPart) lookForEditPartSource(source);
+ GraphicalEditPart targetEditPart = (GraphicalEditPart) lookForEditPartTarget(target, semanticLink);
// descriptor of the link
- CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(getUMLElementType(linkVISUALID), ((IHintedType)getUMLElementType(linkVISUALID)).getSemanticHint(), getDiagramPreferencesHint());
-
+ CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(getUMLElementType(linkVISUALID), ((IHintedType) getUMLElementType(linkVISUALID)).getSemanticHint(),
+ getDiagramPreferencesHint());
IAdaptable sourceAdapter = null;
IAdaptable targetAdapter = null;
EList<Adapter> e = source.eAdapters();
-
- if(sourceEditPart == null) {
+ if (sourceEditPart == null) {
// creation of the node
- ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(source), Node.class, null, ViewUtil.APPEND, true, ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint());
-
+ ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(source), Node.class, null, ViewUtil.APPEND, true, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
// get the command and execute it.
- CreateCommand nodeCreationCommand = new CreateCommand(((IGraphicalEditPart)getHost()).getEditingDomain(), descriptor, ((View)getHost().getModel()));
+ CreateCommand nodeCreationCommand = new CreateCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), descriptor, ((View) getHost().getModel()));
cc.compose(nodeCreationCommand);
-
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable)nodeCreationCommand.getCommandResult().getReturnValue(), new Point(location.x, location.y + 100)); //$NON-NLS-1$
+ SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable) nodeCreationCommand.getCommandResult().getReturnValue(), new Point(location.x, location.y + 100)); //$NON-NLS-1$
cc.compose(setBoundsCommand);
-
-
- sourceAdapter = (IAdaptable)nodeCreationCommand.getCommandResult().getReturnValue();
+ sourceAdapter = (IAdaptable) nodeCreationCommand.getCommandResult().getReturnValue();
} else {
sourceAdapter = new SemanticAdapter(null, sourceEditPart.getModel());
}
- if(targetEditPart == null) {
+ if (targetEditPart == null) {
// creation of the node
- ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(target), Node.class, null, ViewUtil.APPEND, true, ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint());
-
+ ViewDescriptor descriptor = new ViewDescriptor(new EObjectAdapter(target), Node.class, null, ViewUtil.APPEND, true, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
// get the command and execute it.
- CreateCommand nodeCreationCommand = new CreateCommand(((IGraphicalEditPart)getHost()).getEditingDomain(), descriptor, ((View)getHost().getModel()));
+ CreateCommand nodeCreationCommand = new CreateCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), descriptor, ((View) getHost().getModel()));
cc.compose(nodeCreationCommand);
-
- SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable)nodeCreationCommand.getCommandResult().getReturnValue(), new Point(location.x, location.y - 100)); //$NON-NLS-1$
-
+ SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getEditingDomain(), "move", (IAdaptable) nodeCreationCommand.getCommandResult().getReturnValue(), new Point(location.x, location.y - 100)); //$NON-NLS-1$
cc.compose(setBoundsCommand);
- targetAdapter = (IAdaptable)nodeCreationCommand.getCommandResult().getReturnValue();
-
+ targetAdapter = (IAdaptable) nodeCreationCommand.getCommandResult().getReturnValue();
} else {
targetAdapter = new SemanticAdapter(null, targetEditPart.getModel());
}
-
- CommonDeferredCreateConnectionViewCommand aLinkCommand = new CommonDeferredCreateConnectionViewCommand(getEditingDomain(), ((IHintedType)getUMLElementType(linkVISUALID)).getSemanticHint(), sourceAdapter, targetAdapter, getViewer(), getDiagramPreferencesHint(), linkdescriptor, null);
+ CommonDeferredCreateConnectionViewCommand aLinkCommand = new CommonDeferredCreateConnectionViewCommand(getEditingDomain(), ((IHintedType) getUMLElementType(linkVISUALID)).getSemanticHint(), sourceAdapter, targetAdapter, getViewer(),
+ getDiagramPreferencesHint(), linkdescriptor, null);
aLinkCommand.setElement(semanticLink);
-
cc.compose(aLinkCommand);
return cc;
-
}
/**
* Look for editPart from its semantic.
*
* @param semantic
- * the semantic
+ * the semantic
*
* @return the edits the part or null if not found
*/
@@ -595,10 +489,9 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
Collection<EditPart> editPartSet = getHost().getViewer().getEditPartRegistry().values();
Iterator<EditPart> editPartIterator = editPartSet.iterator();
EditPart existedEditPart = null;
- while(editPartIterator.hasNext() && existedEditPart == null) {
+ while (editPartIterator.hasNext() && existedEditPart == null) {
EditPart currentEditPart = editPartIterator.next();
-
- if(isEditPartTypeAdapted(currentEditPart.getClass(), semantic.eClass()) && semantic.equals(((GraphicalEditPart)currentEditPart).resolveSemanticElement())) {
+ if (isEditPartTypeAdapted(currentEditPart.getClass(), semantic.eClass()) && semantic.equals(((GraphicalEditPart) currentEditPart).resolveSemanticElement())) {
existedEditPart = currentEditPart;
}
}
@@ -609,7 +502,7 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* Look for editPart from its semantic and its container.
*
* @param semantic
- * the semantic
+ * the semantic
*
* @return the edits the part or null if not found
*/
@@ -618,11 +511,10 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
Collection<EditPart> editPartSet2 = getTheFirstLevel(semanticLink);
Iterator<EditPart> editPartIterator = editPartSet.iterator();
EditPart existedEditPart = null;
-
- while(editPartIterator.hasNext() && existedEditPart == null) {
+ while (editPartIterator.hasNext() && existedEditPart == null) {
EditPart currentEditPart = editPartIterator.next();
- if(editPartSet2.contains(currentEditPart)) {
- if(isEditPartTypeAdapted(currentEditPart.getClass(), semantic.eClass()) && semantic.equals(((GraphicalEditPart)currentEditPart).resolveSemanticElement())) {
+ if (editPartSet2.contains(currentEditPart)) {
+ if (isEditPartTypeAdapted(currentEditPart.getClass(), semantic.eClass()) && semantic.equals(((GraphicalEditPart) currentEditPart).resolveSemanticElement())) {
existedEditPart = currentEditPart;
}
}
@@ -634,16 +526,16 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
* Check if the edit part type is the best one to represent an object of the given EClass type
*
* @param editPartClass
- * the type of EditPart which may represent a semantic element
+ * the type of EditPart which may represent a semantic element
* @param eClass
- * the EClass type of the represented semantic element
+ * the EClass type of the represented semantic element
* @return true if an edit part of this type should be selected
*/
private boolean isEditPartTypeAdapted(java.lang.Class<? extends EditPart> editPartClass, EClass eClass) {
- if(DiagramEditPart.class.isAssignableFrom(editPartClass) || CompartmentEditPart.class.isAssignableFrom(editPartClass)) {
+ if (DiagramEditPart.class.isAssignableFrom(editPartClass) || CompartmentEditPart.class.isAssignableFrom(editPartClass)) {
// the edit part is disqualified, as a compartment or a diagram can not be dropped
return false;
- } else if(GraphicalEditPart.class.isAssignableFrom(editPartClass)) {
+ } else if (GraphicalEditPart.class.isAssignableFrom(editPartClass)) {
// check the edit part type against advised ones
return isEditPartTypeSuitableForEClass(editPartClass.asSubclass(GraphicalEditPart.class), eClass);
} else {
@@ -653,36 +545,30 @@ public class ProfileDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEd
}
private Collection<EditPart> getTheFirstLevel(Element semanticLink) {
-
EObject linkContainer = semanticLink.eContainer();
EditPart currentEditPart = null;
Collection<EditPart> profileContents = new ArrayList<EditPart>();
-
Collection<EditPart> editPartSet = getHost().getViewer().getEditPartRegistry().values();
Iterator<EditPart> editPartIterator = editPartSet.iterator();
- //Je recherche les éléments qui ont le même parent que mon extension
- while(editPartIterator.hasNext()) {
+ // Je recherche les éléments qui ont le même parent que mon extension
+ while (editPartIterator.hasNext()) {
currentEditPart = editPartIterator.next();
- if(currentEditPart.getParent() != null) {
+ if (currentEditPart.getParent() != null) {
Object model = currentEditPart.getParent().getModel();
- if(model instanceof Node) {
- EObject parent = ((Node)model).getElement();
- if(parent.equals(linkContainer)) {
+ if (model instanceof Node) {
+ EObject parent = ((Node) model).getElement();
+ if (parent.equals(linkContainer)) {
profileContents.add(currentEditPart);
}
}
- if(model instanceof Diagram) {
- EObject parent = ((Diagram)model).getElement();
- if(parent.equals(linkContainer)) {
+ if (model instanceof Diagram) {
+ EObject parent = ((Diagram) model).getElement();
+ if (parent.equals(linkContainer)) {
profileContents.add(currentEditPart);
}
}
}
-
-
-
}
-
return profileContents;
}
}

Back to the top