CreateFeature in Context Pad Button [message #641095] |
Wed, 24 November 2010 04:25  |
Eclipse User |
|
|
|
Hello,
I am trying to develop using GRAPHITI a diagram editor which looks like a class diagram editor. It has options to create classes, references and addition of attribute and methods.
I wanted to have the addition of attributes and methods using the contextpadbuttons. I am able to get it in the menu, but when i now trying to invoke the create method on button is click, it is unable to do so. Could anyone please help me out here. Do i have to create a CustomFeature for adding or could achieve I the same using the Create feature.
Thanks in advance for help.
Regards,
Murthy
|
|
|
|
Re: CreateFeature in Context Pad Button [message #642154 is a reply to message #641617] |
Tue, 30 November 2010 02:00  |
Eclipse User |
|
|
|
Thanks Michael.
I was able to get it done with a little modification. Firstly I added my create feature as a custom feature. In the feature implementation's execute method, I had to create a CreateContext out of Customcontext as below.
@Override
public void execute(final IContext context) {
if (context instanceof ICreateContext) {
create((ICreateContext) context);
} else {
final CustomContext customContext = (CustomContext) context;
CreateContext createContext = new CreateContext();
PictogramElement[] picElements = customContext.getPictogramElements();
//Assuming picElements[0] is the container
createContext.setTargetContainer((ContainerShape) picElements[0]);
//making the absolute location point relative to the container
createContext.setLocation(customContext.getX()-createContext .getTargetContainer().getGraphicsAlgorithm().getX(),customCo ntext.getY()-createContext.getTargetContainer().getGraphicsA lgorithm().getY());
create(createContext);
}
}
Thanks,
Murthy
|
|
|
Powered by
FUDForum. Page generated in 0.05442 seconds