001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.channel.markup.generic;
032:
033: import java.awt.*;
034:
035: import de.ug2t.channel.markup.html.*;
036: import de.ug2t.connector.*;
037: import de.ug2t.kernel.*;
038: import de.ug2t.unifiedGui.*;
039: import de.ug2t.unifiedGui.interfaces.*;
040:
041: public class MuGenericContainer extends MuGenericComponent implements
042: IUnContainer, IUnLayouted {
043: private IMuGenericLayoutManager pem_layoutManager = null;
044: private boolean pem_isLayout = false; // Sollte besser
045:
046: // isNoLayout
047: // heißen
048:
049: /**
050: * @param xName
051: * @param xTplGetter
052: * @param xTplName
053: * @param xAppl
054: * @throws Exception
055: */
056: public MuGenericContainer(String xName, ACoDataGetter xTplGetter,
057: Object xTplName, MuGenericApplication xAppl)
058: throws Exception {
059: super (xName, xTplGetter, xTplName, xAppl);
060: }
061:
062: public void pcmf_reConstructObject(String xName,
063: ACoDataGetter xTplGetter, Object xTplName,
064: MuGenericApplication xAppl) throws Exception {
065: super
066: .pcmf_reConstructObject(xName, xTplGetter, xTplName,
067: xAppl);
068: }
069:
070: public void pcmf_setFill(String xName, boolean xH, boolean xV) {
071: MuGenericComponent l_obj = null;
072:
073: l_obj = (MuGenericComponent) this .pcmf_getSubNode(xName);
074: if (l_obj == null)
075: l_obj = (MuGenericComponent) this .pcmf_getSubElement(xName);
076:
077: this .pcmf_setFill(l_obj, xH, xV);
078: }
079:
080: public void pcmf_setFill(UnComponent xObj, boolean xH, boolean xV) {
081: MuGenericComponent l_obj = null;
082:
083: l_obj = (MuGenericComponent) xObj;
084:
085: if (this .pem_layoutManager == null && l_obj != null) {
086: KeLog
087: .pcmf_log(
088: "ug2t",
089: "cannot set fill due to object not found or no active layout",
090: this , KeLog.ERROR);
091: return;
092: }
093: ;
094:
095: if (l_obj.pdm_hfill == xH && l_obj.pdm_vfill == xV)
096: return;
097:
098: l_obj.pcmf_setFill(xH, xV);
099:
100: this .pcmf_setPropChanged(true);
101: }
102:
103: public void pcmf_setWeights(String xName, int xW, int yW) {
104: MuGenericComponent l_obj = null;
105:
106: l_obj = (MuGenericComponent) this .pcmf_getSubNode(xName);
107: if (l_obj == null)
108: l_obj = (MuGenericComponent) this .pcmf_getSubElement(xName);
109:
110: this .pcmf_setWeights(l_obj, xW, yW);
111: }
112:
113: public void pcmf_setWeights(UnComponent xObj, int xW, int yW) {
114: MuGenericGridBagConstraints l_constr = null;
115: MuGenericComponent l_obj = null;
116:
117: l_obj = (MuGenericComponent) xObj;
118:
119: if (this .pem_layoutManager != null
120: && this .pem_layoutManager.pcmf_supportContraints()
121: && l_obj != null) {
122: l_constr = (MuGenericGridBagConstraints) this .pem_layoutManager
123: .pcmf_getConstraints(l_obj);
124: if (l_constr == null)
125: l_constr = new MuGenericGridBagConstraints();
126:
127: l_constr.pcm_weightx = xW;
128: l_constr.pcm_weighty = yW;
129: this .pem_layoutManager.pcmf_addConstraints(l_obj, l_constr);
130:
131: this .pcmf_setPropChanged(true);
132: } else {
133: KeLog
134: .pcmf_log(
135: "ug2t",
136: "cannot set weights due to object not found, no active layout or constraint is not supported",
137: this , KeLog.ERROR);
138: return;
139: }
140: ;
141: }
142:
143: public void pcmf_setInsets(UnComponent xObj, int xIns1, int xIns2,
144: int xIns3, int xIns4) {
145: MuGenericGridBagConstraints l_constr = null;
146: MuGenericComponent l_obj = null;
147:
148: l_obj = (MuGenericComponent) xObj;
149:
150: if (this .pem_layoutManager != null
151: && this .pem_layoutManager.pcmf_supportContraints()
152: && l_obj != null) {
153: l_constr = (MuGenericGridBagConstraints) pem_layoutManager
154: .pcmf_getConstraints(l_obj);
155: if (l_constr == null)
156: l_constr = new MuGenericGridBagConstraints();
157:
158: l_constr.pcm_insets = new Insets(xIns1, xIns2, xIns3, xIns4);
159: this .pem_layoutManager.pcmf_addConstraints(l_obj, l_constr);
160:
161: this .pcmf_setPropChanged(true);
162: } else {
163: KeLog
164: .pcmf_log(
165: "ug2t",
166: "cannot set weights due to object not found, no active layout or constraint is not supported",
167: this , KeLog.ERROR);
168: return;
169: }
170: ;
171: }
172:
173: public void pcmf_setInsets(String xName, int xIns1, int xIns2,
174: int xIns3, int xIns4) {
175: MuGenericComponent l_obj = null;
176:
177: l_obj = (MuGenericComponent) this .pcmf_getSubNode(xName);
178: if (l_obj == null)
179: l_obj = (MuGenericComponent) this .pcmf_getSubElement(xName);
180:
181: this .pcmf_setInsets(l_obj, xIns1, xIns2, xIns3, xIns4);
182: }
183:
184: public void pcmf_setLayoutManager(IMuGenericLayoutManager xLayout) {
185: if (this .pem_layoutManager == xLayout)
186: return;
187:
188: this .pem_layoutManager = xLayout;
189:
190: if (xLayout == null)
191: this .pem_isLayout = false;
192: else {
193: this .pem_isLayout = true;
194: xLayout.pcmf_setLayoutObj(this );
195: }
196: this .pcmf_setPropChanged(true);
197:
198: return;
199: }
200:
201: public IMuGenericLayoutManager pcmf_getLayoutManager() {
202: return (this .pem_layoutManager);
203: }
204:
205: public boolean pcmf_isLayout() {
206: return (this .pem_isLayout);
207: };
208:
209: public boolean pcmf_setLayout(boolean xLayout) {
210: if (this .pem_isLayout == xLayout)
211: return (xLayout);
212:
213: boolean l_old = this .pem_isLayout;
214: this .pem_isLayout = xLayout;
215: this .pcmf_setPropChanged(true);
216:
217: return (l_old);
218: }
219:
220: public int pcmf_getCommonLayout() {
221: if (this .pem_isLayout && this .pem_layoutManager != null)
222: return (IUnLayouted.LAYOUT_GRIDBAG);
223: else if (!this .pem_isLayout && this .pem_layoutManager == null)
224: return (IUnLayouted.LAYOUT_ABSOLUTE);
225: else
226: return (IUnLayouted.LAYOUT_FLOW);
227: }
228:
229: public void pcmf_setCommonLayout(int xLayout) {
230: switch (xLayout) {
231: case IUnLayouted.LAYOUT_ABSOLUTE:
232: this .pcmf_setLayout(false);
233: break;
234: case IUnLayouted.LAYOUT_FLOW:
235: this .pcmf_setLayout(true);
236: this .pem_layoutManager = null;
237: break;
238: case IUnLayouted.LAYOUT_GRIDBAG:
239: this .pcmf_setLayout(true);
240: IMuGenericLayoutManager l_layout = new HtmlGridBagLayout();
241: l_layout.pcmf_setInsets(0);
242: this .pcmf_setLayoutManager(l_layout);
243: break;
244: }
245: }
246:
247: public void pcmf_setGuiObjNoLayout(boolean xLayout) {
248: this .pcmf_setLayout(!xLayout);
249: };
250:
251: public void pcmf_setGuiObjPosition(String xName, int xPos,
252: int yPos, int xWi, int xHi, String xAlign) {
253: MuGenericComponent l_obj = (MuGenericComponent) this
254: .pcmf_getSubNode(xName);
255: if (l_obj == null) {
256: KeLog
257: .pcmf_log(
258: "ug2t",
259: "gui-object to position not found in this container",
260: this , KeLog.ERROR);
261:
262: return;
263: }
264: ;
265: l_obj.pcmf_setPosition(xPos, yPos, xWi, xHi, xAlign);
266:
267: return;
268: };
269:
270: public void pcmf_setGuiObjPosition(UnComponent xObj, int xPos,
271: int yPos, int xWi, int xHi, String xAlign) {
272: MuGenericComponent l_obj = (MuGenericComponent) xObj;
273: l_obj.pcmf_setPosition(xPos, yPos, xWi, xHi, xAlign);
274:
275: return;
276: };
277:
278: public void pcmf_addWidget(String xName, UnComponent xObj) {
279: this .pcmf_addNode(xName, xObj);
280: };
281:
282: public UnComponent pcmf_removeWidget(String xName) {
283: return ((UnComponent) this .pcmf_removeNode(xName));
284: };
285:
286: public UnComponent pcmf_removeWidget(UnComponent xObj) {
287: return ((UnComponent) this .pcmf_removeNode(xObj));
288: };
289:
290: public UnComponent pcmf_getWidget(String xName) {
291: return ((UnComponent) this .pcmf_getSubNode(xName));
292: };
293:
294: public void pcmf_delete() throws Exception {
295: if (this .pdm_deleted == true)
296: return;
297:
298: if (this .pem_layoutManager != null)
299: this .pem_layoutManager = null;
300:
301: super .pcmf_delete();
302: }
303:
304: // @@
305:
306: // New methods (delegates only) due to interface harmonisation
307: public void pcmf_addWidget(String xName, IUnComponent xObj) {
308: this .pcmf_addWidget(xName, (UnComponent) xObj);
309: }
310:
311: public boolean pcmf_contains(UnComponent xObj) {
312: return (super .pcmf_contains(xObj));
313: };
314:
315: public boolean pcmf_contains(IUnComponent xObj) {
316: return (super .pcmf_contains((UnComponent) xObj));
317: }
318:
319: public IUnComponent pcmf_getWidgetbyName(String xName) {
320: return ((IUnComponent) this .pcmf_getWidget(xName));
321: }
322:
323: public IUnComponent pcmf_removeWidget(IUnComponent xObj) {
324: return ((IUnComponent) this
325: .pcmf_removeWidget((UnComponent) xObj));
326: }
327:
328: public void pcmf_setGuiObjPosition(IUnComponent xObj, int xPos,
329: int yPos, int xWi, int xHi, String xAlign) {
330: this .pcmf_setGuiObjPosition((UnComponent) xObj, xPos, yPos,
331: xWi, xHi, xAlign);
332: }
333: }
|