01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */package org.romaframework.aspect.view.echo2.area.impl;
16:
17: import nextapp.echo2.app.Component;
18:
19: import org.romaframework.aspect.view.area.AreaModeManager;
20: import org.romaframework.aspect.view.echo2.area.AbstractComponentAreaMode;
21:
22: import echopointng.ContainerEx;
23:
24: public class PlaceholderAreaMode extends AbstractComponentAreaMode {
25:
26: public Object createComponent(int iSize) {
27: return new ContainerEx();
28: }
29:
30: @Override
31: public String toString() {
32: return AreaModeManager.DEF_AREAMODE_NAME;
33: }
34:
35: @Override
36: public Object placeComponent(Object iComponentContainer,
37: Object iComponentToPlace) {
38: Component comp = (Component) iComponentContainer;
39: Component parent = comp.getParent();
40:
41: // REMOVE CURRENT COMPONENT TO SUBSTITUTE WITH NEW
42: if (parent != null) {
43: int pos = parent.indexOf(comp);
44: if (pos > -1) {
45: parent.remove(comp);
46: parent.add((Component) iComponentToPlace, pos);
47: }
48: }
49: return iComponentToPlace;
50: }
51:
52: @Override
53: public boolean isChildrenAllowed() {
54: return false;
55: }
56: }
|