Christian HagerSoftware Engineer // Technical Director // Photographer

Creating durable folders in perspectives

When creating an IFolder in a pespective of an Eclipse RCP or RAP application using

IFolderLayout folder = layout.createFolder("de.nordiccoding.myfolder", IPageLayout.TOP, 0.5f, editorArea);

the default behaviour of the folder is to hide the folder once the last view in it has been closed. Unfortunately in many cases this is not the desired behaviour. But where there’s a will there’s a way.
IFolders can be kept from closing themselfs by making them durable. By overriding the ApplicationWorkbenchWindowAdvisor’s isDurableFolder method and returning true you can set all or only specific folders durable.

@Override
public boolean isDurableFolder(String perspectiveId, String folderId) {
    if( "de.nordiccoding.myperspective".equals(perspectiveId) && "de.nordiccoding.myfolder".equals(folderId) ) {
          return true; 
    }
    return super.isDurableFolder(perspectiveId, folderId);
}

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *