Restorable Views


Since Eclipse 3.4, the extension point allowing to define new views inside the workbench has a new attribute called restorable.

Here is the description for this attribute: “flag indicating whether this view allows to be restored upon workbench restart. If set to false, the view will not be open after a workbench restart. The default is true.”

This can be useful for views which content can’t be restored across workbench instances. In our case to “emulate” this behavior we had previously to listen for workbench closes and to programatically close the views that will not be restored.

As a result the following piece of code (that may causes errors !!!!) is replaced just by ONE XML line

private void closeMe() {
     Display.getDefault().syncExec(new Runnable() {
         public void run() {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                 .getActivePage().hideView(OutlineView.this);
            idToSession.removeByV(session);
            sessionToView.removeByK(session);
        }
   });
}

PlatformUI.getWorkbench().addWorkbenchListener(new IWorkbenchListener() {
    public void postShutdown(IWorkbench workbench) {}
    public boolean preShutdown(IWorkbench workbench, boolean forced) {
       closeMe();
       return true;
   }
});

Manu

Advertisements
This entry was posted in Uncategorized by Manuel. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s