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.util.*;
034:
035: import de.ug2t.channel.markup.html.renderer.*;
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 MuGenericPage extends MuGenericContainer implements
042: IUnPage, IKePoolable, IUnGuiEventListener {
043: private IKeView pem_view = new HtmlPageRenderer();
044: protected String pdm_title = null;
045: protected UnComponent pdm_focus = null;
046: protected UnComponent pdm_stdFocus = null;
047: protected IUnImage pdm_bgImg = null;
048:
049: protected IUnPageDecorator pdm_deco = null;
050:
051: protected IUnImage pdm_ico = null;
052: protected boolean pdm_doDeco = true;
053: protected boolean pem_ownMenu = false;
054: private boolean pem_scroll = true;
055: private IUnMenu pem_mainMenu = null;
056: private boolean pem_submitReshapes = false;
057: private String pem_myCss = null;
058: private boolean pem_maximized = false;
059:
060: public MuGenericPage(String xTitle, ACoDataGetter xTplGetter,
061: Object xTplName, MuGenericApplication xAppl)
062: throws Exception {
063: super (xTitle, xTplGetter, xTplName, xAppl);
064:
065: this .pcmf_setView(pem_view);
066: this .pcmf_setValue(xTitle);
067: this .pcmf_setBgColor(this .pdm_kit.getPANEL_BG());
068:
069: this .pdm_title = xTitle;
070:
071: // Debug
072: // this.pcmf_setGenerateReshapeEvents(true);
073: // this.pcmf_addListener(new UnPrintValueListener());
074:
075: return;
076: };
077:
078: // @@
079:
080: public void pcmf_disable() {
081: if (this .pdm_deco != null)
082: this .pdm_deco.pcmf_disable();
083:
084: super .pcmf_disable();
085: };
086:
087: public void pcmf_enable() {
088: if (this .pdm_deco != null)
089: this .pdm_deco.pcmf_enable();
090:
091: super .pcmf_enable();
092: };
093:
094: public void pcmf_setMenu(IUnMenu xMenu) {
095: if (this .pem_mainMenu == null)
096: this .pcmf_getMenu();
097:
098: if (this .pem_mainMenu != null)
099: this .pcmf_removeNode(this .pem_mainMenu
100: .pcmf_getUnComponent());
101:
102: if (xMenu != null)
103: this .pcmf_addNode(xMenu.pcmf_getUnComponent()
104: .pcmf_getName(), (KeTreeNode) xMenu);
105:
106: this .pem_mainMenu = xMenu;
107:
108: return;
109: }
110:
111: public IUnMenu pcmf_getMenu() {
112: if (this .pem_mainMenu != null)
113: return (this .pem_mainMenu);
114:
115: Object l_obj = null;
116: Iterator l_it = this .pcmf_getSubIterator();
117: while (l_it.hasNext()) {
118: l_obj = l_it.next();
119: if (l_obj instanceof IUnMenu
120: && l_obj instanceof IUnContextMenu == false) {
121: this .pem_mainMenu = (IUnMenu) l_obj;
122: break;
123: }
124: }
125: return (this .pem_mainMenu);
126: }
127:
128: public UnComponent pcmf_setPosition(String xName, int xPos,
129: int yPos, int xWidth, int xHeight, int xAlign) {
130: return (null);
131: };
132:
133: public UnComponent pcmf_setPosition(UnComponent xObj, int xPos,
134: int yPos, int xWidth, int xHeight, int xAlign) {
135: return (null);
136: };
137:
138: public void pcmf_setPosition(int xPos, int yPos, int xWi, int xHi,
139: String xAlign) {
140: if (this .pdm_deco != null)
141: ((MuGenericComponent) this .pdm_deco).pcmf_setPosition(xPos,
142: yPos + this .pdm_deco.pcmf_getYPosCorrection(), xWi,
143: xHi, xAlign);
144:
145: super .pcmf_setPosition(xPos, yPos, xWi, xHi, xAlign);
146:
147: return;
148: }
149:
150: public boolean pcmf_getInFrame() {
151: return (!this .pdm_title.equals(this .pcmf_getValue()));
152: }
153:
154: public KeStringTemplate pcmf_renderContent(KeStringTemplate l_body,
155: KeStringTemplate l_retval) {
156: Iterator it = this .pcmf_getSubIterator();
157:
158: boolean l_mdi = this .pcmf_getAppl().pcmf_isMDI();
159:
160: IMuGenericLayoutManager l_layout = this .pcmf_getLayoutManager();
161: if (l_layout == null) {
162: KeTreeElement l_obj = null;
163: while (it.hasNext()) {
164: l_obj = (KeTreeElement) it.next();
165: if (l_obj instanceof IUnMenu == false
166: || l_obj instanceof IUnContextMenu
167: || (this .pem_ownMenu && l_mdi))
168: l_body.pcmf_stringAddEnd(((KeTreeElement) l_obj)
169: .pcmf_execView().toString());
170: }
171: } else {
172: l_layout.pcmf_layout();
173: l_body.pcmf_stringAddEnd(l_layout.pcmf_getMarkupString());
174: }
175:
176: if (l_mdi == true && this .pdm_doDeco)
177: l_body = (KeStringTemplate) this .pdm_deco.pcmf_execView(
178: l_body, this .pcmf_getIcon());
179:
180: l_retval = (KeStringTemplate) pdm_NodeView.pcmf_output(this );
181:
182: IUnMenu l_menu = ((MuGenericApplication) this .pcmf_getAppl())
183: .pcmf_getActiveMenu();
184:
185: if (l_menu != null) {
186: KeStringTemplate l_m = this .pcmf_getMarkupString("MENU");
187: l_retval = KeTools.pcmf_stringSubst(l_retval, "$MENU", l_m);
188: l_retval = KeTools.pcmf_stringSubst(l_retval, "$MENU",
189: l_menu.pcmf_getUnComponent().pcmf_execView()
190: .toString());
191: } else
192: l_retval = KeTools.pcmf_stringSubst(l_retval, "$MENU", "");
193:
194: if (l_mdi)
195: l_retval = KeTools.pcmf_stringSubstAppend(l_retval,
196: "$BODY", l_body.toString(), "$BODY");
197: else
198: l_retval = KeTools.pcmf_stringSubst(l_retval, "$BODY",
199: l_body.toString());
200:
201: return (l_retval);
202: }
203:
204: public void pcmf_ownsMenu(boolean xOwns) {
205: pem_ownMenu = xOwns;
206: return;
207: }
208:
209: public boolean pcmf_getOwnsMenu() {
210: return (this .pem_ownMenu);
211: }
212:
213: public Object pcmf_execView() {
214: if (this .pcmf_isHidden() && !this .pcmf_getRenderIfHidden()) {
215: this .pcmf_setPropChanged(false);
216: Iterator l_it = this .pcmf_getDeepSubNodeIt();
217: while (l_it.hasNext())
218: ((KeTreeElement) l_it.next())
219: .pcmf_setPropChanged(false);
220:
221: return (new KeStringTemplate(""));
222: }
223:
224: KeStringTemplate l_retval = null;
225: KeStringTemplate l_body = null;
226:
227: if ((((MuGenericApplication) this .pcmf_getAppl())
228: .pcmf_getActiveMenu() != null || this .pcmf_getMenu() != null)
229: && this .pcmf_getAppl().pcmf_isMDI() == false)
230: l_body = new KeStringTemplate(this
231: .pcmf_getMarkupString("MOFFSET"));
232: else
233: l_body = new KeStringTemplate("");
234:
235: this .pemf_setDeco();
236:
237: if (this .pdm_title.equals(this .pcmf_getValue()))
238: l_retval = pcmf_renderContent(l_body, l_retval);
239: else {
240: MuGenericComponent l_obj = (MuGenericComponent) KeRegisteredObject
241: .pcmf_getObjByName(this .pcmf_getValue().toString());
242: String l_fret = l_obj.pcmf_execView().toString();
243: this .pcmf_setValue(this .pdm_title);
244:
245: this .pcmf_setPropChanged(false);
246: return (l_fret);
247: }
248:
249: this .pcmf_setPropChanged(false);
250: return (l_retval);
251: };
252:
253: public Object pcmf_execMdiNonActiveView() {
254: if (this .pcmf_isHidden() && !this .pcmf_getRenderIfHidden())
255: return (new KeStringTemplate(""));
256:
257: KeStringTemplate l_retval = null;
258: KeStringTemplate l_body = new KeStringTemplate("");
259:
260: if (this .pcmf_getAppl().pcmf_isMDI() == true
261: && this .pdm_deco == null) {
262: this .pdm_deco = this .pcmf_getAppl()
263: .pcmf_getComponentFactory().pcmf_createMdiDeco(
264: UnComponentFactory.MARKUP,
265: this .pcmf_getName(), this .pcmf_getAppl());
266: this .pdm_deco.pcmf_setPage(this );
267: this .pcmf_addNode(this .pcmf_getName(), this .pdm_deco
268: .pcmf_getUnComponent());
269: this .pdm_deco.pcmf_setPosition(this .pcmf_getXPos(), this
270: .pcmf_getYPos()
271: + this .pdm_deco.pcmf_getYPosCorrection(), this
272: .pcmf_getWi(), this .pcmf_getHi(), null);
273: }
274:
275: if (this .pdm_title.equals(this .pcmf_getValue())) {
276: Iterator it = this .pcmf_getSubIterator();
277:
278: boolean l_mdi = this .pcmf_getAppl().pcmf_isMDI();
279:
280: IMuGenericLayoutManager l_layout = this
281: .pcmf_getLayoutManager();
282: if (l_layout == null) {
283: UnComponent l_obj = null;
284: while (it.hasNext()) {
285: l_obj = (UnComponent) it.next();
286: if (l_obj instanceof IUnMenu == false
287: || l_obj instanceof IUnContextMenu
288: || (this .pem_ownMenu && l_mdi))
289: l_body
290: .pcmf_stringAddEnd(((KeTreeElement) l_obj)
291: .pcmf_execView().toString());
292: }
293: } else {
294: l_layout.pcmf_layout();
295: l_body.pcmf_stringAddEnd(l_layout
296: .pcmf_getMarkupString());
297: }
298:
299: if (l_mdi == true && this .pdm_doDeco)
300: l_body = (KeStringTemplate) this .pdm_deco
301: .pcmf_execView(l_body, this .pcmf_getIcon());
302:
303: l_retval = l_body;
304: } else {
305: MuGenericComponent l_obj = (MuGenericComponent) KeRegisteredObject
306: .pcmf_getObjByName(this .pcmf_getValue().toString());
307: String l_fRet = l_obj.pcmf_execView().toString();
308:
309: this .pcmf_setValue(l_fRet);
310: }
311:
312: this .pcmf_setPropChanged(false);
313: return (l_retval);
314: };
315:
316: public void pcmf_setIcon(IUnImage xIcon) {
317: if (this .pdm_ico != null)
318: this .pdm_ico.pcmf_detach();
319:
320: this .pdm_ico = xIcon;
321: this .pdm_ico.pcmf_attach();
322: };
323:
324: public IUnImage pcmf_getIcon() {
325: return (this .pdm_ico);
326: };
327:
328: public String pcmf_getTitle() {
329: return (this .pdm_title);
330: }
331:
332: public void pcmf_assignFocus(UnComponent xObj) {
333: // Flag übertagen und löschen !
334: this .pdm_focus = xObj;
335: if (xObj != null)
336: xObj.pcmf_readFocusRequest();
337:
338: return;
339: };
340:
341: public void pcmf_setDefaultFocusWdg(UnComponent xWdg) {
342: this .pdm_stdFocus = xWdg;
343: };
344:
345: public void pcmf_setDefaultFocus() {
346: if (this .pdm_stdFocus != null && this .pdm_focus == null)
347: this .pdm_stdFocus.pcmf_requestFocus();
348: };
349:
350: public void pcmf_setBgImage(IUnImage xImg) {
351: this .pdm_bgImg = xImg;
352: this .pcmf_setPropChanged(true);
353: }
354:
355: public IUnImage pcmf_getBgImage() {
356: return (this .pdm_bgImg);
357: };
358:
359: public IUnPageDecorator pcmf_getDeco() {
360: return (this .pdm_deco);
361: }
362:
363: public void pcmf_decorate(boolean xDeco) {
364: this .pdm_doDeco = xDeco;
365: };
366:
367: public void pcmf_setScroll(boolean xScroll) {
368: pem_scroll = xScroll;
369: return;
370: }
371:
372: public boolean pcmf_getScroll() {
373: return (this .pem_scroll);
374: }
375:
376: public void pcmf_delete() throws Exception {
377: if (this .pdm_deleted == true)
378: return;
379:
380: if (this .pdm_ico != null) {
381: this .pdm_ico.pcmf_detach();
382: this .pdm_ico.pcmf_getUnComponent().pcmf_delete();
383: }
384:
385: super .pcmf_delete();
386: }
387:
388: // @@
389:
390: public UnComponent pcmf_getFocusObject() {
391: return (pdm_focus);
392: }
393:
394: public void pcmf_setGenerateReshapeEvents(boolean xReshapes) {
395: this .pem_submitReshapes = xReshapes;
396: this .pcmf_setPropChanged(true);
397:
398: return;
399: }
400:
401: public boolean pcmf_getGenerateReshapeEvents() {
402: return (this .pem_submitReshapes);
403: }
404:
405: public void pcmf_execListener(UnComponent xParam) throws Exception {
406: if (this .pcmf_getParentNode() == null)
407: this .pcmf_getAppl().pcmf_addPage(this .pcmf_getName(),
408: (IUnPage) this );
409:
410: this .pemf_setDeco();
411:
412: if (this .pdm_deco == null)
413: xParam.pcmf_getAppl().pcmf_setActive(this .pcmf_getName());
414: else
415: this .pdm_deco.pcmf_toFront();
416: }
417:
418: private void pemf_setDeco() {
419: if (this .pcmf_getAppl().pcmf_isMDI() == true
420: && this .pdm_deco == null) {
421: this .pdm_deco = this .pcmf_getAppl()
422: .pcmf_getComponentFactory().pcmf_createMdiDeco(
423: UnComponentFactory.MARKUP,
424: this .pcmf_getName(), pcmf_getAppl());
425:
426: this .pdm_deco.pcmf_setPage(this );
427: this .pcmf_addNode(this .pcmf_getName(), this .pdm_deco
428: .pcmf_getUnComponent());
429: this .pdm_deco.pcmf_setPosition(this .pcmf_getXPos(), this
430: .pcmf_getYPos()
431: + this .pdm_deco.pcmf_getYPosCorrection(), this
432: .pcmf_getWi(), this .pcmf_getHi(), null);
433: }
434: }
435:
436: public void pcmf_setExternalCss(String xCss) {
437: this .pem_myCss = xCss;
438: this .pcmf_setPropChanged(true);
439: }
440:
441: public String pcmf_getExternalCss() {
442: return (this .pem_myCss);
443: }
444:
445: public boolean pcmf_isCssSupported() {
446: return (true);
447: }
448:
449: public boolean pcmf_isMaximized() {
450: return (this .pem_maximized);
451: }
452:
453: public void pcmf_maximize(boolean xMax) {
454: this .pem_maximized = xMax;
455:
456: if (this .pdm_deco != null)
457: this .pdm_deco.pcmf_toFront();
458:
459: this .pcmf_setPropChanged(true);
460: }
461:
462: public void pcmf_setInnerPosition(int xPos, int yPos, int xWidth,
463: int xHeigth) {
464: this .pcmf_setPosition(xPos, yPos, xWidth, xHeigth, "WEST");
465: }
466:
467: public void pcmf_setTitle(String xTitle) {
468: this.pdm_title = xTitle;
469: }
470: }
|