001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * LGPL Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005-2006 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.ho.server.generic;
032:
033: import java.util.*;
034:
035: import de.ug2t.kernel.*;
036: import de.ug2t.unifiedGui.interfaces.*;
037: import de.ug2t.xmlScript.*;
038:
039: public final class HoSrvGenericComboBox extends AHoSrvGenericComponent
040: implements IUnComboBox, IUnSyncComponent {
041: private HashMap pem_values = new LinkedHashMap();
042:
043: public HoSrvGenericComboBox(String xName, String xValue,
044: String xString, IUnApplication xAppl, String xClass)
045: throws Exception {
046: super (xName);
047: this .pcmf_setAppl(xAppl);
048: this .pcmf_setLocalValue(xValue);
049: pem_values.put(xValue, xString);
050:
051: if (xClass == null)
052: pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingComboBox";
053: else
054: pdm_clientClass = xClass;
055:
056: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
057: "");
058:
059: if (this .pdm_session.pcmf_isInTransaction()) {
060: ScXmlScript.pcmf_createPBody(l_remCall);
061: } else {
062: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
063: ScXmlScript.pcmf_addProc(l_remCall, null);
064: }
065: ;
066: ScXmlScript.pcmf_addDecl(l_remCall, this .pcmf_getRemName(),
067: this .pdm_clientClass, "global");
068: ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false",
069: "java.lang.String");
070: ScXmlScript.pcmf_addDeclPar(l_remCall, xValue, "false",
071: "java.lang.String");
072: ScXmlScript.pcmf_addDeclPar(l_remCall, xString, "false",
073: "java.lang.String");
074: ScXmlScript.pcmf_addDeclPar(l_remCall,
075: ((HoSrvGenericApplication) xAppl).pcmf_getRemName(),
076: "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
077:
078: ScXmlScript.pcmf_endAll(l_remCall);
079:
080: this .pdm_session.pcmf_call(l_remCall.toString(), this );
081:
082: return;
083: };
084:
085: public void pcmf_beginTr() {
086: return;
087: }
088:
089: public void pcmf_commitTr() {
090: return;
091: }
092:
093: public void pcmf_addValueObj(String xValue, KeRegisteredObject xObj) {
094: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
095: "");
096:
097: if (this .pdm_session.pcmf_isInTransaction()) {
098: ScXmlScript.pcmf_createPBody(l_remCall);
099: } else {
100: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
101: ScXmlScript.pcmf_addProc(l_remCall, null);
102: }
103: ;
104: ScXmlScript.pcmf_addCall(l_remCall, null, this
105: .pcmf_getRemName(), "pcmf_addValueObj");
106: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
107: "java.lang.String");
108: ScXmlScript.pcmf_addCallPar(l_remCall, xObj.pcmf_getRemName(),
109: "true", "de.ug2t.kernel.KeRegisteredObject");
110: ScXmlScript.pcmf_endAll(l_remCall);
111:
112: this .pdm_session.pcmf_call(l_remCall.toString(), this );
113:
114: pem_values.put(xValue, xObj);
115:
116: if (xObj instanceof KeTreeNode)
117: this .pcmf_addNode(xValue, (KeTreeNode) xObj);
118: };
119:
120: public void pcmf_addValue(String xValue, String xString) {
121: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
122: "");
123:
124: if (this .pdm_session.pcmf_isInTransaction()) {
125: ScXmlScript.pcmf_createPBody(l_remCall);
126: } else {
127: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
128: ScXmlScript.pcmf_addProc(l_remCall, null);
129: }
130: ;
131: ScXmlScript.pcmf_addCall(l_remCall, null, this
132: .pcmf_getRemName(), "pcmf_addValue");
133: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
134: "java.lang.String");
135: ScXmlScript.pcmf_addCallPar(l_remCall, xString, "false",
136: "java.lang.String");
137: ScXmlScript.pcmf_endAll(l_remCall);
138:
139: this .pdm_session.pcmf_call(l_remCall.toString(), this );
140:
141: pem_values.put(xValue, xString);
142: };
143:
144: public void pcmf_removeValue(String xValue) {
145: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
146: "");
147:
148: if (this .pdm_session.pcmf_isInTransaction()) {
149: ScXmlScript.pcmf_createPBody(l_remCall);
150: } else {
151: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
152: ScXmlScript.pcmf_addProc(l_remCall, null);
153: }
154: ;
155: ScXmlScript.pcmf_addCall(l_remCall, null, this
156: .pcmf_getRemName(), "pcmf_removeValue");
157: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
158: "java.lang.String");
159: ScXmlScript.pcmf_endAll(l_remCall);
160:
161: this .pdm_session.pcmf_call(l_remCall.toString(), this );
162:
163: pem_values.remove(xValue);
164: this .pcmf_removeNode(xValue);
165: };
166:
167: public void pcmf_clearComboBox() {
168: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
169: "");
170:
171: if (this .pdm_session.pcmf_isInTransaction()) {
172: ScXmlScript.pcmf_createPBody(l_remCall);
173: } else {
174: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
175: ScXmlScript.pcmf_addProc(l_remCall, null);
176: }
177: ;
178: ScXmlScript.pcmf_addCall(l_remCall, null, this
179: .pcmf_getRemName(), "pcmf_clearComboBox");
180: ScXmlScript.pcmf_endAll(l_remCall);
181:
182: this .pdm_session.pcmf_call(l_remCall.toString(), this );
183:
184: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
185: .iterator();
186: Object l_obj = null;
187: while (l_it.hasNext()) {
188: l_obj = l_it.next();
189: if (l_obj instanceof IUnContextMenu
190: || l_obj instanceof IUnEventChannel)
191: continue;
192:
193: this .pcmf_removeNode((KeTreeNode) l_obj);
194: }
195: };
196:
197: public void pcmf_clearAndReleaseComboBox() {
198: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
199: "");
200:
201: if (this .pdm_session.pcmf_isInTransaction()) {
202: ScXmlScript.pcmf_createPBody(l_remCall);
203: } else {
204: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
205: ScXmlScript.pcmf_addProc(l_remCall, null);
206: }
207: ;
208: ScXmlScript.pcmf_addCall(l_remCall, null, this
209: .pcmf_getRemName(), "pcmf_clearAndReleaseComboBox");
210: ScXmlScript.pcmf_endAll(l_remCall);
211:
212: this .pdm_session.pcmf_call(l_remCall.toString(), this );
213:
214: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
215: .iterator();
216: Object l_obj = null;
217:
218: this .pdm_session.pcmf_beginTr();
219: while (l_it.hasNext()) {
220: l_obj = l_it.next();
221: if (l_obj instanceof IUnContextMenu
222: || l_obj instanceof IUnEventChannel)
223: continue;
224:
225: this .pcmf_removeNode((KeTreeNode) l_obj);
226: ((KeTreeNode) l_obj).pcmf_releaseSubs();
227: }
228: this .pdm_session.pcmf_commitTr();
229: };
230:
231: public HashMap pcmf_getValues() {
232: return (pem_values);
233: };
234:
235: public Object pcmf_getSelectedObject() {
236: int l_idx = this .pcmf_getSelectedRow();
237: if (l_idx == -1)
238: return (null);
239:
240: Object l_ret = this .pem_values.keySet().toArray()[l_idx];
241: return (l_ret);
242: }
243:
244: public Object pcmf_setSelectedRow(int xRow) {
245: if (xRow >= this .pem_values.size())
246: return (null);
247:
248: Object l_ret = this .pem_values.keySet().toArray()[xRow];
249: this .pcmf_setLocalValue(l_ret);
250:
251: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
252: "");
253:
254: if (this .pdm_session.pcmf_isInTransaction()) {
255: ScXmlScript.pcmf_createPBody(l_remCall);
256: } else {
257: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
258: ScXmlScript.pcmf_addProc(l_remCall, null);
259: }
260: ;
261: ScXmlScript.pcmf_addCall(l_remCall, null, this
262: .pcmf_getRemName(), "pcmf_setSelectedRow");
263: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xRow),
264: "false", "int");
265: ScXmlScript.pcmf_endAll(l_remCall);
266:
267: this .pdm_session.pcmf_call(l_remCall.toString(), this );
268:
269: return (l_ret);
270: }
271:
272: public int pcmf_getSelectedRow() {
273: return (new ArrayList(this .pem_values.keySet()).indexOf(this
274: .pcmf_getValue()));
275: }
276:
277: public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception {
278: Object l_key = null;
279: AHoSrvGenericComponent l_obj = null;
280: Iterator l_it = this .pcmf_getValues().keySet().iterator();
281: while (l_it.hasNext()) {
282: l_key = l_it.next();
283: if (l_obj == null) {
284: l_obj = new HoSrvGenericComboBox(this .pcmf_getName(),
285: l_key.toString(), this .pcmf_getValues().get(
286: l_key.toString()).toString(), this
287: .pcmf_getAppl(), this .pdm_clientClass);
288: continue;
289: }
290: ;
291:
292: ((HoSrvGenericComboBox) l_obj).pcmf_addValue(l_key
293: .toString(), this .pcmf_getValues().get(
294: l_key.toString()).toString());
295: }
296: ;
297:
298: l_obj.pcmf_setGlobal(true);
299: l_obj.pcmf_setRefFrom(this );
300: this .pcmf_setGlobal(true);
301: l_obj.pcmf_setAutoEcho(this .pcmf_doAutoEcho());
302: this .pcmf_addRef(l_obj);
303:
304: return l_obj;
305: };
306:
307: private boolean pem_readOnly = true;
308:
309: public void pcmf_setReadOnly(boolean xReadOnly) {
310: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
311: "");
312:
313: if (this .pdm_session.pcmf_isInTransaction()) {
314: ScXmlScript.pcmf_createPBody(l_remCall);
315: } else {
316: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
317: ScXmlScript.pcmf_addProc(l_remCall, null);
318: }
319: ;
320: ScXmlScript.pcmf_addCall(l_remCall, null, this
321: .pcmf_getRemName(), "pcmf_setReadOnly");
322: ScXmlScript.pcmf_addCallPar(l_remCall, Boolean
323: .toString(xReadOnly), "false", "boolean");
324: ScXmlScript.pcmf_endAll(l_remCall);
325:
326: this .pdm_session.pcmf_call(l_remCall.toString(), this );
327: this .pem_readOnly = xReadOnly;
328: }
329:
330: public boolean pcmf_isReadOnly() {
331: return (this .pem_readOnly);
332: }
333:
334: private int pem_syncCnt = 0;
335:
336: public Object pcmf_getValueToSync() {
337: return (this .pcmf_getValue());
338: }
339:
340: public void pcmf_setSynced() {
341: this .pem_syncCnt++;
342: }
343:
344: public void pcmf_unSync() {
345: this .pem_syncCnt--;
346: if (this .pem_syncCnt < 0)
347: this .pem_syncCnt = 0;
348: }
349:
350: public boolean pcmf_isSynced() {
351: if (this .pem_syncCnt == 0)
352: return (false);
353: else
354: return (true);
355: }
356:
357: public void pcmf_clearListWidget() {
358: this .pcmf_clearComboBox();
359: }
360:
361: public void pcmf_clearAndReleaseListWidget() {
362: this .pcmf_clearAndReleaseComboBox();
363: }
364:
365: public boolean pcmf_isSelectable() {
366: return (true);
367: }
368: }
|