Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » CreateFeature in Context Pad Button
CreateFeature in Context Pad Button [message #641095] Wed, 24 November 2010 09:25 Go to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
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 #641617 is a reply to message #641095] Fri, 26 November 2010 10:34 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You can use CreateFeatures in the context buttons (add them to the data
object returned in the tool behavior provider method getContextButtonPad)
just as it is done in the tutorial for custom features. To enable the
entries the context object passed into the constructur of the
ContextButtonEntry must be of type CreateContext.

Hope that helps.

Michael


"Murthy" <murthybhat@gmail.com> wrote in message
news:icilev$ake$1@news.eclipse.org...
> 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 07:00 Go to previous message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
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
Previous Topic:Shape hierarchies and rendering
Next Topic:Info needed on Model philosophies in GRAPHITI
Goto Forum:
  


Current Time: Sat Apr 27 02:07:39 GMT 2024

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

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

Back to the top