| Summary: | [Perspectives] Placeholder folder error with multiple instance views | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Marco Maccaferri <m_maccaf> |
| Component: | UI | Assignee: | Nick Edgar <n.a.edgar> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | douglas.pollock, michaelvanmeekeren |
| Version: | 3.0 | ||
| Target Milestone: | 3.0.1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
I have this exact problem. I need to create a placeholder folder where the
folder will contain multiple instances of two different views. Is there any
plan to fix this in the near future or is there a known workaround?
I tried placing the id in the plugin.xml file twice, with and without the
multiple instance wildcard ("primaryId" and "primaryId:*") so that the
folder.addPlaceholder() would find what it needs, but I obviously then get the
view showing up twice in the "Show Views" menu item. I've read all the history
of bug ids 31612 and 56431.
Any suggestions would be helpful.
Thanks.
Added fixes to the addPlaceholder methods in PageLayout, PlaceholderFolderLayout
and FolderLayout.
They now all call PageLayout.checkValidPlaceholderId(String id) which is as follows.
/**
* Checks whether the given id is a valid placeholder id.
* A placeholder id may be simple or compound, and can optionally contain a
wildcard.
*
* @param id the placeholder id
* @return <code>true</code> if the given id is a valid placeholder id,
<code>false</code> otherwise
*/
boolean checkValidPlaceholderId(String id) {
// Check that view is not already in layout.
// This check is done even if the id has a wildcard, since it's
incorrect to create
// multiple placeholders with the same id, wildcard or not.
if (checkPartInLayout(id)) {
return false;
}
// check that primary view id is valid, but only if it has no wildcard
String primaryId = ViewFactory.extractPrimaryId(id);
if (!ViewFactory.hasWildcard(primaryId)) {
IViewRegistry reg = WorkbenchPlugin.getDefault().getViewRegistry();
IViewDescriptor desc = reg.find(primaryId);
if (desc == null) {
// cannot safely open the dialog so log the problem
WorkbenchPlugin.log("Unable to find view with id: " + primaryId);
//$NON-NLS-1$
return false;
}
}
return true;
}
Also added regression tests in IWorkbenchPageTest:
- testOpenPerspectiveWithMultiViewPlaceholdersAtTopLevel()
- testOpenPerspectiveWithMultiViewPlaceholdersInPlaceholderFolder()
- testOpenPerspectiveWithMultiViewPlaceholdersInFolder()
Re comment #1, I don't see any workaround. This should go into 3.0.1 as well. It works fine in Integration Build: I20040901 but not in Eclipse 3.0
Here is my piece of code:
IPlaceholderFolderLayout docs = layout.createPlaceholderFolder("docs",
IPageLayout.RIGHT, 0.5f, "results");
docs.addPlaceholder(DocumentView.ID_VIEW + ":*");
docs.addPlaceholder(BrowserView.ID_VIEW + ":*");
Patch released to 3.0.1. Verified in M20040908 using modified browser example. Plus the tests pass. |
MyViewId is a view with the allowMultiple flag set to true. The following code in my IPerspectiveFactory implementation: public void createInitialLayout(IPageLayout layout) { layout.setEditorAreaVisible(false); IPlaceholderFolderLayout folder = layout.createPlaceholderFolder("book", IPageLayout.LEFT, 0.27f, IPageLayout.ID_EDITOR_AREA); folder.addPlaceholder("MyViewId:*"); } Causes the following message: !MESSAGE Unable to find view label: MyViewId:* and the view's placement doesn't work. I digged a bit on the source code and found that the addPlaceholder method for the FolderPlaceholderLayout class doesn't verify if the view id is in the form viewId:secondaryId, thus failing.