Minimizing a view using perspectiveExtension not supported [message #1707064] |
Tue, 01 September 2015 20:06  |
Eclipse User |
|
|
|
I am trying to minimize a view when I first open a perspective, but cannot find a clean way to do this.
I have tried using the 'minimized' attribute in the plugin.xml:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="my.perspective.id">
<view
id="my.right.view.id"
minimized="true"
ratio="0.75"
relationship="right"
relative="org.eclipse.ui.editorss">
</view>
</perspectiveExtension>
</extension>
However, although it is in the Eclipse docs, the 'minimized' attribute apparently has not actually been implemented in either Eclipse 4.4 or 4.5:
[Excerpt from org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout]:
public void addView(String viewId, int relationship, float ratio, String refId,
boolean minimized) {
if (minimized) {
E4Util.unsupported("addView: use of minimized for " + viewId + " ref " + refId); //$NON-NLS-1$ //$NON-NLS-2$
}
addView(viewId, relationship, ratio, refId);
}
I attempted to minimize the view programmatically using a perspective listener within the IPerspectiveFactory.createInitialLayout implementation:
IFolderLayout rightFolder = layout.createFolder("right.folder", IPageLayout.RIGHT, 0.75f, IPageLayout.ID_EDITOR_AREA);
rightFolder.addView("my.right.view.id");
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
workbenchWindow.addPerspectiveListener(new PerspectiveAdapter() {
@Override
public void perspectiveOpened(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
super.perspectiveOpened(page, perspective);
if (perspective.getId().equals(PERSPECTIVE_ID)) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference viewRef = activePage.findViewReference("my.right.view.id", null);
if (viewRef != null) {
activePage.setPartState(viewRef, IWorkbenchPage.STATE_MINIMIZED);
}
// the work is done so remove this listener
PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePerspectiveListener(this);
}
}
});
This works fairly well, except that every view I minimized in this way gets docked on the LEFT side when minimized. When expanded, the view is docked correctly on the right, but all the minimized views (we actually have several in our application) are stacked to the left which is not the desired behavior.
By briefly delaying the call to setPartState (i.e., running it as a separate thread), we can get the minimized view to dock in the correct location:
if (viewRef != null) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
activePage.setPartState(viewRef, IWorkbenchPage.STATE_MINIMIZED);
}
});
}
The downside to this is that the view visibly paints as open, then minimizes. And since we have a graphics-heavy editor open, the resulting repaint is costly.
Question #1: Is there a better way to implement the auto-minimizing of the view layouts upon opening a perspective, without the redraw limitations described above?
Question #2: Are there plans to implement the 'perspectiveExtensions.view.minimized' attribute any time soon?
Any help would be greatly appreciated.
[Updated on: Wed, 02 September 2015 09:11] by Moderator
|
|
|
Re: Minimizing a view using perspectiveExtension not supported [message #1707330 is a reply to message #1707064] |
Thu, 03 September 2015 14:51  |
Eclipse User |
|
|
|
Follow-up, since no response yet...
Can anyone point me to the Eclipse code (either 4.4/Luna or 4.5/Mars) that loads a customized/saved perspective from the workbench.xmi file? I notice that when a perspective is saved with the views minimized and docked to the right, opening that saved perspective pulls them back in minimized correctly. There may be something in that code that will give me a clue of how to get the correct behavior...
Thanks,
Kyle
|
|
|
Powered by
FUDForum. Page generated in 0.03293 seconds