001: /*
002: * Wi.Ser Framework
003: *
004: * Version: 1.8.1, 20-September-2007
005: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library located in LGPL.txt in the
019: * license directory; if not, write to the
020: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
021: * Boston, MA 02111-1307, USA.
022: *
023: * If this agreement does not cover your requirements, please contact us
024: * via email to get detailed information about the commercial license
025: * or our service offerings!
026: *
027: */
028: package de.ug2t.channel.ho.server.generic;
029:
030: import java.util.*;
031:
032: import de.ug2t.kernel.*;
033: import de.ug2t.unifiedGui.interfaces.*;
034: import de.ug2t.xmlScript.*;
035:
036: public class HoSrvGenericSpinner extends AHoSrvGenericComponent
037: implements IUnSpinner, IUnSyncComponent {
038: private HashMap pem_values = new LinkedHashMap();
039:
040: public HoSrvGenericSpinner(String xName, IUnApplication xAppl,
041: String xClass) throws Exception {
042: super (xName);
043: this .pcmf_setAppl(xAppl);
044:
045: if (xClass == null)
046: pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingSpinner";
047: else
048: pdm_clientClass = xClass;
049:
050: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
051: "");
052:
053: if (this .pdm_session.pcmf_isInTransaction()) {
054: ScXmlScript.pcmf_createPBody(l_remCall);
055: } else {
056: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
057: ScXmlScript.pcmf_addProc(l_remCall, null);
058: }
059: ;
060: ScXmlScript.pcmf_addDecl(l_remCall, this .pcmf_getRemName(),
061: this .pdm_clientClass, "global");
062: ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false",
063: "java.lang.String");
064: ScXmlScript.pcmf_addDeclPar(l_remCall,
065: ((HoSrvGenericApplication) xAppl).pcmf_getRemName(),
066: "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
067:
068: ScXmlScript.pcmf_endAll(l_remCall);
069:
070: this .pdm_session.pcmf_call(l_remCall.toString(), this );
071:
072: return;
073: };
074:
075: public void pcmf_beginTr() {
076: return;
077: }
078:
079: public void pcmf_commitTr() {
080: return;
081: }
082:
083: public void pcmf_addValueObj(String xValue, KeRegisteredObject xObj) {
084: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
085: "");
086:
087: if (this .pdm_session.pcmf_isInTransaction()) {
088: ScXmlScript.pcmf_createPBody(l_remCall);
089: } else {
090: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
091: ScXmlScript.pcmf_addProc(l_remCall, null);
092: }
093: ;
094: ScXmlScript.pcmf_addCall(l_remCall, null, this
095: .pcmf_getRemName(), "pcmf_addValueObj");
096: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
097: "java.lang.String");
098: ScXmlScript.pcmf_addCallPar(l_remCall, xObj.pcmf_getRemName(),
099: "true", "de.ug2t.kernel.KeRegisteredObject");
100: ScXmlScript.pcmf_endAll(l_remCall);
101:
102: this .pdm_session.pcmf_call(l_remCall.toString(), this );
103:
104: pem_values.put(xValue, xObj);
105:
106: if (xObj instanceof KeTreeNode)
107: this .pcmf_addNode(xValue, (KeTreeNode) xObj);
108: };
109:
110: public void pcmf_addValue(String xValue, String xString) {
111: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
112: "");
113:
114: if (this .pdm_session.pcmf_isInTransaction()) {
115: ScXmlScript.pcmf_createPBody(l_remCall);
116: } else {
117: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
118: ScXmlScript.pcmf_addProc(l_remCall, null);
119: }
120: ;
121: ScXmlScript.pcmf_addCall(l_remCall, null, this
122: .pcmf_getRemName(), "pcmf_addValue");
123: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
124: "java.lang.String");
125: ScXmlScript.pcmf_addCallPar(l_remCall, xString, "false",
126: "java.lang.String");
127: ScXmlScript.pcmf_endAll(l_remCall);
128:
129: this .pdm_session.pcmf_call(l_remCall.toString(), this );
130:
131: pem_values.put(xValue, xString);
132: };
133:
134: public void pcmf_removeValue(String xValue) {
135: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
136: "");
137:
138: if (this .pdm_session.pcmf_isInTransaction()) {
139: ScXmlScript.pcmf_createPBody(l_remCall);
140: } else {
141: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
142: ScXmlScript.pcmf_addProc(l_remCall, null);
143: }
144: ;
145: ScXmlScript.pcmf_addCall(l_remCall, null, this
146: .pcmf_getRemName(), "pcmf_removeValue");
147: ScXmlScript.pcmf_addCallPar(l_remCall, xValue, "false",
148: "java.lang.String");
149: ScXmlScript.pcmf_endAll(l_remCall);
150:
151: this .pdm_session.pcmf_call(l_remCall.toString(), this );
152:
153: pem_values.remove(xValue);
154: this .pcmf_removeNode(xValue);
155: };
156:
157: public void pcmf_clearSpinner() {
158: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
159: "");
160:
161: if (this .pdm_session.pcmf_isInTransaction()) {
162: ScXmlScript.pcmf_createPBody(l_remCall);
163: } else {
164: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
165: ScXmlScript.pcmf_addProc(l_remCall, null);
166: }
167: ;
168: ScXmlScript.pcmf_addCall(l_remCall, null, this
169: .pcmf_getRemName(), "pcmf_clearSpinner");
170: ScXmlScript.pcmf_endAll(l_remCall);
171:
172: this .pdm_session.pcmf_call(l_remCall.toString(), this );
173:
174: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
175: .iterator();
176: Object l_obj = null;
177: while (l_it.hasNext()) {
178: l_obj = l_it.next();
179: if (l_obj instanceof IUnContextMenu
180: || l_obj instanceof IUnEventChannel)
181: continue;
182:
183: this .pcmf_removeNode((KeTreeNode) l_obj);
184: }
185: };
186:
187: public void pcmf_clearAndReleaseSpinner() {
188: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
189: "");
190:
191: if (this .pdm_session.pcmf_isInTransaction()) {
192: ScXmlScript.pcmf_createPBody(l_remCall);
193: } else {
194: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
195: ScXmlScript.pcmf_addProc(l_remCall, null);
196: }
197: ;
198: ScXmlScript.pcmf_addCall(l_remCall, null, this
199: .pcmf_getRemName(), "pcmf_clearAndReleaseSpinner");
200: ScXmlScript.pcmf_endAll(l_remCall);
201:
202: this .pdm_session.pcmf_call(l_remCall.toString(), this );
203:
204: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
205: .iterator();
206: Object l_obj = null;
207:
208: this .pdm_session.pcmf_beginTr();
209: while (l_it.hasNext()) {
210: l_obj = l_it.next();
211: if (l_obj instanceof IUnContextMenu
212: || l_obj instanceof IUnEventChannel)
213: continue;
214:
215: this .pcmf_removeNode((KeTreeNode) l_obj);
216: ((KeTreeNode) l_obj).pcmf_releaseSubs();
217: }
218: this .pdm_session.pcmf_commitTr();
219: };
220:
221: public HashMap pcmf_getValues() {
222: return (pem_values);
223: };
224:
225: public Object pcmf_getSelectedObject() {
226: int l_idx = this .pcmf_getSelectedRow();
227: if (l_idx == -1)
228: return (null);
229:
230: Object l_ret = this .pem_values.keySet().toArray()[l_idx];
231: return (l_ret);
232: }
233:
234: public Object pcmf_setSelectedRow(int xRow) {
235: if (xRow >= this .pem_values.size())
236: return (null);
237:
238: Object l_ret = this .pem_values.keySet().toArray()[xRow];
239: this .pcmf_setLocalValue(l_ret);
240:
241: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
242: "");
243:
244: if (this .pdm_session.pcmf_isInTransaction()) {
245: ScXmlScript.pcmf_createPBody(l_remCall);
246: } else {
247: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
248: ScXmlScript.pcmf_addProc(l_remCall, null);
249: }
250: ;
251: ScXmlScript.pcmf_addCall(l_remCall, null, this
252: .pcmf_getRemName(), "pcmf_setSelectedRow");
253: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xRow),
254: "false", "int");
255: ScXmlScript.pcmf_endAll(l_remCall);
256:
257: this .pdm_session.pcmf_call(l_remCall.toString(), this );
258:
259: return (l_ret);
260: }
261:
262: public int pcmf_getSelectedRow() {
263: return (new ArrayList(this .pem_values.keySet()).indexOf(this
264: .pcmf_getValue()));
265: }
266:
267: public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception {
268: Object l_key = null;
269: AHoSrvGenericComponent l_obj = null;
270: Iterator l_it = this .pcmf_getValues().keySet().iterator();
271: while (l_it.hasNext()) {
272: l_key = l_it.next();
273: if (l_obj == null) {
274: l_obj = new HoSrvGenericSpinner(this .pcmf_getName(),
275: this .pcmf_getAppl(), this .pdm_clientClass);
276: continue;
277: }
278: ;
279:
280: ((HoSrvGenericSpinner) l_obj).pcmf_addValue(l_key
281: .toString(), this .pcmf_getValues().get(
282: l_key.toString()).toString());
283: }
284: ;
285:
286: l_obj.pcmf_setGlobal(true);
287: l_obj.pcmf_setRefFrom(this );
288: this .pcmf_setGlobal(true);
289: l_obj.pcmf_setAutoEcho(this .pcmf_doAutoEcho());
290: this .pcmf_addRef(l_obj);
291:
292: return l_obj;
293: };
294:
295: private int pem_syncCnt = 0;
296:
297: public Object pcmf_getValueToSync() {
298: return (this .pcmf_getValue());
299: }
300:
301: public void pcmf_setSynced() {
302: this .pem_syncCnt++;
303: }
304:
305: public void pcmf_unSync() {
306: this .pem_syncCnt--;
307: if (this .pem_syncCnt < 0)
308: this .pem_syncCnt = 0;
309: }
310:
311: public boolean pcmf_isSynced() {
312: if (this .pem_syncCnt == 0)
313: return (false);
314: else
315: return (true);
316: }
317:
318: public void pcmf_clearListWidget() {
319: this .pcmf_clearSpinner();
320: }
321:
322: public void pcmf_clearAndReleaseListWidget() {
323: this .pcmf_clearAndReleaseSpinner();
324: }
325:
326: public void pcmf_spinUp() {
327: Object l_selected = this .pcmf_getValue();
328: ArrayList l_keys = new ArrayList(this .pem_values.keySet());
329: int l_idx = l_keys.indexOf(l_selected);
330: l_idx++;
331: if (l_idx >= l_keys.size())
332: l_idx = 0;
333:
334: this .pcmf_setValue(l_keys.get(l_idx));
335: }
336:
337: public void pcmf_spinDown() {
338: Object l_selected = this .pcmf_getValue();
339: ArrayList l_keys = new ArrayList(this .pem_values.keySet());
340: int l_idx = l_keys.indexOf(l_selected);
341: l_idx--;
342: if (l_idx < 0)
343: l_idx = l_keys.size() - 1;
344:
345: this .pcmf_setValue(l_keys.get(l_idx));
346: }
347:
348: private int pem_talign = IUnInputField.TEXT_ALIGN_WEST;
349:
350: public void pcmf_setTextAlign(int xAlign) {
351: this .pem_talign = xAlign;
352: }
353:
354: public int pcmf_getTextAlign() {
355: return (this.pem_talign);
356: }
357: }
|