javaeclipsercpe4workbench

How can I save workbench.xmi programmatically?


We have an RCP application, using Eclipse 3.x and we are migrating to Eclipse 4.

At a certain point in our application, we need to save the workbench.xml file with the contents of the perspectives. In Eclipse 3.x this was done by writing to the file using memento.

Is there any way in Eclipse 4 to save the workbench.xmi file with the perspectives content?

Apparently all the methods that existed in the Workbench class relating to saving perspectives have been removed and there are no others that do the same.

I tried to find where workbench.xmi is saved but without success.

Can someone help me?


Solution

  • You can use org.eclipse.e4.ui.workbench.IModelResourceHandler to save the workbench.xmi

    You can get this using @Inject or from the IEclipseContext.

    Use the save method:

    public void save() throws IOException