KickJava   Java API By Example, From Geeks To Geeks.

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


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  *******************************************************************************/

11 package org.eclipse.ui.internal;
12
13 public class ContainerPlaceholder extends PartPlaceholder implements
14         ILayoutContainer {
15     private static int nextId = 0;
16
17     private ILayoutContainer realContainer;
18
19     /**
20      * ContainerPlaceholder constructor comment.
21      * @param id java.lang.String
22      * @param label java.lang.String
23      */

24     public ContainerPlaceholder(String JavaDoc id) {
25         super(((id == null) ? "Container Placeholder " + nextId++ : id)); //$NON-NLS-1$
26
}
27
28     /**
29      * add method comment.
30      */

31     public void add(LayoutPart child) {
32         if (!(child instanceof PartPlaceholder)) {
33             return;
34         }
35         realContainer.add(child);
36     }
37
38     /**
39      * See ILayoutContainer::allowBorder
40      */

41     public boolean allowsBorder() {
42         return true;
43     }
44
45     /**
46      * getChildren method comment.
47      */

48     public LayoutPart[] getChildren() {
49         return realContainer.getChildren();
50     }
51
52     /**
53      * getFocus method comment.
54      */

55     public LayoutPart getFocus() {
56         return null;
57     }
58
59     /**
60      * getFocus method comment.
61      */

62     public LayoutPart getRealContainer() {
63         return (LayoutPart) realContainer;
64     }
65
66     /**
67      * isChildVisible method comment.
68      */

69     public boolean isChildVisible(LayoutPart child) {
70         return false;
71     }
72
73     /**
74      * remove method comment.
75      */

76     public void remove(LayoutPart child) {
77         if (!(child instanceof PartPlaceholder)) {
78             return;
79         }
80         realContainer.remove(child);
81     }
82
83     /**
84      * replace method comment.
85      */

86     public void replace(LayoutPart oldChild, LayoutPart newChild) {
87         if (!(oldChild instanceof PartPlaceholder)
88                 && !(newChild instanceof PartPlaceholder)) {
89             return;
90         }
91         realContainer.replace(oldChild, newChild);
92     }
93
94     /**
95      * setChildVisible method comment.
96      */

97     public void setChildVisible(LayoutPart child, boolean visible) {
98     }
99
100     /**
101      * setFocus method comment.
102      */

103     public void setFocus(LayoutPart child) {
104     }
105
106     public void setRealContainer(ILayoutContainer container) {
107
108         if (container == null) {
109             // set the parent container of the children back to the real container
110
if (realContainer != null) {
111                 LayoutPart[] children = realContainer.getChildren();
112                 if (children != null) {
113                     for (int i = 0, length = children.length; i < length; i++) {
114                         children[i].setContainer(realContainer);
115                     }
116                 }
117             }
118         } else {
119             // replace the real container with this place holder
120
LayoutPart[] children = container.getChildren();
121             if (children != null) {
122                 for (int i = 0, length = children.length; i < length; i++) {
123                     children[i].setContainer(this);
124                 }
125             }
126         }
127
128         this.realContainer = container;
129     }
130
131     public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
132         ILayoutContainer container = getContainer();
133
134         if (container != null) {
135             container.findSashes(this, sashes);
136         }
137     }
138
139     /* (non-Javadoc)
140      * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
141      */

142     public boolean allowsAutoFocus() {
143         return false;
144     }
145
146     /* (non-Javadoc)
147      * @see org.eclipse.ui.internal.ILayoutContainer#isZoomed(org.eclipse.ui.internal.LayoutPart)
148      */

149     public boolean childIsZoomed(LayoutPart toTest) {
150         return false;
151     }
152 }
153
Popular Tags