01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: * Chris Gross chris.gross@us.ibm.com Bug 107443
11: *******************************************************************************/package org.eclipse.ui.internal;
12:
13: import org.eclipse.ui.IPlaceholderFolderLayout;
14:
15: /**
16: * This layout is used to define the initial set of placeholders
17: * in a placeholder.
18: * <p>
19: * Views are added to the placeholder by ID. This id is used to identify
20: * a view descriptor in the view registry, and this descriptor is used to
21: * instantiate the IViewPart.
22: * </p>
23: */
24: public class PlaceholderFolderLayout implements
25: IPlaceholderFolderLayout {
26: private PageLayout pageLayout;
27:
28: private ContainerPlaceholder placeholder;
29:
30: public PlaceholderFolderLayout(PageLayout pageLayout,
31: ContainerPlaceholder folder) {
32: super ();
33: this .placeholder = folder;
34: this .pageLayout = pageLayout;
35: }
36:
37: /**
38: * @see IPlaceholderFolderLayout
39: */
40: public void addPlaceholder(String viewId) {
41: if (!pageLayout.checkValidPlaceholderId(viewId)) {
42: return;
43: }
44:
45: // Create the placeholder.
46: LayoutPart newPart = new PartPlaceholder(viewId);
47:
48: linkPartToPageLayout(viewId, newPart);
49:
50: // Add it to the placeholder layout.
51: placeholder.add(newPart);
52: }
53:
54: /**
55: * Inform the page layout of the new part created
56: * and the placeholder the part belongs to.
57: */
58: private void linkPartToPageLayout(String viewId, LayoutPart newPart) {
59: pageLayout.setRefPart(viewId, newPart);
60: // force creation of the view layout rec
61: pageLayout.getViewLayoutRec(viewId, true);
62:
63: pageLayout.setFolderPart(viewId, placeholder);
64: newPart.setContainer(placeholder);
65: }
66:
67: /* (non-Javadoc)
68: * @see org.eclipse.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
69: */
70: public String getProperty(String id) {
71: LayoutPart folder = placeholder.getRealContainer();
72: if (folder instanceof PartStack) {
73: PartStack stack = (PartStack) folder;
74: return stack.getProperty(id);
75: }
76: //throw not supported?
77: return null;
78: }
79:
80: /* (non-Javadoc)
81: * @see org.eclipse.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
82: */
83: public void setProperty(String id, String value) {
84: LayoutPart folder = placeholder.getRealContainer();
85: if (folder instanceof PartStack) {
86: PartStack stack = (PartStack) folder;
87: stack.setProperty(id, value);
88: }
89: //throw not supported?
90: }
91: }
|