Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » dynamical CreateFeatures ?
dynamical CreateFeatures ? [message #710172] Thu, 04 August 2011 19:27 Go to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
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 19:29]

Report message to a moderator

Re: dynamical CreateFeatures ? [message #710222 is a reply to message #710172] Thu, 04 August 2011 20:40 Go to previous messageGo to next message
Joerg Reichert is currently offline Joerg ReichertFriend
Messages: 80
Registered: July 2009
Location: Leipzig
Member
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


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Re: dynamical CreateFeatures ? [message #710362 is a reply to message #710222] Fri, 05 August 2011 00:07 Go to previous message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Great, thanks.
Previous Topic:Connection onMouseOver?
Next Topic:Setting own file extension for Graphiti Diagram
Goto Forum:
  


Current Time: Fri Apr 19 15:17:46 GMT 2024

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

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

Back to the top