Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 98536 - [Perspectives] [RCP] [ViewMgmt] How to prevent multiple instances of the same view from being closed/moved
Summary: [Perspectives] [RCP] [ViewMgmt] How to prevent multiple instances of the same...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0.2   Edit
Hardware: PC Windows 2000
: P3 normal with 15 votes (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-06 11:42 EDT by Sabina Luzzatti CLA
Modified: 2007-05-14 12:58 EDT (History)
4 users (show)

See Also:


Attachments
Testcase to show that the proposed fiz doesn't work when secondary ids in placeholder views are used (34.79 KB, application/x-zip-compressed)
2007-04-13 17:57 EDT, Sabina Luzzatti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sabina Luzzatti CLA 2005-06-06 11:42:58 EDT
In our scenario we have registered a  generic placeholder to define the position
where multiple instances of the same view have to be displayed. This placeholder
is defined in the createInitialLayout method of our perspective according to the
following code:


public class MyPerspective implements IPerspectiveFactory {

public void createInitialLayout((IPageLayout layout){
..................
      IFolderLayout folderMainContent =
             layout.createFolder("main", IPageLayout.RIGHT, 0.25f,
editorId);
      folderMainContent.addView(WelcomeView.ID_VIEW);
      IViewLayout vlx = layout.getViewLayout(WelcomeView.ID_VIEW);
      vlx.setMoveable(false);
      vlx.setCloseable(false);
      folderMainContent.addPlaceholder(PlaceHolderView.ID_VIEW +":*");
      layout.getViewLayout(PlaceHolderView.ID_VIEW+":*"
).setCloseable(false);
.................
}
}
The views identified by PlaceHolderView.ID_VIEW and a unique secondary id are
opened later using:

IWorkbenchPage activePage =    
TellerPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().
      getActivePage();
 (PlaceHolderView)activePage.showView(PlaceHolderView.ID_VIEW,
generateUniqueId(), IWorkbenchPage.VIEW_ACTIVATE);

All the generated views should be not closeable because, according to
requirements,  views can be closed only  using  push buttons .
Despite the views have been defined as not closeable, they are (the red icon
appears on the folder tab).
Comment 1 Nick Edgar CLA 2005-06-06 16:36:37 EDT
I believe the current behaviour is necessary to support the LWP use case of
allow document views to be closeable, even though they have a placeholder in a
fixed perspective

In a fixed perspective, all initial views are marked as non-closeable and
non-moveable, and currently placeholders are too, but this is ignored for
placeholders.  This is unintuitive, and doesn't allow us to support Sabina's
scenario.  It should be possible to fix this (in a backwards compatible way) by
making the default state for placeholders be closeable and moveable, even if the
perspective is fixed, but to honour these settings if they are explicitly
overridden.
Comment 2 Matthew Hatem CLA 2005-06-06 16:56:38 EDT
LWP perspectives are always generated dynamically, we are not using "fixed"
perspectives at the moment but we do use fixed views extensively.

I'm not sure I understand the problem here though.  Seems to me there is just a
bug with IViewLayout not honoring moveable/closable settings for placeholder
layouts.

I Think this actually a problem that LWP has hit once or twice and a bugzilla
was just never opened.  For the LWP use cases we would like to add placeholders
for fixed views.
Comment 3 Mike Higginbotham CLA 2005-07-08 17:14:54 EDT
I have almost the exact same code (using a fixed perspective) and have also run
into this problem. The placeholder is fixed - views added with showView always
are added as an additional tab to the folder containing the view added with
addView(). In the originator's case - with the WelcomeView. Even if you move a
view added with showView elsewhere in the perspective, a future showView will
add the view in  the original placeholder location. It appears views added to a
placeholder are not inheriting the placeholder's moveable/closeable settings. 
Comment 4 Nick Edgar CLA 2005-07-11 12:42:06 EDT
Will investigate for 3.1.1.
Comment 5 Nick Edgar CLA 2005-09-09 10:16:02 EDT
We won't be able to address this for 3.1.1.
Marking for 3.2.
Comment 6 Boris Bokowski CLA 2006-05-23 13:51:31 EDT
Sorry - late in the game, a lot of bugs were moved around and too many 3.2
items ended up on my plate. Moving to 3.3 since I was not able to address this
for 3.2.
Comment 7 Boris Bokowski CLA 2006-05-23 23:21:17 EDT
I just noticed how many votes this bug had (even though almost all are from Italy :)

If this is just a bug and fixing it does not involve API changes I can look at it for 3.2.1.

Comment 8 Boris Bokowski CLA 2006-06-12 21:58:09 EDT
I think I can fix this - does anybody really care about putting it in 3.2.1?  If yes, would you be willing to help me test my fix?

If this is not a high priority, this will be fixed for 3.3.
Comment 9 John Smith CLA 2006-08-30 07:27:29 EDT
I've been having problems in relation to this. I was wondering if this would make sense:

 

In org.eclipse.ui.internal.Perspective, for the getViewLayoutRec(IViewReference ref, boolean create) method, change to this:

 

/**

     * Returns the view layout rec for the given view reference,

     * or null if not found.  If create is true, it creates the record

     * if not already created.

     */

    private ViewLayoutRec getViewLayoutRec(IViewReference ref, boolean create) {

        ViewLayoutRec rec = getViewLayoutRec(ViewFactory.getKey(ref), create);

        if (rec == null)

        {

            rec = getViewLayoutRec(ref.getId(), false);

        }

    }

 

 

This way if you are using views with wildcards (like someTestView:*), when it fails to find, say, "someTestView:1" it can look for "someTestView" instead, and use the values from that. Does this make sense?
Comment 10 Boris Bokowski CLA 2006-11-03 14:44:16 EST
(In reply to comment #9)
> Does this make sense?

Yes, although I am not sure if the fix should be put into getViewLayoutRec() or just isMoveable()/isCloseable(). I will look at this for M4.
Comment 11 Boris Bokowski CLA 2006-12-12 23:19:41 EST
Fixed >20061212.
Comment 12 Boris Bokowski CLA 2006-12-14 14:07:33 EST
Verified on Windows XP using I20061213-0800.
Comment 13 Sabina Luzzatti CLA 2007-04-13 17:51:43 EDT
the fix doesn't work if you use secondary ids in placeholder views, as reported in the initial snippet when this bug was opened. The test has been made using eclipse 3.3M6 on Windows XP.
Comment 14 Sabina Luzzatti CLA 2007-04-13 17:57:39 EDT
Created attachment 63805 [details]
Testcase to show that the proposed fiz doesn't work when secondary ids in placeholder views are used

In the attachment there is a simple RCP application with a Perspective and two Views. The first view , ButtonView , has a button used to create multiple instances of PlaceholderView  that are placed in a folder layout. The layout of placeholderView states that the instances of this View should be NOT closeable but once created, they are.
Comment 15 Boris Bokowski CLA 2007-05-09 14:33:51 EDT
Moving to RC1 for investigation.  Not sure if I will be able to come up with a fix.
Comment 16 Boris Bokowski CLA 2007-05-14 12:58:19 EDT
I should have explained this on the bug when I fixed it.

In createInitialLayout, write 
  folderMainContent.addPlaceholder(PlaceHolderView.ID_VIEW);
  layout.getViewLayout(PlaceHolderView.ID_VIEW).setCloseable(false);
instead of
  folderMainContent.addPlaceholder(PlaceHolderView.ID_VIEW +":*");
  layout.getViewLayout(PlaceHolderView.ID_VIEW+":*").setCloseable(false);

Setting resolution back to fixed.