Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Help Moving Shapes(How can i move a shape inside another)
Help Moving Shapes [message #1111587] Wed, 18 September 2013 12:25 Go to next message
Victor Lopez is currently offline Victor LopezFriend
Messages: 21
Registered: August 2013
Junior Member
Hello everybody,

I am pretty new to this framework. I have done the tutorial and ok, i know more or less how does it works. But now that i want to do some more i dont know how to.

I wanted to move one shape into another (like drop one rectange and then drop anotherone inside of it) and it is not explained in the tutorial and I could not find other clear things on the internet. i would really appreciate your help.

package org.eclipse.graphiti.examples.tutorial.features;
 
public class TutorialMoveEClassFeature extends DefaultMoveShapeFeature {
 
    public TutorialMoveEClassFeature(IFeatureProvider fp) {
        super(fp);
    }
 
    @Override
    public boolean canMoveShape(IMoveShapeContext context) {
        boolean canMove = super.canMoveShape(context);
 
        // perform further check only if move allowed by default feature
        if (canMove) {
            // don't allow move if the class name has the length of 1
            Shape shape = context.getShape();
            Object bo = getBusinessObjectForPictogramElement(shape);
            if (bo instanceof EClass) {
                EClass c = (EClass) bo;
                if (c.getName() != null && c.getName().length() == 1) {
                    canMove = false;
                }
            }
        }
        return canMove;
    }
}


This is what I gor from tutorial just in case someone wants to write something in the middle.

Thank you in advance,

-->Vic.
Re: Help Moving Shapes [message #1113010 is a reply to message #1111587] Fri, 20 September 2013 14:09 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Victor,

basically the super class DefaultMoveShapeFeature does what you need (see
internalMove()). The trick is simply to change the parent of the moved
shape.

Michael
Previous Topic:Undo a feature
Next Topic:Diagram background with gradient colors
Goto Forum:
  


Current Time: Thu Apr 25 14:28:10 GMT 2024

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

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

Back to the top