Sunday, September 13, 2009

Add Actions according conditions

It is known how to add some actions to an Eclipse application. Also, it is known that to remove unwanted actions is more complicated task.In our case we had to add "Migrate to new version" action according the condition that application was not migrated to this new version yet.First of all, as usual, we've added the actionSet extension to the basic project MANIFEST.MF (plugin.xml) file:




Then, in the application starting code, when all application resources are loaded (for example, in application Navigator view), we try to read the application resource version property:



Where getApplication() method returns application instance and isMigrated() method returns true if application version property is higher or same as specified. In this case the “Migrate” action became invisible.

No comments:

Post a Comment