Skip to main content



      Home
Home » Modeling » Graphiti » dynamical CreateFeatures ?
dynamical CreateFeatures ? [message #710172] Thu, 04 August 2011 15:27 Go to next message
Eclipse UserFriend
Motivation: in the Graphiti tutorial in the Help, the creation of each object (Eclass) corresponds to a (say) MyCreateFeature class, there is a single class, and a single instance of this class, and a single create icon in the palette; and the "name" of each create object is filled by the user in a creation popup. Suppose that, in addition to that, I wish to have some feature to create some set of Eclass objects with some predetermined names

I'd wish to avoid to code a separate CreateFeature class for each case.
I wonder, if, for example, I could add some "name" property to my MyCreateFeature class, and create several instances of this class to return them in my MyFeatureProvider.getCreateFeatures() , so that each instance would have a different behaviour. Would this be impossible, or convoluted?

In particular, it's not clear for me which is the contract of the IFeatureProvider.getCreateFeatures() method: when is this -internally- called? Only for the palette? Must this be in sync with the palette? Can I have several instances of the same class?

Another issue (more difficult, I guess) would be to make those instances dynamic; for what I see, the contents of the palette MyToolBehaviorProvider.getPalette() seems to be static, is that so?

[Updated on: Thu, 04 August 2011 15:29] by Moderator

Re: dynamical CreateFeatures ? [message #710222 is a reply to message #710172] Thu, 04 August 2011 16:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hernan,

the palette is build up in the DefaultToolBehaviorProvider.getPalette method. There is the access to the create features provided by the feature provider:

ICreateFeature[] createFeatures = featureProvider.getCreateFeatures();

for (ICreateFeature createFeature : createFeatures) {
   ObjectCreationToolEntry objectCreationToolEntry = new ObjectCreationToolEntry(createFeature.getCreateName(),
   createFeature.getCreateDescription(), createFeature.getCreateImageId(), createFeature.getCreateLargeImageId(), createFeature);

   compartmentEntry.addToolEntry(objectCreationToolEntry);
}


You can override that method in your own tool behavior provider to inject your parameterized create feature instances.

The call chain is
DiagramEditorInternal.refreshPalette()
-> GFPaletteRoot .updatePaletteEntries()
-> IToolBehaviorProvider.getPalette()

So you can get trigger the refresh of the palette by calling getDiagramEditor().refreshPalette(), as getDiagramEditor() is defined in AbstractFeature and so available in every feature class.

Cheers
Joerg
Re: dynamical CreateFeatures ? [message #710362 is a reply to message #710222] Thu, 04 August 2011 20:07 Go to previous message
Eclipse UserFriend
Great, thanks.
Previous Topic:Connection onMouseOver?
Next Topic:Setting own file extension for Graphiti Diagram
Goto Forum:
  


Current Time: Tue Jul 22 19:01:50 EDT 2025

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

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

Back to the top