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 final class MuGenericRadioPanel extends MuGenericContainer
042: implements IUnRadioPanel, IKePoolable {
043: private HashMap pem_values = new LinkedHashMap();
044: private KeStringTemplate pem_body = null;
045: protected IUnImage pdm_bgImg = null;
046: private boolean pem_scroll = true;
047: protected MuGenericScrollController pdm_scrCrt = null;
048:
049: private IKeView pem_view = new HtmlRadioPanelRenderer();
050:
051: protected final class MuRadioPanelHelperView implements IKeView {
052: private int pem_idx = 0;
053:
054: public boolean pcmf_supportsCaching() {
055: return (false);
056: }
057:
058: public void pcmf_clearCache() {
059: throw (new UnsupportedOperationException());
060: }
061:
062: public void pcmf_activateCache(boolean xAc) {
063: throw (new UnsupportedOperationException());
064: }
065:
066: public MuRadioPanelHelperView(int xIdx) {
067: this .pem_idx = xIdx;
068:
069: return;
070: }
071:
072: public Object pcmf_execView(KeTreeElement xTreeEl) {
073: return (xTreeEl.pcmf_execView());
074: };
075:
076: public Object pcmf_output(KeTreeElement xTreeEl) {
077: return (MuGenericRadioPanel.this .pcmf_getOtion(pem_idx));
078: }
079: }
080:
081: public void pcmf_setGuiObjPosition(String xName, int xPos,
082: int yPos, int xWi, int xHi, String xAlign) {
083: MuGenericRaw l_raw = (MuGenericRaw) this .pcmf_getSubNode(xName);
084: if (l_raw != null) {
085: if (l_raw.pcmf_getXPos() == xPos
086: && l_raw.pcmf_getYPos() == yPos
087: && l_raw.pcmf_getWi() == xWi
088: && l_raw.pcmf_getHi() == xHi
089: && l_raw.pcmf_getAlign().equals(xAlign))
090: return;
091:
092: l_raw.pcmf_setPosition(xPos, yPos, xWi, xHi, xAlign);
093: this .pcmf_setPropChanged(true);
094: }
095: return;
096: };
097:
098: public void pcmf_setGuiObjPosition(UnComponent xObj, int xPos,
099: int yPos, int xWi, int xHi, String xAlign) {
100: MuGenericRaw l_raw = (MuGenericRaw) xObj;
101:
102: if (l_raw.pcmf_getXPos() == xPos
103: && l_raw.pcmf_getYPos() == yPos
104: && l_raw.pcmf_getWi() == xWi
105: && l_raw.pcmf_getHi() == xHi
106: && l_raw.pcmf_getAlign().equals(xAlign))
107: return;
108:
109: l_raw.pcmf_setPosition(xPos, yPos, xWi, xHi, xAlign);
110: this .pcmf_setPropChanged(true);
111:
112: return;
113: };
114:
115: public MuGenericRadioPanel(String xName, String xValue,
116: String xString, ACoDataGetter xTplGetter, Object xTplName,
117: MuGenericApplication xAppl) throws Exception {
118: super (xName, xTplGetter, xTplName, xAppl);
119:
120: this .pcmf_setView(pem_view);
121: this .pcmf_setValue(xValue);
122: this .pcmf_setFill(true, true);
123: this .pdm_getMaxSpace = true;
124:
125: this .pdm_scrCrt = new MuGenericScrollController("myscrcrt",
126: this );
127:
128: if (xString != null && xString.equals("") == false)
129: this .pcmf_addValue(xValue, xString);
130:
131: this .pem_body = this .pcmf_getMarkupString("BODY");
132:
133: return;
134: };
135:
136: // @@
137:
138: public Object pcmf_getOtion(int xIdx) {
139: KeStringTemplate l_string = new KeStringTemplate(this .pem_body);
140: Object objV[] = this .pcmf_getValues().values().toArray();
141: Object objK[] = this .pcmf_getValues().keySet().toArray();
142: String l_value = null;
143: String l_label = null;
144:
145: l_value = (String) objK[xIdx];
146: l_label = (String) objV[xIdx];
147:
148: l_string.pcmf_beginTR();
149:
150: if (this .pcmf_getValue().equals(l_value))
151: l_string = KeTools.pcmf_stringSubst(l_string, "$CHECKED",
152: "checked");
153: else
154: l_string = KeTools.pcmf_stringSubst(l_string, "$CHECKED",
155: "");
156:
157: l_string = KeTools.pcmf_stringSubst(l_string, "$NAME", this
158: .pcmf_getObjName());
159: l_string = KeTools
160: .pcmf_stringSubst(l_string, "$VALUE", l_value);
161: l_string = KeTools.pcmf_stringSubst(l_string, "$STRING",
162: l_label);
163: l_string = KeTools.pcmf_stringSubst(l_string, "$OID", this
164: .pcmf_getObjName());
165:
166: if (this .pcmf_isDisabled())
167: l_string = KeTools.pcmf_stringSubst(l_string, "$DISABLED",
168: "disabled");
169: else
170: l_string = KeTools.pcmf_stringSubst(l_string, "$DISABLED",
171: "");
172:
173: if (this .pcmf_isReadOnly())
174: l_string = KeTools.pcmf_stringSubst(l_string, "$READONLY",
175: "readonly");
176: else
177: l_string = KeTools.pcmf_stringSubst(l_string, "$READONLY",
178: "");
179:
180: if (this .pcmf_isSubmit()) {
181: KeStringTemplate l_stpl = this
182: .pcmf_getMarkupString("SUBMIT");
183: if (l_stpl != null)
184: l_string = KeTools.pcmf_stringSubst(l_string,
185: "$SUBMIT", l_stpl);
186: else
187: l_string = KeTools.pcmf_stringSubst(l_string,
188: "$SUBMIT", this .pdm_kit.getSUBMIT());
189: } else
190: l_string = KeTools
191: .pcmf_stringSubst(l_string, "$SUBMIT", "");
192:
193: l_string.pcmf_endTR(true);
194:
195: l_string = this .pcmf_insertPosition(l_string);
196: l_string = this .pcmf_insertToolTip(l_string);
197: l_string = this .pcmf_insertColorandFontandBorder(l_string);
198:
199: return (l_string);
200: };
201:
202: public KeTreeNode pcmf_addValue(String xValue, String xString) {
203: MuGenericRaw l_raw = null;
204: try {
205: l_raw = new MuGenericRaw(xValue, "",
206: (MuGenericApplication) this .pcmf_getAppl());
207: } catch (Exception e) {
208: KeLog.pcmf_logException("ug2t", this , e);
209: }
210: l_raw.pcmf_setView(new MuRadioPanelHelperView(this .pem_values
211: .size()));
212: super .pcmf_addNode(xValue, l_raw);
213:
214: pem_values.put(xValue, xString);
215:
216: return (l_raw);
217: };
218:
219: public void pcmf_removeValue(String xValue) {
220: KeTreeNode l_node = this .pcmf_removeNode(xValue);
221: if (l_node != null)
222: l_node.pcmf_releaseSubs();
223:
224: pem_values.remove(xValue);
225: Iterator l_it = this .pcmf_getSubIterator();
226: while (l_it.hasNext()) {
227: KeTreeElement l_el = (KeTreeElement) l_it.next();
228: if (l_el.pcmf_getView() instanceof MuRadioPanelHelperView)
229: ((MuRadioPanelHelperView) l_el.pcmf_getView()).pem_idx = this
230: .pcmf_indexOf(l_el);
231: }
232: };
233:
234: public void pcmf_removeAllValues() {
235: this .pcmf_clearAndRelease();
236: pem_values.clear();
237: };
238:
239: public HashMap pcmf_getValues() {
240: return (pem_values);
241: };
242:
243: public MuGenericScrollController pcmf_getScrollCrt() {
244: return (this .pdm_scrCrt);
245: }
246:
247: public KeTreeElement pcmf_addElement(String xName,
248: KeTreeElement xNode) {
249: return (null);
250: }
251:
252: public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
253: return (null);
254: }
255:
256: public void pcmf_delete() throws Exception {
257: if (this .pdm_deleted == true)
258: return;
259:
260: this .pdm_scrCrt.pcmf_delete();
261: this .pcmf_clearAndRelease();
262:
263: super .pcmf_delete();
264: }
265:
266: public void pcmf_setBgImage(IUnImage xImg) {
267: if (this .pdm_bgImg == xImg)
268: return;
269:
270: this .pdm_bgImg = xImg;
271: this .pcmf_setPropChanged(true);
272: }
273:
274: public IUnImage pcmf_getBgImage() {
275: return (this .pdm_bgImg);
276: };
277:
278: public void pcmf_setScroll(boolean xScroll) {
279: if (this .pem_scroll == xScroll)
280: return;
281:
282: pem_scroll = xScroll;
283: this .pcmf_setPropChanged(xScroll);
284: return;
285: }
286:
287: public boolean pcmf_getScroll() {
288: return (this .pem_scroll);
289: }
290:
291: private boolean pem_readOnly = false;
292:
293: public void pcmf_setReadOnly(boolean xReadOnly) {
294: if (this .pem_readOnly == xReadOnly)
295: return;
296:
297: this .pem_readOnly = xReadOnly;
298: this .pcmf_setPropChanged(true);
299: }
300:
301: public boolean pcmf_isReadOnly() {
302: return (this .pem_readOnly);
303: }
304:
305: // @@
306: };
|