Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How can I use a custom GridLayer in the Editor?
How can I use a custom GridLayer in the Editor? [message #502505] Tue, 08 December 2009 15:17 Go to next message
Marco is currently offline MarcoFriend
Messages: 27
Registered: July 2009
Junior Member
Hello,

I'm using Compartments in my model which have a GridLayout. To visualize
the grid of my layout manager, I would like to draw some horizontal and
vertical lines.

Probably the best practice would be to override the GridLayer of the
Editor whith a custom implementation.

So how can I replace the default GridLayerEx whith a custom
GridLayer-Implementation? On which location can I integrate my own
GridLayer into the generated Editor-Code?

Thank you very much for your answer.

Regards,
Marco
Re: How can I use a custom GridLayer in the Editor? [message #502753 is a reply to message #502505] Wed, 09 December 2009 15:16 Go to previous messageGo to next message
Daniel Beland is currently offline Daniel BelandFriend
Messages: 2
Registered: July 2009
Junior Member
Hi,


Don't know if there is a better way, but this is how I did:

Add an edit part provider to provide the root edit part of the diagram.
See the extension point org.eclipse.gmf.runtime.diagram.ui.editpartProviders


My RootEditPart extends the standard gmf
org.eclipse.gmf.runtime.diagram.ui.render.editparts.Rendered DiagramRootEditPart

Override the two createGridLayer() methods to provide your own GridLayer.

I think a few times in the code the GridLayer is cast to
org.eclipse.gmf.runtime.diagram.ui.internal.editparts.GridLa yerEx
without a check, so I suggest your GridLayer class extends it.


Cheers,
Daniel


Marco wrote:
> Hello,
>
> I'm using Compartments in my model which have a GridLayout. To visualize
> the grid of my layout manager, I would like to draw some horizontal and
> vertical lines.
>
> Probably the best practice would be to override the GridLayer of the
> Editor whith a custom implementation.
>
> So how can I replace the default GridLayerEx whith a custom
> GridLayer-Implementation? On which location can I integrate my own
> GridLayer into the generated Editor-Code?
>
> Thank you very much for your answer.
>
> Regards,
> Marco
Re: How can I use a custom GridLayer in the Editor? [message #502947 is a reply to message #502753] Thu, 10 December 2009 12:06 Go to previous messageGo to next message
Marco is currently offline MarcoFriend
Messages: 27
Registered: July 2009
Junior Member
Hello Daniel,

thank you for your reply!

I have created my own edit part provider and contributed it over the
extension point "org.eclipse.gmf.runtime.diagram.ui.editpartProviders"

But my "createRootEditPart"-method (where I return my custom
RootEditPart) is never invoked.

Which methods did you override in your edit part provider to get access
to the root edit part of the diagram?

Could you provide me some example-code, please? Thank you very much!

Regards,
Marco



Daniel Beland schrieb:
>
>
> Hi,
>
>
> Don't know if there is a better way, but this is how I did:
>
> Add an edit part provider to provide the root edit part of the diagram.
> See the extension point
> org.eclipse.gmf.runtime.diagram.ui.editpartProviders
>
>
> My RootEditPart extends the standard gmf
> org.eclipse.gmf.runtime.diagram.ui.render.editparts.Rendered DiagramRootEditPart
>
>
> Override the two createGridLayer() methods to provide your own GridLayer.
>
> I think a few times in the code the GridLayer is cast to
> org.eclipse.gmf.runtime.diagram.ui.internal.editparts.GridLa yerEx
> without a check, so I suggest your GridLayer class extends it.
>
>
> Cheers,
> Daniel
>
>
> Marco wrote:
>> Hello,
>>
>> I'm using Compartments in my model which have a GridLayout. To
>> visualize the grid of my layout manager, I would like to draw some
>> horizontal and vertical lines.
>>
>> Probably the best practice would be to override the GridLayer of the
>> Editor whith a custom implementation.
>>
>> So how can I replace the default GridLayerEx whith a custom
>> GridLayer-Implementation? On which location can I integrate my own
>> GridLayer into the generated Editor-Code?
>>
>> Thank you very much for your answer.
>>
>> Regards,
>> Marco
Re: How can I use a custom GridLayer in the Editor? [message #503036 is a reply to message #502947] Thu, 10 December 2009 15:38 Go to previous messageGo to next message
Daniel Beland is currently offline Daniel BelandFriend
Messages: 2
Registered: July 2009
Junior Member
Hi Marco,


You need to configure the edit part provider correctly.
Set a higher priority than the current one (I've put highest).
In the context you must specify it provides the root edit part.

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders "
id="my-ep-provider">
<editpartProvider class="a.b.RootPartProvider">
<Priority name="Highest">
</Priority>
<context providesRootEditPart="true">
</context>
</editpartProvider>
</extension>

Then the createRootEditPart method will be called.


public RootEditPart createRootEditPart(Diagram diagram) {
return new MyDiagramRootEditPart(diagram.getMeasurementUnit());
}


Cheers,
Daniel


Marco wrote:
> Hello Daniel,
>
> thank you for your reply!
>
> I have created my own edit part provider and contributed it over the
> extension point "org.eclipse.gmf.runtime.diagram.ui.editpartProviders"
>
> But my "createRootEditPart"-method (where I return my custom
> RootEditPart) is never invoked.
>
> Which methods did you override in your edit part provider to get access
> to the root edit part of the diagram?
>
> Could you provide me some example-code, please? Thank you very much!
>
> Regards,
> Marco
>
>
>
> Daniel Beland schrieb:
>>
>>
>> Hi,
>>
>>
>> Don't know if there is a better way, but this is how I did:
>>
>> Add an edit part provider to provide the root edit part of the diagram.
>> See the extension point
>> org.eclipse.gmf.runtime.diagram.ui.editpartProviders
>>
>>
>> My RootEditPart extends the standard gmf
>> org.eclipse.gmf.runtime.diagram.ui.render.editparts.Rendered DiagramRootEditPart
>>
>>
>> Override the two createGridLayer() methods to provide your own GridLayer.
>>
>> I think a few times in the code the GridLayer is cast to
>> org.eclipse.gmf.runtime.diagram.ui.internal.editparts.GridLa yerEx
>> without a check, so I suggest your GridLayer class extends it.
>>
>>
>> Cheers,
>> Daniel
>>
>>
>> Marco wrote:
>>> Hello,
>>>
>>> I'm using Compartments in my model which have a GridLayout. To
>>> visualize the grid of my layout manager, I would like to draw some
>>> horizontal and vertical lines.
>>>
>>> Probably the best practice would be to override the GridLayer of the
>>> Editor whith a custom implementation.
>>>
>>> So how can I replace the default GridLayerEx whith a custom
>>> GridLayer-Implementation? On which location can I integrate my own
>>> GridLayer into the generated Editor-Code?
>>>
>>> Thank you very much for your answer.
>>>
>>> Regards,
>>> Marco
Re: How can I use a custom GridLayer in the Editor? [message #503252 is a reply to message #503036] Fri, 11 December 2009 15:37 Go to previous message
Marco is currently offline MarcoFriend
Messages: 27
Registered: July 2009
Junior Member
Thank you, Daniel. I got it working this way.

Daniel Beland schrieb:
>
>
> Hi Marco,
>
>
> You need to configure the edit part provider correctly.
> Set a higher priority than the current one (I've put highest).
> In the context you must specify it provides the root edit part.
>
> <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders "
> id="my-ep-provider">
> <editpartProvider class="a.b.RootPartProvider">
> <Priority name="Highest">
> </Priority>
> <context providesRootEditPart="true">
> </context>
> </editpartProvider>
> </extension>
>
> Then the createRootEditPart method will be called.
>
>
> public RootEditPart createRootEditPart(Diagram diagram) {
> return new MyDiagramRootEditPart(diagram.getMeasurementUnit());
> }
>
>
> Cheers,
> Daniel
>
>
> Marco wrote:
>> Hello Daniel,
>>
>> thank you for your reply!
>>
>> I have created my own edit part provider and contributed it over the
>> extension point "org.eclipse.gmf.runtime.diagram.ui.editpartProviders"
>>
>> But my "createRootEditPart"-method (where I return my custom
>> RootEditPart) is never invoked.
>>
>> Which methods did you override in your edit part provider to get
>> access to the root edit part of the diagram?
>>
>> Could you provide me some example-code, please? Thank you very much!
>>
>> Regards,
>> Marco
>>
>>
>>
>> Daniel Beland schrieb:
>>>
>>>
>>> Hi,
>>>
>>>
>>> Don't know if there is a better way, but this is how I did:
>>>
>>> Add an edit part provider to provide the root edit part of the diagram.
>>> See the extension point
>>> org.eclipse.gmf.runtime.diagram.ui.editpartProviders
>>>
>>>
>>> My RootEditPart extends the standard gmf
>>> org.eclipse.gmf.runtime.diagram.ui.render.editparts.Rendered DiagramRootEditPart
>>>
>>>
>>> Override the two createGridLayer() methods to provide your own
>>> GridLayer.
>>>
>>> I think a few times in the code the GridLayer is cast to
>>> org.eclipse.gmf.runtime.diagram.ui.internal.editparts.GridLa yerEx
>>> without a check, so I suggest your GridLayer class extends it.
>>>
>>>
>>> Cheers,
>>> Daniel
>>>
>>>
>>> Marco wrote:
>>>> Hello,
>>>>
>>>> I'm using Compartments in my model which have a GridLayout. To
>>>> visualize the grid of my layout manager, I would like to draw some
>>>> horizontal and vertical lines.
>>>>
>>>> Probably the best practice would be to override the GridLayer of the
>>>> Editor whith a custom implementation.
>>>>
>>>> So how can I replace the default GridLayerEx whith a custom
>>>> GridLayer-Implementation? On which location can I integrate my own
>>>> GridLayer into the generated Editor-Code?
>>>>
>>>> Thank you very much for your answer.
>>>>
>>>> Regards,
>>>> Marco
Previous Topic:ErrorMessage when Export As SVG
Next Topic:execute template
Goto Forum:
  


Current Time: Mon Apr 12 16:53:30 GMT 2021

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

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

Back to the top