Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to get the result of a CreateElementCommand when doing Drag 'n Drop
How to get the result of a CreateElementCommand when doing Drag 'n Drop [message #244764] Wed, 06 August 2008 14:06 Go to next message
David Johnson is currently offline David JohnsonFriend
Messages: 10
Registered: July 2009
Junior Member
Hi everyone,

Apologies first as I've also posted this to the GMF group as I'm not sure
if it's a GEF problem or a GMF problem actually - most of my code is
generated with GMF, but from what I understand the custom DnD stuff is
GEF. Anyway...

I'm trying to do drag and drop from a tree view onto a diagram view,
where on drop I create a new EditPart. I've managed to do this by doing
something like:

CustomEditPart selectedElement = ( CustomEditPart )getHost();
IElementType type = CustomElementTypes.ICustomElement_2001;
ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor
( new CreateElementRequestAdapter( new CreateElementRequest( type ) ),
Node.class, ( ( IHintedType )type ).getSemanticHint(),
selectedElement.getDiagramPreferencesHint() );
cmd = selectedElement.getCommand( new CreateViewAndElementRequest
(viewDescriptor) );
return cmd;

inside my CustomDragDropEditPolicy.getDropObjectsCommand(). So on drop,
it calls the correct CustomCreateCommand.

However I want to populate the new EditPart's properties with some values
- so how do I get/select the newly created EditPart?

Any ideas and input will be greatly appreciated.

Cheers,
-David
Re: How to get the result of a CreateElementCommand when doing Drag 'n Drop [message #244789 is a reply to message #244764] Thu, 07 August 2008 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

David Johnson wrote:
> Hi everyone,
>
> Apologies first as I've also posted this to the GMF group as I'm not sure
> if it's a GEF problem or a GMF problem actually - most of my code is
> generated with GMF, but from what I understand the custom DnD stuff is
> GEF. Anyway...
>
> I'm trying to do drag and drop from a tree view onto a diagram view,
> where on drop I create a new EditPart. I've managed to do this by doing
> something like:
>
> CustomEditPart selectedElement = ( CustomEditPart )getHost();
> IElementType type = CustomElementTypes.ICustomElement_2001;
> ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor
> ( new CreateElementRequestAdapter( new CreateElementRequest( type ) ),
> Node.class, ( ( IHintedType )type ).getSemanticHint(),
> selectedElement.getDiagramPreferencesHint() );
> cmd = selectedElement.getCommand( new CreateViewAndElementRequest
> (viewDescriptor) );
> return cmd;
>
> inside my CustomDragDropEditPolicy.getDropObjectsCommand(). So on drop,
> it calls the correct CustomCreateCommand.
>
> However I want to populate the new EditPart's properties with some values
> - so how do I get/select the newly created EditPart?
>
> Any ideas and input will be greatly appreciated.
>
> Cheers,
> -David
Open type org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool, look at
it's method *performCreation*, you'll know how to retrieve new created
editpart.

method definiton:

protected void performCreation(int button) {

antiScroll = true;

EditPartViewer viewer = getCurrentViewer();
Command c = getCurrentCommand();
executeCurrentCommand();
selectAddedObject(viewer, DiagramCommandStack.getReturnValues(c));

antiScroll = false;
}
Re: How to get the result of a CreateElementCommand when doing Drag 'n Drop [message #244823 is a reply to message #244789] Fri, 08 August 2008 10:21 Go to previous messageGo to next message
David Johnson is currently offline David JohnsonFriend
Messages: 10
Registered: July 2009
Junior Member
Hi David,

OK, thanks for the help!

Regards,
-David

On Thu, 07 Aug 2008 22:08:45 +0800, David BY Chan wrote:

> David Johnson wrote:
>> Hi everyone,
>>
>> Apologies first as I've also posted this to the GMF group as I'm not
>> sure if it's a GEF problem or a GMF problem actually - most of my code
>> is generated with GMF, but from what I understand the custom DnD stuff
>> is GEF. Anyway...
>>
>> I'm trying to do drag and drop from a tree view onto a diagram view,
>> where on drop I create a new EditPart. I've managed to do this by doing
>> something like:
>>
>> CustomEditPart selectedElement = ( CustomEditPart )getHost();
>> IElementType type = CustomElementTypes.ICustomElement_2001;
>> ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor
>> ( new CreateElementRequestAdapter( new CreateElementRequest( type ) ),
>> Node.class, ( ( IHintedType )type ).getSemanticHint(),
>> selectedElement.getDiagramPreferencesHint() ); cmd =
>> selectedElement.getCommand( new CreateViewAndElementRequest
>> (viewDescriptor) );
>> return cmd;
>>
>> inside my CustomDragDropEditPolicy.getDropObjectsCommand(). So on drop,
>> it calls the correct CustomCreateCommand.
>>
>> However I want to populate the new EditPart's properties with some
>> values - so how do I get/select the newly created EditPart?
>>
>> Any ideas and input will be greatly appreciated.
>>
>> Cheers,
>> -David
> Open type org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool, look at
> it's method *performCreation*, you'll know how to retrieve new created
> editpart.
>
> method definiton:
>
> protected void performCreation(int button) {
>
> antiScroll = true;
>
> EditPartViewer viewer = getCurrentViewer(); Command c =
> getCurrentCommand();
> executeCurrentCommand();
> selectAddedObject(viewer,
DiagramCommandStack.getReturnValues(c));
>
> antiScroll = false;
> }
Re: How to get the result of a CreateElementCommand when doing Drag 'n Drop [message #245815 is a reply to message #244823] Wed, 15 October 2008 06:58 Go to previous message
Eclipse UserFriend
Originally posted by: manojm.blr.interrasystems.com

Hi!

I am also facing the same kind of problem.
Is it solved at your end?

Please help me by your suggestion.
I would be very much thankful, if you could help with some code snippet.

Regards,
Manoj

David Johnson wrote:
> Hi David,
>
> OK, thanks for the help!
>
> Regards,
> -David
>
> On Thu, 07 Aug 2008 22:08:45 +0800, David BY Chan wrote:
>
>
>>David Johnson wrote:
>>
>>>Hi everyone,
>>>
>>>Apologies first as I've also posted this to the GMF group as I'm not
>>>sure if it's a GEF problem or a GMF problem actually - most of my code
>>>is generated with GMF, but from what I understand the custom DnD stuff
>>>is GEF. Anyway...
>>>
>>>I'm trying to do drag and drop from a tree view onto a diagram view,
>>>where on drop I create a new EditPart. I've managed to do this by doing
>>>something like:
>>>
>>>CustomEditPart selectedElement = ( CustomEditPart )getHost();
>>>IElementType type = CustomElementTypes.ICustomElement_2001;
>>>ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor
>>>( new CreateElementRequestAdapter( new CreateElementRequest( type ) ),
>>>Node.class, ( ( IHintedType )type ).getSemanticHint(),
>>>selectedElement.getDiagramPreferencesHint() ); cmd =
>>>selectedElement.getCommand( new CreateViewAndElementRequest
>>>(viewDescriptor) );
>>>return cmd;
>>>
>>>inside my CustomDragDropEditPolicy.getDropObjectsCommand(). So on drop,
>>>it calls the correct CustomCreateCommand.
>>>
>>>However I want to populate the new EditPart's properties with some
>>>values - so how do I get/select the newly created EditPart?
>>>
>>>Any ideas and input will be greatly appreciated.
>>>
>>>Cheers,
>>>-David
>>
>>Open type org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool, look at
>>it's method *performCreation*, you'll know how to retrieve new created
>>editpart.
>>
>>method definiton:
>>
>>protected void performCreation(int button) {
>>
>> antiScroll = true;
>>
>> EditPartViewer viewer = getCurrentViewer(); Command c =
>> getCurrentCommand();
>> executeCurrentCommand();
>> selectAddedObject(viewer,
>
> DiagramCommandStack.getReturnValues(c));
>
>>
>> antiScroll = false;
>> }
>
>
Previous Topic:Embedded Editor state of the art question
Next Topic:[Announce] GEF 3.5.0 I200810141852 is available
Goto Forum:
  


Current Time: Thu Sep 19 02:37:07 GMT 2024

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

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

Back to the top