Home » Modeling » GMF (Graphical Modeling Framework) » how to create programmatically a note attachment
| | | |
Re: how to create programmatically a note attachment [message #34758 is a reply to message #34419] |
Wed, 30 August 2006 12:39   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Here's an example of how to create the note when you create an element.
Modify the CreationEditPolicy for the editPart corresponding to that
element type.
Maybe someone else can suggest how to add the edge.
vlad
protected Command getCreateCommand(CreateViewRequest request) {
IElementType NOTE = ElementTypeRegistry
.getInstance()
.getType(
"org.eclipse.gmf.runtime.diagram.ui.presentation.note");
ICommand createElementViewCommand = ((ICommandProxy) super
.getCreateCommand(request)).getICommand();
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
.getEditingDomain();
CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
editingDomain,
DiagramUIMessages.AddCommand_Label);
cc.compose(createElementViewCommand);
CreateViewRequest createNoteRequest = CreateViewRequestFactory
.getCreateShapeRequest(
NOTE,
PreferencesHint.USE_DEFAULTS);
Iterator descriptors = createNoteRequest
.getViewDescriptors().iterator();
while (descriptors.hasNext()) {
CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
.next();
CreateCommand createCommand = new CreateCommand(
editingDomain, descriptor,
((View) (getHost().getModel()))
.getDiagram());
cc.compose(createCommand);
}
return new ICommandProxy(cc.reduce());
}
On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
> One idea is to override the method
> protected Command getCreateCommand(CreateViewRequest request) in
> CreationEditPolicy
>
> This method is responsible for creating the view for the new element. You
> should compose this command with another that creates the views for the
> Note and the connection.
>
> To see how to create a note take a look at NoteViewFactory.
>
> You can figure a lot about how this is done by setting breakpoints in
> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
> Attachment tool.
>
> vlad
>
>
>
>
>
>
>
>
>
> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>
>> Cherie,
>> thanks for your answer.
>> My aim is to create a note attachment when a new element is drawn in the
>> diagram between the new element and an existing one.
>> How could I reuse the AddNoteAction?
>> Best regards
>>
>> michele
>>
>> Cherie Mahoney ha scritto:
>>> Michele,
>>>
>>> The answer depends on where the code is called to create the new element in
>>> your diagram. There is an AddNoteAction in GMF that creates a new note and
>>> draws a note attachment to the element from which the action was executed.
>>> If you are doing something similar to this, you could probably reuse this
>>> code.
>>>
>>> - Cherie
>>>
>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>> Hi all
>>>> I need to create programmatically a note attachment when I create an
>>>> element in my diagram.
>>>> How can I do?
>>>> Thanks
>>>>
>>>> Michele
>>>
>>>
|
|
|
Re: how to create programmatically a note attachment [message #35109 is a reply to message #34758] |
Thu, 31 August 2006 04:18   |
Eclipse User |
|
|
|
Vlad
thanks so much for your help...I will try that...
regards
michele
Vlad Ciubotariu ha scritto:
> Here's an example of how to create the note when you create an element.
> Modify the CreationEditPolicy for the editPart corresponding to that
> element type.
>
> Maybe someone else can suggest how to add the edge.
>
> vlad
>
> protected Command getCreateCommand(CreateViewRequest request) {
>
> IElementType NOTE = ElementTypeRegistry
> .getInstance()
> .getType(
> "org.eclipse.gmf.runtime.diagram.ui.presentation.note");
>
> ICommand createElementViewCommand = ((ICommandProxy) super
> .getCreateCommand(request)).getICommand();
>
> TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
> .getEditingDomain();
>
> CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
> editingDomain,
> DiagramUIMessages.AddCommand_Label);
>
> cc.compose(createElementViewCommand);
>
> CreateViewRequest createNoteRequest = CreateViewRequestFactory
> .getCreateShapeRequest(
> NOTE,
> PreferencesHint.USE_DEFAULTS);
>
> Iterator descriptors = createNoteRequest
> .getViewDescriptors().iterator();
>
> while (descriptors.hasNext()) {
> CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
> .next();
>
> CreateCommand createCommand = new CreateCommand(
> editingDomain, descriptor,
> ((View) (getHost().getModel()))
> .getDiagram());
>
> cc.compose(createCommand);
> }
>
> return new ICommandProxy(cc.reduce());
>
> }
>
> On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
>
>> One idea is to override the method
>> protected Command getCreateCommand(CreateViewRequest request) in
>> CreationEditPolicy
>>
>> This method is responsible for creating the view for the new element. You
>> should compose this command with another that creates the views for the
>> Note and the connection.
>>
>> To see how to create a note take a look at NoteViewFactory.
>>
>> You can figure a lot about how this is done by setting breakpoints in
>> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
>> Attachment tool.
>>
>> vlad
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>>
>>> Cherie,
>>> thanks for your answer.
>>> My aim is to create a note attachment when a new element is drawn in the
>>> diagram between the new element and an existing one.
>>> How could I reuse the AddNoteAction?
>>> Best regards
>>>
>>> michele
>>>
>>> Cherie Mahoney ha scritto:
>>>> Michele,
>>>>
>>>> The answer depends on where the code is called to create the new element in
>>>> your diagram. There is an AddNoteAction in GMF that creates a new note and
>>>> draws a note attachment to the element from which the action was executed.
>>>> If you are doing something similar to this, you could probably reuse this
>>>> code.
>>>>
>>>> - Cherie
>>>>
>>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>>> Hi all
>>>>> I need to create programmatically a note attachment when I create an
>>>>> element in my diagram.
>>>>> How can I do?
>>>>> Thanks
>>>>>
>>>>> Michele
>>>>
>
|
|
|
Re: how to create programmatically a note attachment [message #36819 is a reply to message #34758] |
Fri, 01 September 2006 09:12   |
Eclipse User |
|
|
|
Hi Vlad
I override the getCreateCommand(CreateViewRequest request) in
CrationEditPolicy as you suggested but...I can't understand when this
method is called...
Sorry but I have never use Command so maybe I ignore some basically
concept? Can you give me some other suggestions?
Thanks in advance
michele
Vlad Ciubotariu ha scritto:
> Here's an example of how to create the note when you create an element.
> Modify the CreationEditPolicy for the editPart corresponding to that
> element type.
>
> Maybe someone else can suggest how to add the edge.
>
> vlad
>
> protected Command getCreateCommand(CreateViewRequest request) {
>
> IElementType NOTE = ElementTypeRegistry
> .getInstance()
> .getType(
> "org.eclipse.gmf.runtime.diagram.ui.presentation.note");
>
> ICommand createElementViewCommand = ((ICommandProxy) super
> .getCreateCommand(request)).getICommand();
>
> TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
> .getEditingDomain();
>
> CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
> editingDomain,
> DiagramUIMessages.AddCommand_Label);
>
> cc.compose(createElementViewCommand);
>
> CreateViewRequest createNoteRequest = CreateViewRequestFactory
> .getCreateShapeRequest(
> NOTE,
> PreferencesHint.USE_DEFAULTS);
>
> Iterator descriptors = createNoteRequest
> .getViewDescriptors().iterator();
>
> while (descriptors.hasNext()) {
> CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
> .next();
>
> CreateCommand createCommand = new CreateCommand(
> editingDomain, descriptor,
> ((View) (getHost().getModel()))
> .getDiagram());
>
> cc.compose(createCommand);
> }
>
> return new ICommandProxy(cc.reduce());
>
> }
>
> On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
>
>> One idea is to override the method
>> protected Command getCreateCommand(CreateViewRequest request) in
>> CreationEditPolicy
>>
>> This method is responsible for creating the view for the new element. You
>> should compose this command with another that creates the views for the
>> Note and the connection.
>>
>> To see how to create a note take a look at NoteViewFactory.
>>
>> You can figure a lot about how this is done by setting breakpoints in
>> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
>> Attachment tool.
>>
>> vlad
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>>
>>> Cherie,
>>> thanks for your answer.
>>> My aim is to create a note attachment when a new element is drawn in the
>>> diagram between the new element and an existing one.
>>> How could I reuse the AddNoteAction?
>>> Best regards
>>>
>>> michele
>>>
>>> Cherie Mahoney ha scritto:
>>>> Michele,
>>>>
>>>> The answer depends on where the code is called to create the new element in
>>>> your diagram. There is an AddNoteAction in GMF that creates a new note and
>>>> draws a note attachment to the element from which the action was executed.
>>>> If you are doing something similar to this, you could probably reuse this
>>>> code.
>>>>
>>>> - Cherie
>>>>
>>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>>> Hi all
>>>>> I need to create programmatically a note attachment when I create an
>>>>> element in my diagram.
>>>>> How can I do?
>>>>> Thanks
>>>>>
>>>>> Michele
>>>>
>
|
|
|
Re: how to create programmatically a note attachment [message #37092 is a reply to message #36819] |
Fri, 01 September 2006 13:03   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Nessun problema :)
The edit part corresponding to the element you need to create, must
install your modified EditPolicy as follows:
protected void createDefaultEditPolicies() {
installEditPolicy(EditPolicyRoles.CREATION_ROLE,
new CreationEditPolicy() {
......
}
The anonymous class overrides
protected Command getCreateCommand(CreateViewRequest request)
This method is called in the super class when it creates the view for a
newly create element.
Spero che funzioni. Altrimenti mandammi un messagio a
vlad@swen.uwaterloo.ca includendo il source code ...
vlad
On Fri, 01 Sep 2006 15:12:11 +0200, Michele Puccio wrote:
> Hi Vlad
> I override the getCreateCommand(CreateViewRequest request) in
> CrationEditPolicy as you suggested but...I can't understand when this
> method is called...
> Sorry but I have never use Command so maybe I ignore some basically
> concept? Can you give me some other suggestions?
> Thanks in advance
>
> michele
>
>
> Vlad Ciubotariu ha scritto:
>> Here's an example of how to create the note when you create an element.
>> Modify the CreationEditPolicy for the editPart corresponding to that
>> element type.
>>
>> Maybe someone else can suggest how to add the edge.
>>
>> vlad
>>
>> protected Command getCreateCommand(CreateViewRequest request) {
>>
>> IElementType NOTE = ElementTypeRegistry
>> .getInstance()
>> .getType(
>> "org.eclipse.gmf.runtime.diagram.ui.presentation.note");
>>
>> ICommand createElementViewCommand = ((ICommandProxy) super
>> .getCreateCommand(request)).getICommand();
>>
>> TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
>> .getEditingDomain();
>>
>> CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
>> editingDomain,
>> DiagramUIMessages.AddCommand_Label);
>>
>> cc.compose(createElementViewCommand);
>>
>> CreateViewRequest createNoteRequest = CreateViewRequestFactory
>> .getCreateShapeRequest(
>> NOTE,
>> PreferencesHint.USE_DEFAULTS);
>>
>> Iterator descriptors = createNoteRequest
>> .getViewDescriptors().iterator();
>>
>> while (descriptors.hasNext()) {
>> CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
>> .next();
>>
>> CreateCommand createCommand = new CreateCommand(
>> editingDomain, descriptor,
>> ((View) (getHost().getModel()))
>> .getDiagram());
>>
>> cc.compose(createCommand);
>> }
>>
>> return new ICommandProxy(cc.reduce());
>>
>> }
>>
>> On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
>>
>>> One idea is to override the method
>>> protected Command getCreateCommand(CreateViewRequest request) in
>>> CreationEditPolicy
>>>
>>> This method is responsible for creating the view for the new element. You
>>> should compose this command with another that creates the views for the
>>> Note and the connection.
>>>
>>> To see how to create a note take a look at NoteViewFactory.
>>>
>>> You can figure a lot about how this is done by setting breakpoints in
>>> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
>>> Attachment tool.
>>>
>>> vlad
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>>>
>>>> Cherie,
>>>> thanks for your answer.
>>>> My aim is to create a note attachment when a new element is drawn in the
>>>> diagram between the new element and an existing one.
>>>> How could I reuse the AddNoteAction?
>>>> Best regards
>>>>
>>>> michele
>>>>
>>>> Cherie Mahoney ha scritto:
>>>>> Michele,
>>>>>
>>>>> The answer depends on where the code is called to create the new element in
>>>>> your diagram. There is an AddNoteAction in GMF that creates a new note and
>>>>> draws a note attachment to the element from which the action was executed.
>>>>> If you are doing something similar to this, you could probably reuse this
>>>>> code.
>>>>>
>>>>> - Cherie
>>>>>
>>>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>>>> Hi all
>>>>>> I need to create programmatically a note attachment when I create an
>>>>>> element in my diagram.
>>>>>> How can I do?
>>>>>> Thanks
>>>>>>
>>>>>> Michele
>>>>>
>>
|
|
|
Re: how to create programmatically a note attachment [message #174339 is a reply to message #34758] |
Tue, 26 February 2008 08:57   |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
This approach doesn't seem to work with the current version of GMF.
Does anyone know how a note can be added programmaticaly now?
Cheers,
Tomas Zijdemans
Vlad Ciubotariu wrote:
> Here's an example of how to create the note when you create an element.
> Modify the CreationEditPolicy for the editPart corresponding to that
> element type.
>
> Maybe someone else can suggest how to add the edge.
>
> vlad
>
> protected Command getCreateCommand(CreateViewRequest request) {
>
> IElementType NOTE = ElementTypeRegistry
> .getInstance()
> .getType(
> "org.eclipse.gmf.runtime.diagram.ui.presentation.note");
>
> ICommand createElementViewCommand = ((ICommandProxy) super
> .getCreateCommand(request)).getICommand();
>
> TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
> .getEditingDomain();
>
> CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
> editingDomain,
> DiagramUIMessages.AddCommand_Label);
>
> cc.compose(createElementViewCommand);
>
> CreateViewRequest createNoteRequest = CreateViewRequestFactory
> .getCreateShapeRequest(
> NOTE,
> PreferencesHint.USE_DEFAULTS);
>
> Iterator descriptors = createNoteRequest
> .getViewDescriptors().iterator();
>
> while (descriptors.hasNext()) {
> CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
> .next();
>
> CreateCommand createCommand = new CreateCommand(
> editingDomain, descriptor,
> ((View) (getHost().getModel()))
> .getDiagram());
>
> cc.compose(createCommand);
> }
>
> return new ICommandProxy(cc.reduce());
>
> }
>
> On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
>
>> One idea is to override the method
>> protected Command getCreateCommand(CreateViewRequest request) in
>> CreationEditPolicy
>>
>> This method is responsible for creating the view for the new element. You
>> should compose this command with another that creates the views for the
>> Note and the connection.
>>
>> To see how to create a note take a look at NoteViewFactory.
>>
>> You can figure a lot about how this is done by setting breakpoints in
>> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
>> Attachment tool.
>>
>> vlad
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>>
>>> Cherie,
>>> thanks for your answer.
>>> My aim is to create a note attachment when a new element is drawn in the
>>> diagram between the new element and an existing one.
>>> How could I reuse the AddNoteAction?
>>> Best regards
>>>
>>> michele
>>>
>>> Cherie Mahoney ha scritto:
>>>> Michele,
>>>>
>>>> The answer depends on where the code is called to create the new element in
>>>> your diagram. There is an AddNoteAction in GMF that creates a new note and
>>>> draws a note attachment to the element from which the action was executed.
>>>> If you are doing something similar to this, you could probably reuse this
>>>> code.
>>>>
>>>> - Cherie
>>>>
>>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>>> Hi all
>>>>> I need to create programmatically a note attachment when I create an
>>>>> element in my diagram.
>>>>> How can I do?
>>>>> Thanks
>>>>>
>>>>> Michele
>>>>
>
|
|
|
Re: how to create programmatically a note attachment [message #175370 is a reply to message #174339] |
Tue, 04 March 2008 04:01  |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
I still haven't solved this...
Any tips appreciated :)
Cheers,
Tomas Zijdemans
Tomas Zijdemans wrote:
> This approach doesn't seem to work with the current version of GMF.
>
> Does anyone know how a note can be added programmaticaly now?
>
>
> Cheers,
>
> Tomas Zijdemans
>
>
> Vlad Ciubotariu wrote:
>> Here's an example of how to create the note when you create an element.
>> Modify the CreationEditPolicy for the editPart corresponding to that
>> element type.
>>
>> Maybe someone else can suggest how to add the edge.
>>
>> vlad
>>
>> protected Command getCreateCommand(CreateViewRequest request) {
>>
>> IElementType NOTE = ElementTypeRegistry
>> .getInstance()
>> .getType(
>>
>> "org.eclipse.gmf.runtime.diagram.ui.presentation.note");
>>
>> ICommand createElementViewCommand = ((ICommandProxy) super
>> .getCreateCommand(request)).getICommand();
>>
>> TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)
>> getHost())
>> .getEditingDomain();
>>
>> CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
>> editingDomain,
>> DiagramUIMessages.AddCommand_Label);
>>
>> cc.compose(createElementViewCommand);
>>
>> CreateViewRequest createNoteRequest = CreateViewRequestFactory
>> .getCreateShapeRequest(
>> NOTE,
>> PreferencesHint.USE_DEFAULTS);
>>
>> Iterator descriptors = createNoteRequest
>> .getViewDescriptors().iterator();
>>
>> while (descriptors.hasNext()) {
>> CreateViewRequest.ViewDescriptor descriptor =
>> (CreateViewRequest.ViewDescriptor) descriptors
>> .next();
>>
>> CreateCommand createCommand = new CreateCommand(
>> editingDomain, descriptor,
>> ((View) (getHost().getModel()))
>> .getDiagram());
>>
>> cc.compose(createCommand);
>> }
>>
>> return new ICommandProxy(cc.reduce());
>>
>> }
>>
>> On Wed, 30 Aug 2006 10:55:59 -0400, Vlad Ciubotariu wrote:
>>
>>> One idea is to override the method protected Command
>>> getCreateCommand(CreateViewRequest request) in
>>> CreationEditPolicy
>>>
>>> This method is responsible for creating the view for the new element.
>>> You
>>> should compose this command with another that creates the views for the
>>> Note and the connection.
>>>
>>> To see how to create a note take a look at NoteViewFactory.
>>>
>>> You can figure a lot about how this is done by setting breakpoints in
>>> GraphicalNodeEditPolicy (gmf) while attaching notes using the Note
>>> Attachment tool.
>>>
>>> vlad
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wed, 30 Aug 2006 09:37:23 +0200, Michele Puccio wrote:
>>>
>>>> Cherie,
>>>> thanks for your answer.
>>>> My aim is to create a note attachment when a new element is drawn in
>>>> the diagram between the new element and an existing one.
>>>> How could I reuse the AddNoteAction?
>>>> Best regards
>>>>
>>>> michele
>>>>
>>>> Cherie Mahoney ha scritto:
>>>>> Michele,
>>>>>
>>>>> The answer depends on where the code is called to create the new
>>>>> element in
>>>>> your diagram. There is an AddNoteAction in GMF that creates a new
>>>>> note and
>>>>> draws a note attachment to the element from which the action was
>>>>> executed.
>>>>> If you are doing something similar to this, you could probably
>>>>> reuse this
>>>>> code.
>>>>>
>>>>> - Cherie
>>>>>
>>>>> "Michele Puccio" <puccio@eng.it> wrote in message
>>>>> news:ed1qoh$pr6$1@utils.eclipse.org...
>>>>>> Hi all
>>>>>> I need to create programmatically a note attachment when I create an
>>>>>> element in my diagram.
>>>>>> How can I do?
>>>>>> Thanks
>>>>>>
>>>>>> Michele
>>>>>
>>
|
|
|
Goto Forum:
Current Time: Sun Jul 13 14:22:09 EDT 2025
Powered by FUDForum. Page generated in 0.35374 seconds
|