Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Palette model and EditPart model?
Palette model and EditPart model? [message #146135] Tue, 03 August 2004 08:56 Go to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Hello!

A general question at the beginning:
Is it possible to have a model object stored in the palette?

If I select this model in the palette an "drag" it to my parent-figure
in the grahical editor I want to have a copy of this model object.

Is GEF designed to provide something for this action I want?

Else I tried to workaround this way:
I put a CreationTool to the palette with a name corresponding to something
like an ID to the model I want to have. When my CreateCommand becomes
executed, I get the selected Tool name from the palette and gets a model
copy from a list stored in my editor.

Is there a better way to do so?
Hope that's clear enough to understand.

Thanks in advance, Martin.
Re: Palette model and EditPart model? [message #146162 is a reply to message #146135] Tue, 03 August 2004 11:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: word-up.gmx.de

Hi,

the normal way is to register a factory for an entry in the palette which
creates the model objects.
So if you want to have a "copy" of a model object (btw, what do you mean
by a copy? a clone? a reference to the same object? or just another
instance of the model class?) your factory should return that "copy". Your
factory should implement the CreationFactory interface.


mastr wrote:

> Hello!

> A general question at the beginning:
> Is it possible to have a model object stored in the palette?

> If I select this model in the palette an "drag" it to my parent-figure
> in the grahical editor I want to have a copy of this model object.

> Is GEF designed to provide something for this action I want?

> Else I tried to workaround this way:
> I put a CreationTool to the palette with a name corresponding to something
> like an ID to the model I want to have. When my CreateCommand becomes
> executed, I get the selected Tool name from the palette and gets a model
> copy from a list stored in my editor.

> Is there a better way to do so?
> Hope that's clear enough to understand.

> Thanks in advance, Martin.
Re: Palette model and EditPart model? [message #146180 is a reply to message #146162] Tue, 03 August 2004 11:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Max wrote:

> So if you want to have a "copy" of a model object (btw, what do you mean
> by a copy? a clone? a reference to the same object? or just another
> instance of the model class?)...

I ment a clone not a new instance because I need the attributes of the
model object.

> ...your factory should return that "copy". Your
> factory should implement the CreationFactory interface.

My createPaletteRoot() method contains this:

entry = new DefaultPaletteToolEntry(
new CreationTool(
new CreateRequest.SimpleFactory(MyModel.class)),
b.getName(),
b.getDescription()
null,
null);
bundleEntries.add(entry);

So, if I implement my own "CreationFactory" I'm enabled to do this?:

MyModel model = new MyModel(attrib1, attrib2);
entry = new DefaultPaletteToolEntry(
new CreationTool(
new MyCreationFactory(model)),
b.getName(),
b.getDescription()
null,
null);
bundleEntries.add(entry);

and in MyLayoutEditPolicy implementation's method

protected Command getCreateCommand(CreateRequest request) {
...
MyModel model = (MyModel) request.getNewObject();
return new CreationCommand(parent, model);
}

I'll get this model object via getNewObject?

Thanks for your answer.
Re: Palette model and EditPart model? [message #146208 is a reply to message #146180] Tue, 03 August 2004 11:42 Go to previous message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

I tried it out and it works... thank you Max.
Previous Topic:MutilPageEditor & save
Next Topic:Problem with GraphicalEditorWithPalette
Goto Forum:
  


Current Time: Fri Apr 26 09:23:36 GMT 2024

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

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

Back to the top