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 HtmlListBoxRenderer implements IKeView {
043: private MuGenericCache pem_cache = new MuGenericCache();
044: private MuGenericApplication pem_appl = null;
045: protected boolean pdm_setSize = true;
046:
047: public boolean pcmf_supportsCaching() {
048: return (true);
049: }
050:
051: public void pcmf_clearCache() {
052: this .pem_cache.pcmf_clearCache();
053: }
054:
055: private KeStringTemplate pcmf_insertFont(UnFontDescriptor xFont) {
056: KeStringTemplate l_ret = null;
057: UnFontDescriptor l_font = xFont;
058:
059: if (l_font == null)
060: l_font = this .pem_appl.pcmf_getFont();
061:
062: if (l_font != null) {
063: l_ret = pem_appl.pcmf_getTemplateKit().getFONT();
064:
065: KeTools.pcmf_stringSubst(l_ret, "$FNAME", l_font
066: .pcmf_getFontName());
067: KeTools.pcmf_stringSubst(l_ret, "$FSIZE", Integer
068: .toString(l_font.pcmf_getFontSize()));
069:
070: switch (l_font.pcmf_getFontStyle()) {
071: case Font.ITALIC:
072: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "italic");
073: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
074: break;
075: case Font.BOLD:
076: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "bold");
077: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
078: break;
079: default:
080: KeTools.pcmf_stringSubst(l_ret, "$BOLD", "normal");
081: KeTools.pcmf_stringSubst(l_ret, "$FSTYLE", "normal");
082: }
083: }
084: return l_ret;
085: }
086:
087: public void pcmf_reset() {
088: this .pem_appl = null;
089: pdm_setSize = true;
090: };
091:
092: public void pcmf_activateCache(boolean xAc) {
093: this .pem_cache.pcmf_activateThisCache(xAc);
094: return;
095: }
096:
097: public Object pcmf_output(KeTreeElement xTreeEl) {
098: MuGenericListBox html_xTreeEl = (MuGenericListBox) xTreeEl;
099:
100: // @@
101:
102: if (this .pdm_setSize == true
103: && html_xTreeEl.pcmf_getFixedSize() == null) {
104: if (html_xTreeEl.pcmf_getVisibleRows() != 0) {
105: this .pdm_setSize = false;
106: UnFontDescriptor l_font = html_xTreeEl.pcmf_getFont();
107: if (l_font != null)
108: html_xTreeEl.pcmf_setFixedSize(-1, (l_font
109: .pcmf_getFontSize() + 4)
110: * html_xTreeEl.pcmf_getVisibleRows(),
111: UnFixedSize.FIX_SIZE);
112: else
113: html_xTreeEl.pcmf_setFixedSize(-1,
114: 16 * html_xTreeEl.pcmf_getVisibleRows(),
115: UnFixedSize.FIX_SIZE);
116: }
117: }
118: if (pem_appl == null) {
119: Object l_appl = KeRegisteredObject
120: .pcmf_getObjByName(IUnApplication.MY_APPL);
121: if (l_appl instanceof MuGenericApplication)
122: pem_appl = (MuGenericApplication) l_appl;
123: else
124: pem_appl = (MuGenericApplication) html_xTreeEl
125: .pcmf_getAppl();
126: }
127:
128: pem_appl.pcmf_getRenderer().pcmf_addScrollPos(
129: html_xTreeEl.pcmf_getScrollCrt());
130:
131: // @@
132:
133: Iterator it = html_xTreeEl.pcmf_getValues().values().iterator();
134: Iterator itK = html_xTreeEl.pcmf_getValues().keySet()
135: .iterator();
136: String l_value = null;
137: Object l_label = null;
138: KeStringTemplate l_templ = html_xTreeEl
139: .pcmf_getMarkupString("MAIN");
140: KeStringTemplate l_templ2 = html_xTreeEl
141: .pcmf_getMarkupString("ITEMS");
142: KeStringTemplate l_templ4 = html_xTreeEl
143: .pcmf_getMarkupString("SELECTED");
144: KeStringTemplate l_templ5 = html_xTreeEl
145: .pcmf_getMarkupString("NOTSELECTED");
146: KeStringTemplate l_string = new KeStringTemplate(l_templ2);
147:
148: l_templ = html_xTreeEl.pcmf_insertToolTip(l_templ);
149:
150: String l_fgBuffer = html_xTreeEl.pcmf_getFgColor();
151: String l_bgBuffer = html_xTreeEl.pcmf_getBgColor();
152: if (xTreeEl.pcmf_isDisabled()) {
153: html_xTreeEl.pcmf_setFgColor("gray");
154: html_xTreeEl.pcmf_setBgColor("lightgray");
155: }
156:
157: l_templ = html_xTreeEl
158: .pcmf_insertColorandFontandBorder(l_templ);
159:
160: if (xTreeEl.pcmf_isDisabled()) {
161: html_xTreeEl.pcmf_setFgColor(l_fgBuffer);
162: html_xTreeEl.pcmf_setBgColor(l_bgBuffer);
163: }
164:
165: l_templ = html_xTreeEl.pcmf_insertPosition(l_templ);
166: l_templ = html_xTreeEl.pcmf_insertChannelandMenu(l_templ);
167: l_templ = html_xTreeEl.pcmf_insertTabIndex(l_templ);
168:
169: KeStringTemplate l_templ3 = html_xTreeEl
170: .pcmf_getMarkupString("ISCONTAINER");
171: boolean l_iscont = l_templ3 != null
172: && l_templ3.toString().trim().equals("true");
173:
174: Object l_mValue = html_xTreeEl.pcmf_getValue();
175:
176: int l_num = 0;
177: while (itK.hasNext()) {
178: l_value = (String) itK.next();
179: l_label = it.next();
180:
181: l_string.pcmf_beginTR();
182:
183: KeTools.pcmf_stringSubst(l_string, "$ITEM_FONT", "");
184:
185: if (l_mValue != null && l_mValue.equals(l_value)) {
186: String l_selString = null;
187: if (l_templ4 != null)
188: l_selString = l_templ4.toString();
189: else
190: l_selString = "selected";
191:
192: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
193: l_selString);
194: if (l_mValue != null) {
195: KeTools.pcmf_stringSubst(l_templ, "$VALUE_SEL",
196: l_value);
197: KeTools.pcmf_stringSubst(l_templ, "$STRING_SEL",
198: l_label.toString());
199: KeTools.pcmf_stringSubst(l_templ, "$SELNUM",
200: Integer.toString(l_num));
201: }
202: } else
203: KeTools.pcmf_stringSubst(l_string, "$SELECTED",
204: l_templ5);
205:
206: KeTools.pcmf_stringSubst(l_string, "$VALUE", l_value);
207: KeTools.pcmf_stringSubst(l_string, "$NUM", Integer
208: .toString(l_num++));
209:
210: if (l_label instanceof String)
211: l_label = KeTools.pcmf_deRefObj(l_label.toString());
212:
213: if (l_label instanceof MuGenericComponent && l_iscont) {
214: l_label = ((MuGenericComponent) l_label)
215: .pcmf_execView().toString();
216: KeTools.pcmf_stringSubst(l_string, "$STRING", l_label
217: .toString());
218: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
219: html_xTreeEl.pcmf_getFgColor());
220: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
221: html_xTreeEl.pcmf_getBgColor());
222: } else if (l_label instanceof IKeViewable) {
223: IKeView l_view = ((IKeViewable) l_label).pcmf_getView();
224:
225: if (l_view instanceof UnIconValueView) {
226: UnIconValueView l_iv = (UnIconValueView) l_view;
227:
228: if (l_iv.pcmf_getFg() != null)
229: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
230: l_iv.pcmf_getFg());
231: else
232: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
233: html_xTreeEl.pcmf_getFgColor());
234:
235: if (l_iv.pcmf_getBg() != null)
236: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
237: l_iv.pcmf_getBg());
238: else
239: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
240: html_xTreeEl.pcmf_getBgColor());
241:
242: if (l_iscont) {
243: KeStringTemplate l_fstring = this
244: .pcmf_insertFont(l_iv
245: .pcmf_getFontDesc());
246: if (l_fstring != null)
247: KeTools.pcmf_stringSubst(l_string,
248: "$ITEM_FONT", l_fstring.toString());
249:
250: if (l_iv.pcmf_getStdIcon() != null) {
251: l_label = l_iv.pcmf_getStdIcon()
252: .pcmf_getUnComponent()
253: .pcmf_execView()
254: + l_label.toString();
255: KeTools.pcmf_stringSubst(l_string,
256: "$STRING", l_label.toString());
257: } else
258: KeTools.pcmf_stringSubst(l_string,
259: "$STRING", l_label.toString());
260: } else
261: KeTools.pcmf_stringSubst(l_string, "$STRING",
262: l_label.toString());
263: } else {
264: KeTools.pcmf_stringSubst(l_string, "$STRING",
265: l_label.toString());
266: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
267: html_xTreeEl.pcmf_getFgColor());
268: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
269: html_xTreeEl.pcmf_getBgColor());
270: }
271: } else {
272: KeTools.pcmf_stringSubst(l_string, "$STRING", l_label
273: .toString());
274: KeTools.pcmf_stringSubst(l_string, "$CFGCOL",
275: html_xTreeEl.pcmf_getFgColor());
276: KeTools.pcmf_stringSubst(l_string, "$CBGCOL",
277: html_xTreeEl.pcmf_getBgColor());
278: }
279:
280: l_string.pcmf_endTR(true);
281:
282: if (itK.hasNext())
283: l_string.pcmf_stringAddEnd(new KeStringTemplate(
284: l_templ2));
285: }
286: ;
287:
288: l_templ.pcmf_beginTR();
289:
290: KeTools.pcmf_stringSubst(l_templ, "$VALUE_SEL", "");
291: KeTools.pcmf_stringSubst(l_templ, "$STRING_SEL", "");
292: KeTools.pcmf_stringSubst(l_templ, "$SELNUM", "");
293:
294: if (html_xTreeEl.pcmf_getValues().size() != 0)
295: KeTools.pcmf_stringSubst(l_templ, "$ITEMS", l_string);
296:
297: if (html_xTreeEl.pcmf_isSubmit()) {
298: KeStringTemplate l_stpl = html_xTreeEl
299: .pcmf_getMarkupString("SUBMIT");
300: if (l_stpl != null)
301: KeTools.pcmf_stringSubst(l_templ, "$SUBMIT", l_stpl);
302: else
303: KeTools.pcmf_stringSubst(l_templ, "$SUBMIT",
304: html_xTreeEl.pcmf_getKit().getSUBMIT());
305: } else
306: KeTools.pcmf_stringSubst(l_templ, "$SUBMIT", "");
307:
308: KeTools.pcmf_stringSubst(l_templ, "$NAME", html_xTreeEl
309: .pcmf_getObjName());
310: KeTools.pcmf_stringSubst(l_templ, "$SIZE", Integer
311: .toString(html_xTreeEl.pcmf_getVisibleRows()));
312:
313: KeTools.pcmf_stringSubst(l_templ, "$PNAME", html_xTreeEl
314: .pcmf_getScrollCrt().pcmf_getObjName());
315: KeTools.pcmf_stringSubst(l_templ, "$POS_SCROLL", html_xTreeEl
316: .pcmf_getScrollCrt().pcmf_getValue().toString());
317: KeTools.pcmf_stringSubst(l_templ, "$OID", html_xTreeEl
318: .pcmf_getObjName());
319:
320: if (html_xTreeEl.pcmf_isReadOnly())
321: KeTools.pcmf_stringSubst(l_templ, "$READONLY", "readonly");
322: else
323: KeTools.pcmf_stringSubst(l_templ, "$READONLY", "");
324:
325: if (html_xTreeEl.pcmf_isDisabled()) {
326: KeTools.pcmf_stringSubst(l_templ, "$DISABLED", "disabled");
327: KeTools.pcmf_stringSubst(l_templ, "$READONLY", "readonly");
328: } else
329: KeTools.pcmf_stringSubst(l_templ, "$DISABLED", "");
330:
331: l_templ.pcmf_endTR(true);
332:
333: // @@
334:
335: return (l_templ);
336: };
337:
338: public void pcmf_setSize(boolean xSize) {
339: pdm_setSize = xSize;
340: }
341:
342: public Object pcmf_execView(KeTreeElement xTreeEl) {
343: return (xTreeEl.pcmf_execView());
344: };
345: };
|