Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » View disappears in one perspective if it is a fast view in another
View disappears in one perspective if it is a fast view in another [message #787405] Tue, 31 January 2012 14:42 Go to next message
Ken Wenzel is currently offline Ken WenzelFriend
Messages: 51
Registered: July 2009
Member
The following behavior was observed with Eclipse 3.8 and RAP. A proposed fix can be found at the end of this message.

Let's say I define two perspectives sharing the same view "the.view":

Perspective P1
public class P1 implements IPerspectiveFactory {
  public void createInitialLayout(IPageLayout layout) {
    layout.addView("the.view", IPageLayout.LEFT, 0.3f,
        layout.getEditorArea());
  }
}


and Perspective P2
public class P2 implements IPerspectiveFactory {
  public void createInitialLayout(IPageLayout layout) {
    layout.addFastView("the.view");
  }
}


That means the view "the.view" is a normal view in perspective P1 but a fast view in perspective P2.

If P1 is opened first and afterwards P2 then the view "the.view" disappears completely from P1 but is correctly shown as a fast view in P2.

I think this behavior is due to a bug in the org.eclipse.ui.internal.Perspective implementation in combination with the implementation of org.eclipse.ui.internal.WorkbenchPage#makeFastView.

If a new perspective is opened then the following code in org.eclipse.ui.internal.WorkbenchPage#createPerspective is executed:
Perspective persp = ((WorkbenchImplementation) Tweaklets.get(WorkbenchImplementation.KEY))
  .createPerspective(desc, this);
perspList.add(persp);


The first instruction results in a call to org.eclipse.ui.internal.Perspective#loadPredefinedPersp which contains the following code for the intialization of fast views:
// Retrieve fast views
if (fastViewManager != null) {
  ArrayList fastViews = layout.getFastViews();
  for (Iterator fvIter = fastViews.iterator(); fvIter.hasNext();) {
    IViewReference ref = (IViewReference) fvIter.next();
    fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, 
      !fvIter.hasNext());
  }
}


This results in one or more calls to org.eclipse.ui.internal.WorkbenchPage#makeFastView which in turn modifies the currently active perspective
public void makeFastView(IViewReference ref) {
  Perspective persp = getActivePerspective();
  if (persp == null) {
    return;
  }
  ...

and not the one which is about to be initialized.

A possible fix would be to move the initialization of fast views into org.eclipse.ui.internal.Perspective#onActivate
private boolean fastViewsInitialized;

protected void onActivate() {
  if (!fastViewsInitialized && fastViewManager != null) {
    fastViewsInitialized = true;
    for (Iterator fvIter = layout.getFastViews().iterator(); fvIter
        .hasNext();) {
      IViewReference ref = (IViewReference) fvIter.next();
      fastViewManager.addViewReference(
          FastViewBar.FASTVIEWBAR_ID, -1, ref,
          !fvIter.hasNext());
    }
  }

  ...
}


Best regards,

Ken
Re: View disappears in one perspective if it is a fast view in another [message #787715 is a reply to message #787405] Tue, 31 January 2012 22:29 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
Ken, you should open a bug against RAP at bugs.eclipse.org
Previous Topic:Creating a new search tab
Next Topic:Linked resources and Version Control
Goto Forum:
  


Current Time: Fri Apr 26 03:43:54 GMT 2024

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

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

Back to the top