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