Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Drag and Drop Multiple Pictogram elements from the Palette
Drag and Drop Multiple Pictogram elements from the Palette [message #1703887] Wed, 05 August 2015 15:41 Go to next message
Mike Sherry is currently offline Mike SherryFriend
Messages: 3
Registered: May 2015
Junior Member
I have created custom Objects in the palette that can drag and drop individual pictogram elements using a class that extends AbstractAddFeature. What I would like to know if it is possible to drag and drop an item from the palette that contains multiple pictogram elements, such as task1, task2 and a connection between them? I cannot do this with my class from above since
	public PictogramElement add(IAddContext context) {}

only returns one PictogramElement.

  • Attachment: Capture.JPG
    (Size: 24.82KB, Downloaded 475 times)
Re: Drag and Drop Multiple Pictogram elements from the Palette [message #1703922 is a reply to message #1703887] Wed, 05 August 2015 20:42 Go to previous message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
In my editor I am adding rectangle with associated label that are separate pictogram elements. However they are both linked to the same business object and more linked to each other.
Please look at example from my code:
	public PictogramElement add(IAddContext context) {
	    final Task addedTask = (Task) context.getNewObject();
	    final ContainerShape target = context.getTargetContainer();

	    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
	    final IGaService       gaService       = Graphiti.getGaService();
	    final ContainerShape containerShape = peCreateService.createContainerShape(target, true);

	    int width = 0;
	    int height = 0;
	    width  = context.getWidth()  <= 0 ? getWidth()  : context.getWidth();
	    height = context.getHeight() <= 0 ? getHeight() : context.getHeight();

	    final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
	    gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width, height);

	    // create and set visible rectangle inside invisible rectangle
	    RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 20, 20);
	    roundedRectangle.setStyle(addedTask.isOnlyLocal() ? onlyLocalStyle : getStyle());
	    if(!addedTask.isAtomic()) roundedRectangle.setLineStyle(LineStyle.DOT);
	    gaService.setLocationAndSize(roundedRectangle, 0, 0, width, height);

	    insertInside(peCreateService, gaService, width, height, containerShape, invisibleRectangle, addedTask);
	    ContainerShape labelShape = addLabel(target, addedTask.getId(), width, height, context.getX(), context.getY());
	    link(containerShape, new Object[] {addedTask, labelShape});
	    link(labelShape, new Object[] {addedTask, containerShape});
	    addInternalPorts(addedTask, containerShape);
	    return containerShape;

I think that linking or making somehow relation between pictogram elements should be enough.

[Updated on: Wed, 05 August 2015 20:49]

Report message to a moderator

Previous Topic:Adding gestures in Graphiti
Next Topic:NPE after upgrading to eclipse mars
Goto Forum:

Current Time: Mon Apr 22 00:13:58 GMT 2024

Powered by FUDForum. Page generated in 0.03037 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top