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
@Override
	public PictogramElement add(IAddContext context) {}

only returns one PictogramElement.

index.php/fa/22796/0/
  • Attachment: Capture.JPG
    (Size: 24.82KB, Downloaded 472 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
Member
Hi,
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:
	@Override
	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.setParentGraphicsAlgorithm(invisibleRectangle);
	    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});
	
	    updatePictogramElement(labelShape);
	    layoutPictogramElement(labelShape);
	    addInternalPorts(addedTask, containerShape);
	    updatePictogramElement(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: Tue Mar 19 10:41:18 GMT 2024

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

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

Back to the top