KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > PlaceholderFolderLayout


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Chris Gross chris.gross@us.ibm.com Bug 107443
11  *******************************************************************************/

12 package org.eclipse.ui.internal;
13
14 import org.eclipse.ui.IPlaceholderFolderLayout;
15
16 /**
17  * This layout is used to define the initial set of placeholders
18  * in a placeholder.
19  * <p>
20  * Views are added to the placeholder by ID. This id is used to identify
21  * a view descriptor in the view registry, and this descriptor is used to
22  * instantiate the IViewPart.
23  * </p>
24  */

25 public class PlaceholderFolderLayout implements 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 JavaDoc 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 JavaDoc 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 JavaDoc getProperty(String JavaDoc 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 JavaDoc id, String JavaDoc 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 }
92
Popular Tags