AidenPearce
AidenPearce

Reputation: 93

Do not save workbench state in a eclipse RCP app

I am devoloping an application with eclipse RCP. This application should alwaysshow a certain perspective when started. But the application saves it workbench state and when restarted it shows the same perspective it had when it was closed. I tried to add

public void initialize(IWorkbenchConfigurer configurer){
    configurer.setSaveAndRestore(false);
}

to my ApplicationWorkbenchAdvisor class, but it did'nt work. I also thought of selection the right perspective, but I don't know where to add such a piece of code.

How can my application always show the same perspective on startup?

Upvotes: 1

Views: 1094

Answers (2)

unai alba
unai alba

Reputation: 21

Too late for you but maybe usefull for other people.

As @Aiden says, we add -clearPersistedState to the program arguments in run configurations.

It worked for us in e4 with Eclipse Neon 4.6.

Upvotes: 2

AidenPearce
AidenPearce

Reputation: 93

I found out that if you always want the same start perspective, you can set the default perspective during startup.

public class Application implements IApplication {
    public Object start(IApplicationContext content){
        PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective("youperspective here");

        //other code...
    }

    //other code...
}

UPDATE: This only works if you enable "Clear workspace" in your run configurations. My current solution is to delete the workbench file during program startup.

Upvotes: 1

Related Questions