CombinedTemplateCreationEntry and drag and drop from the palette [message #234021] |
Wed, 09 May 2007 19:44 |
Ian Leslie Messages: 137 Registered: July 2009 |
Senior Member |
|
|
I have done some searching in this forum but cannot quite piece together
and answer. I had a very simple tool palette with only a few items in it
which were all create-able using the default constructor. I used this
constructor for my CombinedTemplateCreationEntry objects:
CombinedTemplateCreationEntry(String label, String shortDesc, Object
template, CreationFactory factory, ImageDescriptor iconSmall,
ImageDescriptor iconLarge)
Where the template was the type of my object and the factory was a
SimpleFactory constructed with that same type.
Then I needed to add a few palette entries that required some information
for the constructor. But I found that this did not work as expected.
Selecting the tool and then clicking on the diagram produced the correct
results but drag and dropping created instances of the object that used
the default constructor. It seems that the click placement was using my
factory but the drag and drop was using createInstance from the type - my
factory was never called.
I found this thread
http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg1 3863.html
which looked promising. It sounded like I could switch to using this
constructor and my factory woudl get called:
CombinedTemplateCreationEntry(String label, String shortDesc,
CreationFactory factory, ImageDescriptor iconSmall, ImageDescriptor
iconLarge)
But this meant that now drag and drop from the tool palette is not
allowed. I suppose that is slightly better than creating the wrong thing.
Shouldn't the factory be called in all cases when an object is created
from the tool palette?
On a more pragmatic note: What is the right thing for me to do in order to
get drag and drop to work for all my tool palette entries? It seems from
re-reading the above forum post and a few others I found that one
possibility is to actually change my diagram to accept instances of the
factory to be dropped and then switch back to the
CombinedTemplateCreationEntry constructor and use the factory as the
template. Then when one gets dropped I can invoke the getNewObject
method. Would I be going down the right track? Are there any changes in
3.3 that I should be aware of? My application will not be GA until after
3.3 is ready so I am planning to switch to 3.3 before my application ships.
Any help or advice would be appreciated.
Ian
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03727 seconds