Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to call own layoutProvider from "Arrange All"
How to call own layoutProvider from "Arrange All" [message #216611] Wed, 28 January 2009 18:13 Go to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi everyone,

I was searching on the mailing list but did not find a sufficient answer fop my problem.

I want to use my own layoutProvider while using the already existing menu item "Arrange All".


I did the following things so far:

1. Add the extension point, see below:

<extension name="PSC Viewer Layout Provider" point="org.eclipse.gmf.runtime.diagram.ui.layoutProviders">
<layoutProvider class="ui.diagram.providers.LayoutProvider">
<Priority name="Highest">
</Priority>
</layoutProvider>
</extension>


2. Create a class derived from org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractL ayoutNodeProvider

public class PscViewerLayoutProvider extends AbstractLayoutNodeProvider {

public Runnable layoutLayoutNodes(List layoutNodes,
boolean offsetFromBoundingBox, IAdaptable layoutHint) {
System.out.println("layoutNodes: "+layoutNodes.toString());
System.out.println("offsetFromBoundingBox: "+offsetFromBoundingBox);
System.out.println("layoutHint: "+layoutHint.toString());
return null;
}

public boolean provides(IOperation operation) {
System.out.println(""+operation.toString());
if (operation instanceof org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNo deOperation) {
System.out.println("true");
return true;
}
System.out.println("false");
return false;
}
}

I would expect to see at least the println while calling "Arrange All". But I don't see any thing at System.out!

Does any one could please give me a hint how to solve the problem?

Thanks, Martin
Re: How to call own layoutProvider from "Arrange All" [message #216637 is a reply to message #216611] Thu, 29 January 2009 08:49 Go to previous messageGo to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Hi Martin,

It seems to me that your class value in plugin.xml is not the right one :

<layoutProvider class="ui.diagram.providers.LayoutProvider">

should be :

<layoutProvider class="yourcompany.yourpackage.PscViewerLayoutProvider">

BTW debugging with system.out is evil :P, why you do not simply add breakpoints ?

Regards,

Mariot

Martin Jacob a écrit :
> Hi everyone,
>
> I was searching on the mailing list but did not find a sufficient
> answer fop my problem.
>
> I want to use my own layoutProvider while using the already existing
> menu item "Arrange All".
>
>
> I did the following things so far:
>
> 1. Add the extension point, see below:
>
> <extension name="PSC Viewer Layout Provider"
> point="org.eclipse.gmf.runtime.diagram.ui.layoutProviders">
> <layoutProvider class="ui.diagram.providers.LayoutProvider">
> <Priority name="Highest">
> </Priority>
> </layoutProvider>
> </extension>
>
>
> 2. Create a class derived from
> org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractL ayoutNodeProvider
>
>
> public class PscViewerLayoutProvider extends AbstractLayoutNodeProvider {
>
> public Runnable layoutLayoutNodes(List layoutNodes,
> boolean offsetFromBoundingBox, IAdaptable layoutHint) {
> System.out.println("layoutNodes: "+layoutNodes.toString());
> System.out.println("offsetFromBoundingBox: "+offsetFromBoundingBox);
> System.out.println("layoutHint: "+layoutHint.toString());
> return null;
> }
>
> public boolean provides(IOperation operation) {
> System.out.println(""+operation.toString());
> if (operation instanceof
> org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNo deOperation) {
> System.out.println("true");
> return true;
> }
> System.out.println("false");
> return false;
> }
> }
>
> I would expect to see at least the println while calling "Arrange All".
> But I don't see any thing at System.out!
>
> Does any one could please give me a hint how to solve the problem?
>
> Thanks, Martin
Re: How to call own layoutProvider from "Arrange All" [message #216644 is a reply to message #216637] Thu, 29 January 2009 09:15 Go to previous messageGo to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi Mariot,

the package and class name in plugin.xml is correct. (I just delete some parts for posting it here)
And yes u are right system.out is evil, its just a old habit from C programming....

Now I used the debugger but got the same result. My layout provider will not be called :(

Any other suggestions?

Cheers, Martin

Mariot Chauvin wrote, On 29.01.2009 09:49:
> Hi Martin,
>
> It seems to me that your class value in plugin.xml is not the right one :
>
> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>
> should be :
>
> <layoutProvider class="yourcompany.yourpackage.PscViewerLayoutProvider">
>
> BTW debugging with system.out is evil :P, why you do not simply add breakpoints ?
>
> Regards,
>
> Mariot
>
> Martin Jacob a écrit :
>> Hi everyone,
>>
>> I was searching on the mailing list but did not find a sufficient
>> answer fop my problem.
>>
>> I want to use my own layoutProvider while using the already existing
>> menu item "Arrange All".
>>
>>
>> I did the following things so far:
>>
>> 1. Add the extension point, see below:
>>
>> <extension name="PSC Viewer Layout Provider"
>> point="org.eclipse.gmf.runtime.diagram.ui.layoutProviders">
>> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>> <Priority name="Highest">
>> </Priority>
>> </layoutProvider>
>> </extension>
>>
>>
>> 2. Create a class derived from
>> org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractL ayoutNodeProvider
>>
>>
>> public class PscViewerLayoutProvider extends AbstractLayoutNodeProvider {
>>
>> public Runnable layoutLayoutNodes(List layoutNodes,
>> boolean offsetFromBoundingBox, IAdaptable layoutHint) {
>> System.out.println("layoutNodes: "+layoutNodes.toString());
>> System.out.println("offsetFromBoundingBox: "+offsetFromBoundingBox);
>> System.out.println("layoutHint: "+layoutHint.toString());
>> return null;
>> }
>>
>> public boolean provides(IOperation operation) {
>> System.out.println(""+operation.toString());
>> if (operation instanceof
>> org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNo deOperation) {
>> System.out.println("true");
>> return true;
>> }
>> System.out.println("false");
>> return false;
>> }
>> }
>>
>> I would expect to see at least the println while calling "Arrange All".
>> But I don't see any thing at System.out!
>>
>> Does any one could please give me a hint how to solve the problem?
>>
>> Thanks, Martin
Re: How to call own layoutProvider from "Arrange All" [message #216652 is a reply to message #216644] Thu, 29 January 2009 09:46 Go to previous messageGo to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Martin,

Is there another layout defined with the highest priority ?
If you externalize your layout in a plug-in check that you plug-in started without errors ("Show View" -> "Other" -> "Plug-in Registry").

If you install GMF sdk there is also an example of layout provider ("New" -> "Example/ GMF PLugins/Square layout provider") to compare.

Regards,

Mariot

Martin Jacob a écrit :
> Hi Mariot,
>
> the package and class name in plugin.xml is correct. (I just delete some
> parts for posting it here)
> And yes u are right system.out is evil, its just a old habit from C
> programming....
>
> Now I used the debugger but got the same result. My layout provider will
> not be called :(
>
> Any other suggestions?
>
> Cheers, Martin
>
> Mariot Chauvin wrote, On 29.01.2009 09:49:
>> Hi Martin,
>>
>> It seems to me that your class value in plugin.xml is not the right one :
>>
>> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>>
>> should be :
>>
>> <layoutProvider class="yourcompany.yourpackage.PscViewerLayoutProvider">
>>
>> BTW debugging with system.out is evil :P, why you do not simply add
>> breakpoints ?
>>
>> Regards,
>>
>> Mariot
>>
>> Martin Jacob a écrit :
>>> Hi everyone,
>>>
>>> I was searching on the mailing list but did not find a sufficient
>>> answer fop my problem.
>>>
>>> I want to use my own layoutProvider while using the already existing
>>> menu item "Arrange All".
>>>
>>>
>>> I did the following things so far:
>>>
>>> 1. Add the extension point, see below:
>>>
>>> <extension name="PSC Viewer Layout Provider"
>>> point="org.eclipse.gmf.runtime.diagram.ui.layoutProviders">
>>> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>>> <Priority name="Highest">
>>> </Priority>
>>> </layoutProvider>
>>> </extension>
>>>
>>>
>>> 2. Create a class derived from
>>> org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractL ayoutNodeProvider
>>>
>>>
>>>
>>> public class PscViewerLayoutProvider extends
>>> AbstractLayoutNodeProvider {
>>>
>>> public Runnable layoutLayoutNodes(List layoutNodes,
>>> boolean offsetFromBoundingBox, IAdaptable layoutHint) {
>>> System.out.println("layoutNodes: "+layoutNodes.toString());
>>> System.out.println("offsetFromBoundingBox: "+offsetFromBoundingBox);
>>> System.out.println("layoutHint: "+layoutHint.toString());
>>> return null;
>>> }
>>>
>>> public boolean provides(IOperation operation) {
>>> System.out.println(""+operation.toString());
>>> if (operation instanceof
>>> org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNo deOperation)
>>> {
>>> System.out.println("true");
>>> return true;
>>> }
>>> System.out.println("false");
>>> return false;
>>> }
>>> }
>>>
>>> I would expect to see at least the println while calling "Arrange All".
>>> But I don't see any thing at System.out!
>>>
>>> Does any one could please give me a hint how to solve the problem?
>>>
>>> Thanks, Martin
Re: How to call own layoutProvider from "Arrange All" [message #216658 is a reply to message #216652] Thu, 29 January 2009 10:08 Go to previous message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi Mariot,

thanks for the hint!
In fact the plugin could not be loaded because a ClassNotFoundException was thrown...
Now I copied the package name and class name to the extension point in plugin.xml. And it works! There must be a typo some where...

Regards, Martin



Mariot Chauvin wrote, On 29.01.2009 10:46:
> Martin,
>
> Is there another layout defined with the highest priority ?
> If you externalize your layout in a plug-in check that you plug-in started without errors ("Show View" -> "Other" -> "Plug-in Registry").
>
> If you install GMF sdk there is also an example of layout provider ("New" -> "Example/ GMF PLugins/Square layout provider") to compare.
>
> Regards,
>
> Mariot
>
> Martin Jacob a écrit :
>> Hi Mariot,
>>
>> the package and class name in plugin.xml is correct. (I just delete some
>> parts for posting it here)
>> And yes u are right system.out is evil, its just a old habit from C
>> programming....
>>
>> Now I used the debugger but got the same result. My layout provider will
>> not be called :(
>>
>> Any other suggestions?
>>
>> Cheers, Martin
>>
>> Mariot Chauvin wrote, On 29.01.2009 09:49:
>>> Hi Martin,
>>>
>>> It seems to me that your class value in plugin.xml is not the right one :
>>>
>>> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>>>
>>> should be :
>>>
>>> <layoutProvider class="yourcompany.yourpackage.PscViewerLayoutProvider">
>>>
>>> BTW debugging with system.out is evil :P, why you do not simply add
>>> breakpoints ?
>>>
>>> Regards,
>>>
>>> Mariot
>>>
>>> Martin Jacob a écrit :
>>>> Hi everyone,
>>>>
>>>> I was searching on the mailing list but did not find a sufficient
>>>> answer fop my problem.
>>>>
>>>> I want to use my own layoutProvider while using the already existing
>>>> menu item "Arrange All".
>>>>
>>>>
>>>> I did the following things so far:
>>>>
>>>> 1. Add the extension point, see below:
>>>>
>>>> <extension name="PSC Viewer Layout Provider"
>>>> point="org.eclipse.gmf.runtime.diagram.ui.layoutProviders">
>>>> <layoutProvider class="ui.diagram.providers.LayoutProvider">
>>>> <Priority name="Highest">
>>>> </Priority>
>>>> </layoutProvider>
>>>> </extension>
>>>>
>>>>
>>>> 2. Create a class derived from
>>>> org.eclipse.gmf.runtime.diagram.ui.services.layout.AbstractL ayoutNodeProvider
>>>>
>>>>
>>>>
>>>> public class PscViewerLayoutProvider extends
>>>> AbstractLayoutNodeProvider {
>>>>
>>>> public Runnable layoutLayoutNodes(List layoutNodes,
>>>> boolean offsetFromBoundingBox, IAdaptable layoutHint) {
>>>> System.out.println("layoutNodes: "+layoutNodes.toString());
>>>> System.out.println("offsetFromBoundingBox: "+offsetFromBoundingBox);
>>>> System.out.println("layoutHint: "+layoutHint.toString());
>>>> return null;
>>>> }
>>>>
>>>> public boolean provides(IOperation operation) {
>>>> System.out.println(""+operation.toString());
>>>> if (operation instanceof
>>>> org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNo deOperation)
>>>> {
>>>> System.out.println("true");
>>>> return true;
>>>> }
>>>> System.out.println("false");
>>>> return false;
>>>> }
>>>> }
>>>>
>>>> I would expect to see at least the println while calling "Arrange All".
>>>> But I don't see any thing at System.out!
>>>>
>>>> Does any one could please give me a hint how to solve the problem?
>>>>
>>>> Thanks, Martin
Previous Topic:[Announce] GMF 2.2.0 I200901281927 is available
Next Topic:Hide 'Input methods' in Context Menu
Goto Forum:
  


Current Time: Thu Apr 18 23:14:51 GMT 2024

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

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

Back to the top