Minimizing a view using perspectiveExtension not supported [message #1707064] |
Wed, 02 September 2015 00:06 |
Kyle McCreary Messages: 2 Registered: May 2015 |
Junior Member |
|
|
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 13:11] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03190 seconds