Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Minimizing a view using perspectiveExtension not supported(Need a workaround for opening a view in minimized state when a perspective is opened, since the 'perspectiveExtension.view.minimized' attribute is not yet supported/implemented in Eclipse 4.4 and 4.5.)
Minimizing a view using perspectiveExtension not supported [message #1707064] Wed, 02 September 2015 00:06 Go to next message
Kyle McCreary is currently offline Kyle McCrearyFriend
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

Re: Minimizing a view using perspectiveExtension not supported [message #1707330 is a reply to message #1707064] Thu, 03 September 2015 18:51 Go to previous message
Kyle McCreary is currently offline Kyle McCrearyFriend
Messages: 2
Registered: May 2015
Junior Member
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
Previous Topic:Why does the second perspective show up in a new window?
Next Topic:Theming the Eclipse 4.6 IDE itself -- How/where to override GTK3 "theme.css" for Eclipse o
Goto Forum:
  


Current Time: Mon Sep 23 05:16:37 GMT 2024

Powered by FUDForum. Page generated in 0.03190 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top