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.renderer;
032:
033: import java.awt.*;
034: import java.util.*;
035:
036: import de.ug2t.channel.markup.generic.*;
037: import de.ug2t.kernel.*;
038: import de.ug2t.unifiedGui.*;
039: import de.ug2t.unifiedGui.interfaces.*;
040: import de.ug2t.unifiedGui.views.*;
041:
042: public final class HtmlTreeViewRenderer implements IKeView {
043: private MuGenericApplication pem_appl = null;
044: private IKePropertyChangeListener pem_listen = null;
045:
046: public void pcmf_reset() {
047: this .pem_appl = null;
048: };
049:
050: public void pcmf_clearCache() {
051: this .pem_cache.pcmf_clearCache();
052: }
053:
054: public boolean pcmf_supportsCaching() {
055: return (true);
056: }
057:
058: public void pcmf_activateCache(boolean xAc) {
059: this .pem_cache.pcmf_activateThisCache(xAc);
060: return;
061: }
062:
063: private KeStringTemplate pcmf_insertFont(KeStringTemplate xString,
064: UnFontDescriptor xFont) {
065: KeStringTemplate l_ret = null;
066: UnFontDescriptor l_font = xFont;
067:
068: if (l_font == null)
069: l_font = this .pem_appl.pcmf_getFont();
070:
071: if (l_font == null) {
072: l_ret = KeTools.pcmf_stringSubst(xString, "$FONT", "");
073: } else {
074: l_ret = KeTools.pcmf_stringSubst(xString, "$FONT", pem_appl
075: .pcmf_getTemplateKit().getFONT());
076:
077: l_ret.pcmf_beginTR();
078:
079: KeTools.pcmf_stringSubst(l_ret, "$FNAME", l_font
080: .pcmf_getFontName());
081: KeTools.pcmf_stringSubst(l_ret, "$FSIZE", Integer
082: .toString(l_font.pcmf_getFontSize()));
083:
084: switch (l_font.pcmf_getFontStyle()) {
085: case Font.ITALIC:
086: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "italic");
087: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
088: break;
089: case Font.BOLD:
090: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "bold");
091: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
092: break;
093: default:
094: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
095: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
096: }
097:
098: l_ret.pcmf_endTR(true);
099: }
100: return l_ret;
101: }
102:
103: public KeStringTemplate pcmf_buildLine(KeTreeElement xTreeEl,
104: KeStringTemplate xBlank, KeStringTemplate xLitem,
105: KeStringTemplate xIitem, KeStringTemplate xItem,
106: KeStringTemplate xIteme, KeStringTemplate xItemc,
107: KeStringTemplate xSStyle, KeStringTemplate xNSStyle,
108: KeStringTemplate xLoItem, KeStringTemplate xLolItem,
109: KeStringTemplate xLitemM, KeStringTemplate xLitem_D,
110: KeStringTemplate xLitemM_D, KeStringTemplate xItem_D,
111: String xName, KeTreeNode xRoot, MuGenericTreeView xTree,
112: int xIndent) {
113: if (this .pem_listen == null)
114: this .pem_listen = new UnPropertyPropagationListener(xTree,
115: true);
116:
117: KeStringTemplate l_Blank = new KeStringTemplate(xBlank);
118:
119: KeStringTemplate l_Litem = null;
120: KeStringTemplate l_LitemM = null;
121: KeStringTemplate l_string = null;
122:
123: if (xTree.pcmf_isDisabled()) {
124: l_Litem = new KeStringTemplate(xLitem_D);
125: l_LitemM = new KeStringTemplate(xLitemM_D);
126: l_string = new KeStringTemplate(xItem_D);
127: } else {
128: l_Litem = new KeStringTemplate(xLitem);
129: l_LitemM = new KeStringTemplate(xLitemM);
130: l_string = new KeStringTemplate(xItem);
131: }
132:
133: KeStringTemplate l_Iitem = new KeStringTemplate(xIitem);
134: KeStringTemplate l_Iteme = new KeStringTemplate(xIteme);
135: KeStringTemplate l_Itemc = new KeStringTemplate(xItemc);
136: KeStringTemplate l_xSStyle = new KeStringTemplate(xSStyle);
137: KeStringTemplate l_loItem = new KeStringTemplate(xLoItem);
138: KeStringTemplate l_lolItem = new KeStringTemplate(xLolItem);
139:
140: Iterator l_it = null;
141: Iterator l_itK = null;
142: KeStringTemplate l_myLItem = null;
143: KeStringTemplate l_myLItemM = null;
144: KeTreeNode l_parent = xTreeEl.pcmf_getParentNode();
145:
146: KeTreeNode l_o1 = null;
147: KeTreeElement l_o2 = null;
148: KeTreeElement l_o4 = null;
149:
150: // Eventchannel wird nicht angezeigt
151: if (xTreeEl instanceof IUnEventChannel)
152: return (new KeStringTemplate(""));
153:
154: l_string.pcmf_beginTR();
155:
156: boolean l_renderName = true;
157:
158: if (xTreeEl instanceof MuGenericComponent
159: && !(xTreeEl instanceof MuGenericTreeView)) {
160: KeTools.pcmf_stringSubst(l_string, "$OBJ",
161: (String) ((MuGenericComponent) xTreeEl)
162: .pcmf_execView());
163: l_renderName = false;
164: } else if (xTreeEl.pcmf_getValue() instanceof MuGenericComponent
165: && !(xTreeEl instanceof MuGenericTreeView)) {
166: KeTools.pcmf_stringSubst(l_string, "$OBJ",
167: (String) ((MuGenericComponent) xTreeEl
168: .pcmf_getValue()).pcmf_execView());
169:
170: ((MuGenericComponent) xTreeEl.pcmf_getValue())
171: .pcmf_removePropertyChangedListener(pem_listen);
172: ((MuGenericComponent) xTreeEl.pcmf_getValue())
173: .pcmf_addPropertyChangedListener(pem_listen);
174: l_renderName = false;
175: } else if (xTreeEl.pcmf_getValue() != null
176: && KeTools.pcmf_deRefObj(xTreeEl.pcmf_getValue()
177: .toString()) instanceof MuGenericComponent
178: && !(xTreeEl instanceof MuGenericTreeView)) {
179: KeLog.pcmf_log("ug2t",
180: "late add (during render) of item in tree, cache does not Work: "
181: + xTreeEl.pcmf_getValue().toString(), this ,
182: KeLog.MESSAGE);
183:
184: KeTools.pcmf_stringSubst(l_string, "$OBJ",
185: ((MuGenericComponent) KeTools.pcmf_deRefObj(xTreeEl
186: .pcmf_getValue().toString()))
187: .pcmf_execView().toString());
188:
189: xTreeEl.pcmf_setValue(KeTools.pcmf_deRefObj(xTreeEl
190: .pcmf_getValue().toString()));
191: xTreeEl.pcmf_setValueOwnerShip(true);
192:
193: ((MuGenericComponent) xTreeEl.pcmf_getValue())
194: .pcmf_removePropertyChangedListener(pem_listen);
195: ((MuGenericComponent) xTreeEl.pcmf_getValue())
196: .pcmf_addPropertyChangedListener(pem_listen);
197: l_renderName = false;
198: } else {
199: KeTools.pcmf_stringSubst(l_string, "$OBJ", "");
200: KeTools.pcmf_stringSubst(l_string, "$VALUE", xTreeEl
201: .pcmf_getValue() == null ? "" : xTreeEl
202: .pcmf_getValue().toString());
203: }
204: ;
205:
206: l_myLItem = KeTools.pcmf_stringSubst(l_Litem, "$CLICKED",
207: xTreeEl.pcmf_getObjName());
208: l_myLItemM = KeTools.pcmf_stringSubst(l_LitemM, "$CLICKED",
209: xTreeEl.pcmf_getObjName());
210:
211: if (xTree.pcmf_isMultiSelection()) {
212: boolean l_contain = xTree.pcmf_getValues().pcmf_contains(
213: xTreeEl);
214: if (l_contain)
215: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
216: l_xSStyle.toString());
217: else
218: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
219: new KeStringTemplate(xNSStyle));
220: } else {
221: if (xTree.pcmf_getValue() == xTreeEl)
222: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
223: l_xSStyle.toString());
224: else
225: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
226: new KeStringTemplate(xNSStyle));
227: }
228:
229: KeTools.pcmf_stringSubst(l_string, "$CLICKED", xTreeEl
230: .pcmf_getObjName());
231: KeTools.pcmf_stringSubst(l_string, "$ORDERSYS_ID", xName);
232:
233: if (l_renderName)
234: KeTools.pcmf_stringSubst(l_string, "$NODENAME", xTreeEl
235: .toString());
236: else
237: KeTools.pcmf_stringSubst(l_string, "$NODENAME", " ");
238:
239: l_string.pcmf_endTR(true);
240:
241: if (xTreeEl instanceof MuGenericComponent == false) {
242: if (xTreeEl instanceof KeTreeNode
243: && !((KeTreeNode) xTreeEl).pcmf_isHidden()
244: && xTreeEl.pcmf_getChildCount() > 0) {
245: IKeView l_view = xTreeEl.pcmf_getView();
246: if (l_view instanceof UnIconValueView
247: && !(xTreeEl instanceof MuGenericTreeView)
248: && ((UnIconValueView) l_view)
249: .pcmf_getOpenIcon() != null)
250: l_string
251: .pcmf_stringAddFront(((UnIconValueView) l_view)
252: .pcmf_getOpenIcon()
253: .pcmf_getUnComponent()
254: .pcmf_execView().toString());
255: else
256: l_string.pcmf_stringAddFront(l_Iteme);
257: } else if (xTreeEl.pcmf_getChildCount() > 0) {
258: IKeView l_view = xTreeEl.pcmf_getView();
259: if (l_view instanceof UnIconValueView
260: && !(xTreeEl instanceof MuGenericTreeView)
261: && ((UnIconValueView) l_view)
262: .pcmf_getCloseIcon() != null)
263: l_string
264: .pcmf_stringAddFront(((UnIconValueView) l_view)
265: .pcmf_getCloseIcon()
266: .pcmf_getUnComponent()
267: .pcmf_execView().toString());
268: else
269: l_string.pcmf_stringAddFront(l_Itemc);
270: } else {
271: IKeView l_view = xTreeEl.pcmf_getView();
272: if (l_view instanceof UnIconValueView
273: && !(xTreeEl instanceof MuGenericTreeView)
274: && ((UnIconValueView) l_view).pcmf_getStdIcon() != null)
275: l_string
276: .pcmf_stringAddFront(((UnIconValueView) l_view)
277: .pcmf_getStdIcon()
278: .pcmf_getUnComponent()
279: .pcmf_execView().toString());
280: else
281: l_string.pcmf_stringAddFront(l_Itemc);
282: }
283: }
284:
285: IKeView l_view = xTreeEl.pcmf_getView();
286: if (l_view instanceof UnIconValueView
287: && !(xTreeEl instanceof MuGenericTreeView)) {
288: UnIconValueView l_iv = (UnIconValueView) l_view;
289:
290: l_string = this .pcmf_insertFont(l_string, l_iv
291: .pcmf_getFontDesc());
292:
293: if (l_iv.pcmf_getFg() != null)
294: KeTools.pcmf_stringSubst(l_string, "$CFGCOL", l_iv
295: .pcmf_getFg());
296: else if (xTreeEl instanceof UnComponent)
297: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
298: ((UnComponent) xTreeEl).pcmf_getFgColor());
299: else
300: KeTools.pcmf_stringSubst(l_string, "$CFGCOL", xTree
301: .pcmf_getFgColor());
302:
303: if (l_iv.pcmf_getBg() != null)
304: KeTools.pcmf_stringSubst(l_string, "$CBGCOL", l_iv
305: .pcmf_getBg());
306: else if (xTreeEl instanceof UnComponent)
307: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
308: ((UnComponent) xTreeEl).pcmf_getBgColor());
309: else
310: KeTools.pcmf_stringSubst(l_string, "$CBGCOL", xTree
311: .pcmf_getBgColor());
312: } else {
313: l_string = this .pcmf_insertFont(l_string, null);
314: KeTools.pcmf_stringSubst(l_string, "$CFGCOL", xTree
315: .pcmf_getFgColor());
316: KeTools.pcmf_stringSubst(l_string, "$CBGCOL", xTree
317: .pcmf_getBgColor());
318: }
319:
320: KeStringTemplate l_strBuf = new KeStringTemplate("");
321: l_strBuf.pcmf_stringAddEnd(l_string);
322: for (int i = 1; i <= xIndent; i++) {
323: l_o1 = ((KeTreeNode) xTreeEl.pcmf_getParentGeneration(i));
324: l_o2 = xTreeEl.pcmf_getParentGeneration(i - 1);
325: ArrayList l_alist = l_o1.pcmf_getAllSubs();
326: l_o4 = (KeTreeElement) l_alist.get(l_alist.size() - 1);
327:
328: if (l_parent != null && i == 1) {
329: if (xTreeEl.pcmf_getChildCount() == 0
330: && l_parent.pcmf_indexOf(xTreeEl) == l_parent
331: .pcmf_getChildCount() - 1)
332: l_strBuf.pcmf_stringAddFront(l_lolItem);
333: else if (xTreeEl.pcmf_getChildCount() == 0)
334: l_strBuf.pcmf_stringAddFront(l_loItem);
335: else if (((KeTreeNode) xTreeEl).pcmf_isHidden())
336: l_strBuf.pcmf_stringAddFront(l_myLItem);
337: else
338: l_strBuf.pcmf_stringAddFront(l_myLItemM);
339: } else {
340: if (l_o2 == l_o4)
341: // l_string = l_Blank + l_string;
342: l_strBuf.pcmf_stringAddFront(l_Blank);
343: else
344: // l_string = l_Iitem + l_string;
345: l_strBuf.pcmf_stringAddFront(l_Iitem);
346: }
347: ;
348: }
349: ;
350: l_string = l_strBuf;
351: if (xTreeEl instanceof KeTreeNode
352: && !((KeTreeNode) xTreeEl).pcmf_isHidden()) {
353: l_it = ((KeTreeNode) xTreeEl).pcmf_getAllSubs().iterator();
354: l_itK = ((KeTreeNode) xTreeEl).pcmf_getAllSubNames()
355: .iterator();
356:
357: while (l_it.hasNext())
358: l_string.pcmf_stringAddEnd(pcmf_buildLine(
359: (KeTreeElement) l_it.next(), xBlank, xLitem,
360: xIitem, xItem, xIteme, xItemc, xSStyle,
361: xNSStyle, xLoItem, xLolItem, xLitemM, xLitem_D,
362: xLitemM_D, xItem_D, (String) l_itK.next(),
363: xRoot, xTree, xIndent + 1));
364: }
365: ;
366:
367: xTree.pcmf_incRendererLines();
368:
369: return (l_string);
370: };
371:
372: private MuGenericCache pem_cache = new MuGenericCache();
373:
374: public Object pcmf_output(KeTreeElement xTreeEl) {
375: MuGenericTreeView l_tree = (MuGenericTreeView) xTreeEl;
376:
377: // @@
378:
379: if (pem_appl == null) {
380: Object l_appl = KeRegisteredObject
381: .pcmf_getObjByName(IUnApplication.MY_APPL);
382: if (l_appl instanceof MuGenericApplication)
383: pem_appl = (MuGenericApplication) l_appl;
384: else
385: pem_appl = (MuGenericApplication) l_tree.pcmf_getAppl();
386: }
387:
388: this .pem_appl.pcmf_getRenderer().pcmf_addScrollPos(
389: l_tree.pcmf_getScrollCrt());
390:
391: // @@
392:
393: l_tree.pcmf_setRendererLines(0);
394: KeStringTemplate l_retval = null;
395:
396: KeStringTemplate l_string = l_tree.pcmf_getMarkupString("MAIN");
397:
398: KeStringTemplate l_itemc = l_tree.pcmf_getMarkupString("ITEMC");
399: KeStringTemplate l_iteme = l_tree.pcmf_getMarkupString("ITEME");
400: KeStringTemplate l_item = l_tree.pcmf_getMarkupString("ITEM");
401: KeStringTemplate l_iitem = l_tree.pcmf_getMarkupString("IITEM");
402: KeStringTemplate l_litem = l_tree.pcmf_getMarkupString("LITEM");
403: KeStringTemplate l_litemM = l_tree
404: .pcmf_getMarkupString("LITEMM");
405: KeStringTemplate l_blank = l_tree.pcmf_getMarkupString("BLANK");
406: KeStringTemplate l_sstyle = l_tree
407: .pcmf_getMarkupString("SSTYLE");
408: KeStringTemplate l_nsstyle = l_tree
409: .pcmf_getMarkupString("NSSTYLE");
410: KeStringTemplate l_loitem = l_tree
411: .pcmf_getMarkupString("LOITEM");
412: KeStringTemplate l_lolitem = l_tree
413: .pcmf_getMarkupString("LOLITEM");
414:
415: KeStringTemplate l_litem_D = l_tree
416: .pcmf_getMarkupString("LITEM_D");
417: KeStringTemplate l_litemM_D = l_tree
418: .pcmf_getMarkupString("LITEMM_D");
419: KeStringTemplate l_item_D = l_tree
420: .pcmf_getMarkupString("ITEM_D");
421:
422: l_string = l_tree.pcmf_insertToolTip(l_string);
423: l_string = l_tree.pcmf_insertColorandFontandBorder(l_string);
424: l_string = l_tree.pcmf_insertPosition(l_string);
425: l_string = l_tree.pcmf_insertChannelandMenu(l_string);
426:
427: l_retval = pcmf_buildLine(l_tree.pcmf_getRoot(), l_blank,
428: l_litem, l_iitem, l_item, l_iteme, l_itemc, l_sstyle,
429: l_nsstyle, l_loitem, l_lolitem, l_litemM, l_litem_D,
430: l_litemM_D, l_item_D, "ROOT", l_tree.pcmf_getRoot(),
431: l_tree, 0);
432:
433: l_string.pcmf_beginTR();
434:
435: KeTools.pcmf_stringSubst(l_string, "$ROWS", l_retval);
436: KeTools.pcmf_stringSubst(l_string, "$URL", pem_appl
437: .pcmf_getHostName()
438: + ":"
439: + Integer.toString(pem_appl.pcmf_getPort())
440: + "/"
441: + pem_appl.pcmf_getRootUrl());
442: KeTools.pcmf_stringSubst(l_string, "$PROT", pem_appl
443: .pcmf_getProtocol());
444: KeTools.pcmf_stringSubst(l_string, "$NAME", l_tree
445: .pcmf_getObjName());
446: KeTools.pcmf_stringSubst(l_string, "$OID", l_tree
447: .pcmf_getObjName());
448: KeTools.pcmf_stringSubst(l_string, "$PNAME", l_tree
449: .pcmf_getScrollCrt().pcmf_getObjName());
450: KeTools.pcmf_stringSubst(l_string, "$POS_SCROLL", l_tree
451: .pcmf_getScrollCrt().pcmf_getValue().toString());
452:
453: l_string.pcmf_endTR(true);
454:
455: // @@
456:
457: return (l_string);
458: };
459:
460: public Object pcmf_execView(KeTreeElement xTreeEl) {
461: return (xTreeEl.pcmf_execView());
462: };
463: };
|