D.Griffin
D.Griffin

Reputation: 27

E4 RCP How to set Toolbar item from preferences on start-up

Eclipse E4 (4.4.2), I have a Handled Tool Item defined in the Application model at,
Windows and Dialogs -> TrimBars -> Window Trim -> Toolbar

The Type of the item is Check. An option of the item call Selected, assigns the default selection of the Toolbar item when the RCP application is launched. I am persisting the current state of the tool bar item in org.eclipse.core.runtime.preferences.InstanceScope (other non-UI preferences as also stored here).

Is there a way to set the selection state of the tool bar item when the application is re-launched to the value stored in my preferences? i.e. if tool bar item is selected on exiting the application it is selected on launching, if tool bar item is de-selected on existing the application it is not selected on launching.

Upvotes: 0

Views: 295

Answers (1)

greg-449
greg-449

Reputation: 111216

There is no standard way since the Eclipse Application Platform doesn't know anything about the preferences.

You could use a model processor defined using the org.eclipse.e4.workbench.model extension point to add code to initialize the item.

<extension
     id="themeContribution"
     point="org.eclipse.e4.workbench.model">
  <processor
        beforefragment="false"
        class="package.ItemProcessor">
     <element
           id="item.id">
     </element>
  </processor>

Alternatively you should be able to write code to set the tool bar item value from the preferences in the @ProcessAdditions method of your application LifeCycle class (assuming you have one). Note the @PostContextCreate method is probably called to early for this.

Upvotes: 1

Related Questions