You can filter out workbench contributions (including menus etc.) using Activities - I'm still getting the hang of this, but basically it works like this...

You define an activity (e.g. being a logged in user) and then bind it to extension Ids using a regex. You then control whether an activity is enabled or not within code (you can also make it enabled by default in the plugin.xml). Here's a really simple example....

In plugin.xml;

<activity
   id="com.example.activity.InMyPerspective"
   name="In My Perspective">
</activity>
<activityPatternBinding
   activityId="com.example.activity.InMyPerspective"
   pattern="net\.refractions\.udig\.ui/net\.refractions\.udig\..*">
</activityPatternBinding>

The pattern of the regex is meant to match [plugin-id]/[contribution-id], so, in this case, the pattern matches all contributions starting with "net.refractions.udig." in the "net.refractions.udig.ui" plugin. Activities are disabled by default, so if this is all you put into your plugin.xml then the matching contributions will not show - for example, the Help menu items disappear because they're in an actionSet with an Id of "net.refractions.udig.helpMenuItems".

You can then enable the activity (and therefore all the contributions it matches) in code like this....

IWorkbenchActivitySupport was = PlatformUI.getWorkbench().getActivitySupport();
IActivityManager activityManager = was.getActivityManager();
Set<String> allActivities = new HashSet<String>();
String activityId = "com.example.activity.InMyPerspective";
if (activityManager.getActivity(activityId).isDefined()) {
   allActivities.add(activityId);
}
was.setEnabledActivityIds(allActivities);

You can get the currently enabled activities from was.getActivityManager().getEnabledActivityIds().

I'm still not entirely sure what the best way is of dynamically changing the activity state and/or responding to state changes but this does seem to be a nifty way of changing the overall UI based on pretty much anything.

Dave S-B

Jody Garnett wrote:
Hi Frederic; we don't add functionality to UDig until there is some who needs it. I am not sure if we have thought about how to turn on and off tools. I started doing that work but there was nobody around interested to test...

So lets do so now ...
1. Tools are probably contributed via action sets; can you check how that is done? If we can make an action set with the same name as a tool category we should be able to toggle the actionset off for your persepective and hide the tool categorizes you don't need 2. There is a new way to do menus and toolbars is with expressions and context and that sort of thing; I need to figure it out more

I made a couple "dynamic" menu entries (to process the tools into the menu tree) when a Map is enabled; we can make the check for a matchig actionset or context there. There is also an Eclipse RCP where the plugin.xml files are filtered abit allowing you to turn off anything you want (the code will still be there but it won't be picked up by the Platform).

The Window menu is part of Eclipse RCP; while you don't have to use that in your app it is part of the eclipse user interface guidelines.

You may want to start with an Eclipse RCP book; there are some docs in the wiki about customizing uDig but many of your questions are aimed at the menu extention points about which we both need to learn more.
Jody

Frederic Renard wrote:

Hi every body,

I wrote a stand alone RCP application who needs Udig. It work fine when launched from my Eclipse IDE. But I have problems with 'product' configuration. I 've searched 2 days …..

- when I open my application I received this error : Error opening the editor.Group not found: additions. I suppose some udig modules are missings or not initialized , or not instanciated.

I also search who to customize udig menu : I want to

- suppress some tools like 'Delete feature', 'Create Polygon Geometry',…

- suppresse to level menus like 'Map','Data,'Window',

- or supress some options into this menus.

Probably all this operations are simple, but I didn't find tuto, explainations ( or I didn't understand them) or examples.

Is there a book about Udig customisation ?

Best regards,

Frederick

------------------------------------------------------------------------

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to