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.html;
032:
033: import java.util.*;
034:
035: import de.ug2t.channel.markup.generic.*;
036: import de.ug2t.kernel.*;
037: import de.ug2t.unifiedGui.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039:
040: /**
041: * @author Dirk
042: *
043: * date: 29.12.2004
044: *
045: * <p>
046: * Purpose:
047: * </p>
048: */
049: public class HtmlFullPageRenderer implements
050: IMuGenericApplicationOutput {
051: private HashMap pem_ctxMenus = new LinkedHashMap();
052: private HashMap pem_dlgs = new LinkedHashMap();
053: private HashMap pem_scrollPos = new HashMap();
054: private ArrayList pem_commands = new ArrayList();
055:
056: private MuGenericTemplateKit pem_kit = null;
057: private MuGenericApplication pem_appl = null;
058:
059: /**
060: *
061: */
062: public HtmlFullPageRenderer(MuGenericApplication xAppl,
063: MuGenericTemplateKit xKit) {
064: this .pem_kit = xKit;
065: this .pem_appl = xAppl;
066: }
067:
068: public HtmlFullPageRenderer(MuGenericApplication xAppl) {
069: this .pem_kit = xAppl.pcmf_getTemplateKit();
070: this .pem_appl = xAppl;
071: }
072:
073: public void pcmf_refreshDlgs() {
074: ArrayList l_list = new ArrayList(this .pem_dlgs.keySet());
075: Iterator l_it = l_list.iterator();
076: while (l_it.hasNext()) {
077: Object l_obj = l_it.next();
078: if (l_obj instanceof MuGenericDialog)
079: ((MuGenericDialog) l_obj).pcmf_setPropChanged(true);
080: }
081: }
082:
083: public final void pcmf_addScrollPos(MuGenericScrollController xCrt) {
084: Object l_obj = xCrt.pcmf_getMyObj();
085: if (l_obj instanceof IUnPanel
086: && ((IUnPanel) l_obj).pcmf_getScroll())
087: this .pem_scrollPos.put(xCrt, null);
088: else if (l_obj instanceof IUnPanel == false)
089: this .pem_scrollPos.put(xCrt, null);
090: };
091:
092: public KeStringTemplate pcmf_renderCtxMenues(KeStringTemplate xTpl) {
093: // ContextMenus einblenden wenn vorhanden
094: Iterator it = new ArrayList(this .pem_ctxMenus.keySet())
095: .iterator();
096: MuGenericContextMenu l_ctxMenu = null;
097: while (it.hasNext()) {
098: l_ctxMenu = (MuGenericContextMenu) it.next();
099: if (this .pemf_testCtxMenu(l_ctxMenu)) {
100: l_ctxMenu.pcmf_setShowInPage(true);
101: xTpl = KeTools.pcmf_stringSubstAppend(xTpl, "$CTXMENU",
102: l_ctxMenu.pcmf_getUnComponent().pcmf_execView()
103: .toString(), "$CTXMENU");
104: l_ctxMenu.pcmf_setShowInPage(false);
105: } else {
106: this .pem_ctxMenus.remove(l_ctxMenu);
107: KeTreeElement l_parent = l_ctxMenu.pcmf_getParentNode();
108: if (l_parent != null)
109: l_parent.pcmf_setPropChanged(true);
110: }
111: }
112: xTpl = KeTools.pcmf_stringSubst(xTpl, "$CTXMENU", "");
113:
114: return (xTpl);
115: }
116:
117: private boolean pemf_testCtxMenu(KeTreeElement xCtx) {
118: KeTreeElement l_parent = xCtx.pcmf_getParentNode();
119: if (l_parent == null)
120: return (false);
121:
122: if (l_parent instanceof IUnDialog) {
123: if (((IUnDialog) l_parent).pcmf_isDisplay())
124: return (true);
125:
126: return (false);
127: }
128:
129: if (l_parent.pcmf_getParentNode() instanceof MuGenericTabbedPane) {
130: if (((MuGenericTabbedPane) l_parent.pcmf_getParentNode())
131: .pcmf_getActive() != l_parent)
132: return (false);
133: }
134:
135: if (this .pem_appl.pcmf_isMDI()) {
136: if (l_parent instanceof IUnApplication)
137: return (true);
138: } else if (l_parent == this .pem_appl.pcmf_getActive())
139: return (true);
140:
141: return (this .pemf_testCtxMenu(l_parent));
142: }
143:
144: public void pcmf_addCtxMenu(IUnMenu xCtxMenu) {
145: this .pem_ctxMenus.put(xCtxMenu, null);
146: };
147:
148: public void pcmf_removeCtxMenu(IUnMenu xCtxMenu) {
149: this .pem_ctxMenus.remove(xCtxMenu);
150: };
151:
152: public ArrayList pcmf_getCtxMenus() {
153: return new ArrayList(this .pem_ctxMenus.keySet());
154: }
155:
156: public KeStringTemplate pcmf_renderDialogues(KeStringTemplate xTpl) {
157: Iterator it = new ArrayList(this .pem_dlgs.keySet()).iterator();
158: Object l_obj = null;
159: while (it.hasNext()) {
160: l_obj = it.next();
161: if (l_obj instanceof IUnDialog
162: || l_obj instanceof IUnFileChooser)
163: xTpl = KeTools.pcmf_stringSubstAppend(xTpl, "$DIALOG",
164: ((UnComponent) l_obj).pcmf_execView()
165: .toString(), "$DIALOG");
166: else if (l_obj instanceof IUnOptionDialog
167: && ((MuGenericOptionDialog) l_obj).pcmf_getState() != MuGenericOptionDialog.DLG_OFF) {
168: xTpl = KeTools.pcmf_stringSubst(xTpl, "$OPTDLGVAL",
169: ((UnComponent) l_obj).pcmf_execView()
170: .toString());
171: xTpl = KeTools.pcmf_stringSubst(xTpl, "$OPTDLGSCR",
172: ((MuGenericOptionDialog) l_obj)
173: .pcmf_getOnLoadScript().toString());
174: }
175: }
176:
177: xTpl.pcmf_beginTR();
178:
179: xTpl = KeTools.pcmf_stringSubst(xTpl, "$DIALOG", "");
180: xTpl = KeTools.pcmf_stringSubst(xTpl, "$OPTDLGVAL", "");
181: xTpl = KeTools.pcmf_stringSubst(xTpl, "$OPTDLGSCR", "");
182:
183: xTpl.pcmf_endTR(true);
184:
185: return (xTpl);
186: }
187:
188: public void pcmf_addDlg(IUnDialog xDlg) {
189: this .pem_dlgs.put(xDlg, null);
190: };
191:
192: public void pcmf_addDlg(IUnOptionDialog xDlg) {
193: this .pem_dlgs.put(xDlg, null);
194: };
195:
196: public void pcmf_removeDlg(IUnOptionDialog xDlg) {
197: this .pem_dlgs.remove(xDlg);
198: };
199:
200: public void pcmf_removeDlg(IUnDialog xDlg) {
201: this .pem_dlgs.remove(xDlg);
202: };
203:
204: public void pcmf_addDlg(IUnFileChooser xDlg) {
205: this .pem_dlgs.put(xDlg, null);
206: };
207:
208: public void pcmf_removeDlg(IUnFileChooser xDlg) {
209: this .pem_dlgs.remove(xDlg);
210: };
211:
212: /**
213: * <p>
214: * Does...
215: * </p>
216: * <p>
217: *
218: * @return a Type with
219: * </p>
220: * <p>
221: * @param
222: * </p>
223: */
224: public void pcmf_addToRenderlist(MuGenericComponent xObj) {
225: return;
226: }
227:
228: public Object pcmf_execView(HashMap xDlg, HashMap xCtx,
229: HashMap xScroll, ArrayList xCommands) {
230: this .pem_scrollPos = xScroll;
231: this .pem_dlgs = xDlg;
232: this .pem_ctxMenus = xCtx;
233: this .pem_commands = xCommands;
234:
235: return (this .pcmf_execView());
236: }
237:
238: public Object pcmf_execView() {
239: Object l_rawRet = null;
240: KeStringTemplate l_ret = null;
241:
242: KeLog.pcmf_log("ug2t", "full render", this , KeLog.MESSAGE);
243:
244: if (((MuGenericPage) this .pem_appl.pcmf_getRootPane())
245: .pcmf_getInFrame())
246: return (this .pem_appl.pcmf_getRootPane().pcmf_execView());
247:
248: if (this .pem_appl.pcmf_isMDI() == false)
249: l_rawRet = this .pem_appl.pcm_active.pcmf_execView();
250: else
251: l_rawRet = this .pem_appl.pcm_Desktop.pcmf_execView();
252:
253: if (l_rawRet instanceof KeStringTemplate)
254: l_ret = (KeStringTemplate) l_rawRet;
255: else
256: return (l_rawRet);
257:
258: if (this .pem_appl.pcmf_isMDI() == true) {
259: StringBuffer l_mdiret = new StringBuffer();
260: this .pem_appl.pcm_orgactive = this .pem_appl.pcm_active;
261:
262: if (!((IUnPage) this .pem_appl.pcm_active)
263: .pcmf_isMaximized()) {
264: Iterator l_it = this .pem_appl.pcmf_getSubIterator();
265: Object l_sub = null;
266: while (l_it.hasNext()) {
267: l_sub = l_it.next();
268: if (l_sub instanceof MuGenericPage) {
269: if (((IUnPage) l_sub).pcmf_isMaximized())
270: l_mdiret = new StringBuffer();
271:
272: if (l_sub != this .pem_appl.pcm_active
273: && l_sub != this .pem_appl.pcm_Desktop) {
274: this .pem_appl.pcm_active = (UnComponent) l_sub;
275: l_mdiret.append(((MuGenericPage) l_sub)
276: .pcmf_execMdiNonActiveView()
277: .toString());
278: this .pem_appl.pcm_active = this .pem_appl.pcm_orgactive;
279: }
280: }
281: }
282: }
283: if (this .pem_appl.pcm_active != this .pem_appl.pcm_Desktop) {
284: l_mdiret
285: .append(((MuGenericPage) this .pem_appl.pcm_active)
286: .pcmf_execMdiNonActiveView().toString());
287: }
288:
289: l_ret = KeTools.pcmf_stringSubst(l_ret, "$BODY", l_mdiret
290: .toString());
291: }
292: if (this .pem_appl.pcm_resized) {
293: this .pem_appl.pcm_resized = false;
294: l_ret = KeTools.pcmf_stringSubst(l_ret, "$RESIZE",
295: ((MuGenericComponent) this .pem_appl.pcm_active)
296: .pcmf_getMarkupString("RESIZE"));
297: l_ret = KeTools.pcmf_stringSubst(l_ret, "$AW_WI", Integer
298: .toString(this .pem_appl.pcm_wi));
299: l_ret = KeTools.pcmf_stringSubst(l_ret, "$AW_HI", Integer
300: .toString(this .pem_appl.pcm_hi));
301: } else
302: l_ret = KeTools.pcmf_stringSubst(l_ret, "$RESIZE", "");
303:
304: l_ret = this .pcmf_renderDialogues(l_ret);
305: l_ret = this .pcmf_renderCtxMenues(l_ret);
306: l_ret = this .pcmf_renderScrollSettings(l_ret);
307: l_ret = this .pcmf_renderCalls(l_ret);
308: l_ret = this .pdmf_setFocusToWidget(l_ret);
309:
310: if (this .pem_appl.pcmf_getRenderer() == this )
311: l_ret = KeTools.pcmf_stringSubst(l_ret, "$TARGET", "_self");
312:
313: if (this .pem_appl.pcmf_isReleaseOnBrowserExit()) {
314: KeStringTemplate l_eType = ((MuGenericComponent) this .pem_appl.pcm_active)
315: .pcmf_getMarkupString("EXIT");
316: l_ret = KeTools.pcmf_stringSubst(l_ret, "$EXIT", l_eType
317: .toString());
318: } else
319: l_ret = KeTools.pcmf_stringSubst(l_ret, "$EXIT", "");
320:
321: if (this .pem_appl.pcmf_isMultipart()) {
322: KeStringTemplate l_eType = ((MuGenericComponent) this .pem_appl.pcm_active)
323: .pcmf_getMarkupString("ENCTYPE");
324: l_ret = KeTools.pcmf_stringSubst(l_ret, "$ENCTYPE", l_eType
325: .toString());
326: } else
327: l_ret = KeTools.pcmf_stringSubst(l_ret, "$ENCTYPE", "");
328:
329: l_ret = KeTools.pcmf_stringSubst(l_ret, "$CHARSET",
330: KeEnvironment.pcmf_getCharacterSet());
331: l_ret = KeTools
332: .pcmf_stringSubst(l_ret, "$REQCNT", Integer
333: .toString(this .pem_appl
334: .pcmf_getCurrentRequestNumber()));
335:
336: if (this .pem_appl.pcmf_getGenerateReshapeEvents()
337: && this .pem_appl.pcmf_isSubmit())
338: l_ret = KeTools
339: .pcmf_stringSubst(l_ret, "$SUBMIT", "SUBMIT");
340: else
341: l_ret = KeTools.pcmf_stringSubst(l_ret, "$SUBMIT", "");
342:
343: if (this .pem_appl.pcmf_getExternalCss() != null) {
344: KeStringTemplate l_csstpl = this .pem_kit.getCSS_DEF();
345:
346: l_csstpl = KeTools.pcmf_stringSubst(l_csstpl, "$URL",
347: pem_appl.pcmf_getHostName() + ":"
348: + Integer.toString(pem_appl.pcmf_getPort())
349: + "/" + pem_appl.pcmf_getRootUrl());
350: l_csstpl = KeTools.pcmf_stringSubst(l_csstpl, "$PROT",
351: pem_appl.pcmf_getProtocol());
352: l_csstpl = KeTools.pcmf_stringSubst(l_csstpl, "$REF",
353: this .pem_appl.pcmf_getExternalCss());
354:
355: l_ret = KeTools.pcmf_stringSubst(l_ret, "$CSSREF", l_csstpl
356: .toString());
357: } else
358: l_ret = KeTools.pcmf_stringSubst(l_ret, "$CSSREF", "");
359:
360: MuGenericApplication.NewBrowserWin l_ow = this .pem_appl
361: .pcmf_getOpenBrowserWindow();
362: if (l_ow != null) {
363: KeStringTemplate l_owStr = ((MuGenericComponent) this .pem_appl.pcm_active)
364: .pcmf_getMarkupString("OPENWIN");
365:
366: l_owStr.pcmf_beginTR();
367: l_owStr.pcmf_stringSubst("$WIDTH", Integer
368: .toString(l_ow.pdm_width));
369: l_owStr.pcmf_stringSubst("$HEIGHT", Integer
370: .toString(l_ow.pdm_height));
371: l_owStr.pcmf_stringSubst("$SB", l_ow.pdm_scroll ? "YES"
372: : "NO");
373: l_owStr.pcmf_stringSubst("$URL", l_ow.pdm_url);
374: l_owStr.pcmf_stringSubst("$TITLE", l_ow.pdm_title);
375: l_owStr.pcmf_endTR(true);
376:
377: l_ret = KeTools.pcmf_stringSubst(l_ret, "$OPENWIN", l_owStr
378: .toString());
379: } else
380: l_ret = KeTools.pcmf_stringSubst(l_ret, "$OPENWIN", "");
381:
382: return (l_ret);
383: }
384:
385: /**
386: * <p>
387: * Does...
388: * </p>
389: * <p>
390: *
391: * @return a Type with
392: * </p>
393: * <p>
394: * @param
395: * </p>
396: */
397: public void pcmf_removeFromRenderlist(MuGenericComponent xObj) {
398: return;
399: }
400:
401: /**
402: * <p>
403: * Does...
404: * </p>
405: * <p>
406: *
407: * @return a Type with
408: * </p>
409: * <p>
410: * @param
411: * </p>
412: */
413: public void pcmf_reqestFullRender() {
414: return;
415: }
416:
417: /**
418: * <p>
419: * Does...
420: * </p>
421: * <p>
422: *
423: * @return a Type with
424: * </p>
425: * <p>
426: * @param
427: * </p>
428: */
429: public KeStringTemplate pcmf_wrapMarkup(KeStringTemplate xHTML,
430: MuGenericComponent xObj) {
431: return (xHTML);
432: }
433:
434: /**
435: * <p>
436: * Does...
437: * </p>
438: * <p>
439: *
440: * @return a Type with
441: * </p>
442: * <p>
443: * @param
444: * </p>
445: */
446: public String pcmf_wrapMarkup(String xHTML, MuGenericComponent xObj) {
447: return (xHTML);
448: }
449:
450: protected KeStringTemplate pdmf_setFocusToWidget(
451: KeStringTemplate xRet) {
452: UnComponent l_fobj = ((MuGenericPage) this .pem_appl.pcm_active)
453: .pcmf_getFocusObject();
454:
455: if (l_fobj != null && l_fobj.pcmf_isDeleted() == false) {
456: xRet = KeTools.pcmf_stringSubst(xRet, "$FOCUS",
457: ((MuGenericPage) this .pem_appl.pcm_active)
458: .pcmf_getFocusObject().pcmf_getObjName());
459: ((MuGenericPage) this .pem_appl.pcm_active)
460: .pcmf_assignFocus(null);
461: } else
462: xRet = KeTools.pcmf_stringSubst(xRet, "$FOCUS", "null");
463:
464: return (xRet);
465: }
466:
467: public KeStringTemplate pcmf_renderCalls(KeStringTemplate xRet) {
468: if (this .pem_commands.size() == 0) {
469: xRet = KeTools.pcmf_stringSubst(xRet, "$CALLS", "");
470: return (xRet);
471: }
472:
473: Iterator l_sit = this .pem_commands.iterator();
474: StringBuffer l_calls = new StringBuffer();
475: while (l_sit.hasNext()) {
476: String l_call = l_sit.next().toString();
477: l_calls.append(l_call);
478: }
479: ;
480:
481: xRet = KeTools.pcmf_stringSubst(xRet, "$CALLS", l_calls
482: .toString());
483: this .pem_commands.clear();
484:
485: return (xRet);
486: }
487:
488: public KeStringTemplate pcmf_renderScrollSettings(
489: KeStringTemplate xRet) {
490: Iterator l_sit = this .pem_scrollPos.keySet().iterator();
491: MuGenericScrollController l_scrCrt = null;
492: KeStringTemplate l_tpl = null;
493:
494: while (l_sit.hasNext()) {
495: l_scrCrt = (MuGenericScrollController) l_sit.next();
496: if (l_scrCrt.pcmf_isDeleted())
497: continue;
498:
499: l_tpl = ((MuGenericComponent) this .pem_appl.pcm_active)
500: .pcmf_getMarkupString("SETSCROLL");
501:
502: l_tpl.pcmf_beginTR();
503: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$NAME", l_scrCrt
504: .pcmf_getMyObj().pcmf_getObjName());
505: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$PX", Integer
506: .toString(l_scrCrt.pcmf_getX()));
507: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$PY", Integer
508: .toString(l_scrCrt.pcmf_getY()));
509: l_tpl.pcmf_endTR(true);
510:
511: xRet = KeTools.pcmf_stringSubstAppend(xRet,
512: "$SETSCROLLPOS", l_tpl.toString(), "$SETSCROLLPOS");
513: l_scrCrt.pcmf_setPropChanged(false);
514: }
515: ;
516:
517: xRet = KeTools.pcmf_stringSubst(xRet, "$SETSCROLLPOS", "");
518: this .pem_scrollPos.clear();
519:
520: return (xRet);
521: }
522:
523: public int pcmf_getRenderState() {
524: return (IMuGenericApplicationOutput.FULLRENDER);
525: }
526:
527: public boolean pcmf_canHandleIForm() {
528: return (true);
529: }
530:
531: public void pcmf_rerenderDialogs() {
532: }
533:
534: public boolean pcmf_checkDialogStackTop(IUnDialog xToCheck) {
535: ArrayList l_list = new ArrayList(this .pem_dlgs.keySet());
536: if (l_list.indexOf(xToCheck) == l_list.size() - 1)
537: return (true);
538:
539: return (false);
540: }
541:
542: public void pcmf_doFullRender() {
543: this .pem_appl.pcmf_repaint();
544: }
545:
546: public void pcmf_addCommand(String xCommand) {
547: this.pem_commands.add(xCommand);
548: }
549: }
|