Strangely, I can now access the property in the way that I wrote. But I got
random crashes at different places. Sometimes the app ran without problem,
sometimes it crashed before the workbench could have started. It looks to
me that the order of loading the plugins is indeterministic, and the
crashes happened when my plugin was loaded too late. (Whatever this should
mean.)

I implemented the workbench post-startup notifications and moved the CL
argument processing after the workbench has started. It seems it solves my
issues.

Pull request here:
https://github.com/MITK/MITK/pull/114

Could you please review it?

Cheers,
Miklos


On 27 August 2015 at 21:18, Miklos Espak <[email protected]> wrote:

> Hi,
>
> I introduced some command line arguments for our MITK based application,
> e.g. --perspective, to set the initial perspective, and others to set the
> initial layout of our custom editor. Until the MITK upgrade the arguments
> were processed in the PostStartup function of our Workbench class that was
> in our application plugin. Now I have to move the code to a different
> plugin so that the application plugin does not have a transitive dependency
> on org.mitk.gui.qt.common. (This plugin assumes that the workbench is ready
> when it gets activated.)
>
> What I figured so far:
>
> Now you need to override the defineOptions function of your application
> class. My looks like this now:
>
>   void defineOptions(Poco::Util::OptionSet& options) override
>
>   {
>
>     Poco::Util::Option perspectiveOption("perspective", "", "name of initial 
> perspective");
>
>     perspectiveOption.argument("<perspective>").binding("niftk.perspective");
>
>     options.addOption(perspectiveOption);
>
>
>     mitk::BaseApplication::defineOptions(options);
>
>   }
>
>
>
> And I try to access the "niftk.perspective" configuration parameter from
> the activator of a plugin, like this:
>
>   Poco::Util::LayeredConfiguration& config = 
> Poco::Util::Application::instance().config();
>
>   if (config.has("niftk.perspective"))
>
>   {
>
>     ....
>
>   }
>
>
> But this config object does not have that configuration property. There
> used to be a berry::Platform::GetConfiguration() function (you can still
> find some uses in the MITK sources) but it has been removed.
>
> Any idea, how to access those properties? Should that function be
> reintroduced?
>
> My other problem is that it does not seem to be possible to run code after
> the workbench has started. There is an IWorkbenchListener class, but it
> only has PreShutDown and PostShutDown functions but no PostStartUp. I
> noticed that when the plugin activator above runs,
> berry::PlatformUI::IsWorkbenchRunning() returns true but the PostStartUp
> function of the workbench has not run yet.
>
> Should berry::IWorkbenchListener have a PostStartUp function?
>
> Cheers,
> Miklos
>
>
>
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to