Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 389987

Summary: Support placeholders with wildcards
Product: [Eclipse Project] Platform Reporter: Uwe Kubosch <uwe>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: emoffatt, kuebler, uwe
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Uwe Kubosch CLA 2012-09-20 05:46:52 EDT
Given this example using Eclipse RCP 4.2:

public class Perspective implements IPerspectiveFactory {
    @Override
    public void createInitialLayout(IPageLayout layout) {
        layout.setEditorAreaVisible(false);

        IFolderLayout left = layout.createFolder(
                "left", IPageLayout.LEFT, 0.75f, IPageLayout.ID_EDITOR_AREA);
        left.addPlaceholder(OrdersView.ID + ":*");

        IFolderLayout bottomRight = layout.createFolder(
                "bottom right", IPageLayout.RIGHT, 0.5f,
                IPageLayout.ID_EDITOR_AREA);
        bottomRight.addView(OperatorsView.ID);
        bottomRight.addView(ShiftsView.ID);

        layout.addView(VehiclesView.ID, IPageLayout.TOP, 0.5f, "bottom right");

        final IWorkbenchWindow window = Activator.getDefault().getWorkbench()
                .getActiveWorkbenchWindow();
        window.getShell().getDisplay().asyncExec(new Runnable() {
            @Override
            public void run() {
                try {
                    window.getActivePage().showView(OrdersView.ID, "42",
                            IWorkbenchPage.VIEW_ACTIVATE);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

I would expect OrdersView to open in the "left" folder.  It is however opened in the "bottom right" folder.

Looking in the code for org.eclipse.ui.internal.e4.compatibility.ModeledPlaceholderFolderLayout.addPlaceholder, I see a check for wildcard usage, and a message:

E4Util.unsupported("IPageLayout.addPlacehoder(): wildcard in view id: " + viewId);

The result is a NOOP.

Could you implement placeholders with wildcards, or explain how to do it with Eclipse RCP 4.2 ?

Thank you for your efforts.
Comment 1 Eric Moffatt CLA 2012-09-21 14:52:15 EDT
Uwe, it's already on our list...;-).

*** This bug has been marked as a duplicate of bug 383309 ***
Comment 2 Uwe Kubosch CLA 2012-09-21 14:57:49 EDT
Excellent!  Thank you!
Comment 3 Jens Kuebler CLA 2013-05-02 03:39:18 EDT
I can't see that this has been fixed, yet.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java

Supported is now to add multiple instances of the same view. However it is not supported to specify wildcards for placeholders and expect views to populate to this category once there are instanciated.
Comment 4 Eric Moffatt CLA 2013-05-02 13:31:37 EDT
Jens, I'm not sure what you're asking for. The only pattern I know of is that you can add a placeholder of the format '<viewId>:*' to a stack and that will be used to determine where new instances of 'viewId' views as they're created. What am I missing ?
Comment 5 Jens Kuebler CLA 2013-05-03 03:44:37 EDT
Yes, that is the pattern I'm speaking of. Given the code below I wonder how to add a placeholder with wildcards as the code explicitly states that this is unsupported.

public void addPlaceholder(String viewId) {
		boolean containsWildcards = viewId.indexOf('?') != -1;
		if (containsWildcards) {
			E4Util.unsupported("IPageLayout.addPlacehoder(): wildcard in view id: " + viewId); //$NON-NLS-1$
			return;
		}
...
Comment 6 Eric Moffatt CLA 2013-05-03 11:36:44 EDT
That code is looking for '?', not ':'...I'm not even sure where '?' comes into the multi-instance view story...am I missing something?

If you call 'addPlaceholder("MyViewId:*") then the result will be that wherever this placeholder is will be where new instances of "MyViewId" will appear.