Bug 434493 - [ComponentDiagram] copy & pasted ports apply in on (root)model cant be deleted
Summary: [ComponentDiagram] copy & pasted ports apply in on (root)model cant be deleted
Status: UNCONFIRMED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Diagram (show other bugs)
Version: 0.10.2   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-09 08:52 EDT by Rudolf Schneider CLA
Modified: 2017-08-02 11:39 EDT (History)
3 users (show)

See Also:


Attachments
Screenshot of the model explorer and the model (32.54 KB, application/zip)
2014-05-13 09:48 EDT, Rudolf Schneider CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rudolf Schneider CLA 2014-05-09 08:52:39 EDT
If you add a port to an component and then copy & paste it, it appears on the (root) model. It is not possible to delete this port from the model.

1. add a component to a model
2. add a port to the component
3. select the port element
4. press cmd+c or strg+c to copy it to clipboard
5. press cmd+v or strg+v to paste it.

The port element cant be deleted and the model is invalid.

The port element should bei deleteable.
Comment 1 Benoit Maggi CLA 2014-05-13 09:26:34 EDT
it's working fine on the nightly build.

Can you attach a screenshot of your model explorer?
Or best the corrupted model ?
Comment 2 Rudolf Schneider CLA 2014-05-13 09:48:57 EDT
Created attachment 243027 [details]
Screenshot of the model explorer and the model
Comment 3 Benoit Maggi CLA 2014-05-13 10:39:25 EDT
This code (at the end) forbid your action.
Since the graphical port is not in the graphical element of his semantic parent, 
you can not delete it. 

You can "hide" it(remove only the graphical part)


org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.CustomPortItemSemanticEditPolicy

	/**
	 * <pre>
	 * Forbid direct destruction of Port in case the graphical parent is not
	 * the semantic parent.  
	 * 
	 * {@inheritDoc}
	 * </pre>
	 */
	@Override
	protected Command getDestroyElementCommand(DestroyElementRequest req) {

		EObject graphicalParent = ((GraphicalEditPart)getHost().getParent()).resolveSemanticElement();
		EObject semanticParent = req.getElementToDestroy().eContainer();

		if(graphicalParent != semanticParent) {
			return UnexecutableCommand.INSTANCE;
		}

		return super.getDestroyElementCommand(req);
	}