001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal;
011:
012: public class ContainerPlaceholder extends PartPlaceholder implements
013: ILayoutContainer {
014: private static int nextId = 0;
015:
016: private ILayoutContainer realContainer;
017:
018: /**
019: * ContainerPlaceholder constructor comment.
020: * @param id java.lang.String
021: * @param label java.lang.String
022: */
023: public ContainerPlaceholder(String id) {
024: super (((id == null) ? "Container Placeholder " + nextId++ : id)); //$NON-NLS-1$
025: }
026:
027: /**
028: * add method comment.
029: */
030: public void add(LayoutPart child) {
031: if (!(child instanceof PartPlaceholder)) {
032: return;
033: }
034: realContainer.add(child);
035: }
036:
037: /**
038: * See ILayoutContainer::allowBorder
039: */
040: public boolean allowsBorder() {
041: return true;
042: }
043:
044: /**
045: * getChildren method comment.
046: */
047: public LayoutPart[] getChildren() {
048: return realContainer.getChildren();
049: }
050:
051: /**
052: * getFocus method comment.
053: */
054: public LayoutPart getFocus() {
055: return null;
056: }
057:
058: /**
059: * getFocus method comment.
060: */
061: public LayoutPart getRealContainer() {
062: return (LayoutPart) realContainer;
063: }
064:
065: /**
066: * isChildVisible method comment.
067: */
068: public boolean isChildVisible(LayoutPart child) {
069: return false;
070: }
071:
072: /**
073: * remove method comment.
074: */
075: public void remove(LayoutPart child) {
076: if (!(child instanceof PartPlaceholder)) {
077: return;
078: }
079: realContainer.remove(child);
080: }
081:
082: /**
083: * replace method comment.
084: */
085: public void replace(LayoutPart oldChild, LayoutPart newChild) {
086: if (!(oldChild instanceof PartPlaceholder)
087: && !(newChild instanceof PartPlaceholder)) {
088: return;
089: }
090: realContainer.replace(oldChild, newChild);
091: }
092:
093: /**
094: * setChildVisible method comment.
095: */
096: public void setChildVisible(LayoutPart child, boolean visible) {
097: }
098:
099: /**
100: * setFocus method comment.
101: */
102: public void setFocus(LayoutPart child) {
103: }
104:
105: public void setRealContainer(ILayoutContainer container) {
106:
107: if (container == null) {
108: // set the parent container of the children back to the real container
109: if (realContainer != null) {
110: LayoutPart[] children = realContainer.getChildren();
111: if (children != null) {
112: for (int i = 0, length = children.length; i < length; i++) {
113: children[i].setContainer(realContainer);
114: }
115: }
116: }
117: } else {
118: // replace the real container with this place holder
119: LayoutPart[] children = container.getChildren();
120: if (children != null) {
121: for (int i = 0, length = children.length; i < length; i++) {
122: children[i].setContainer(this );
123: }
124: }
125: }
126:
127: this .realContainer = container;
128: }
129:
130: public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
131: ILayoutContainer container = getContainer();
132:
133: if (container != null) {
134: container.findSashes(this , sashes);
135: }
136: }
137:
138: /* (non-Javadoc)
139: * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
140: */
141: public boolean allowsAutoFocus() {
142: return false;
143: }
144:
145: /* (non-Javadoc)
146: * @see org.eclipse.ui.internal.ILayoutContainer#isZoomed(org.eclipse.ui.internal.LayoutPart)
147: */
148: public boolean childIsZoomed(LayoutPart toTest) {
149: return false;
150: }
151: }
|