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.channel.ho.*;
036: import de.ug2t.kernel.*;
037: import de.ug2t.unifiedGui.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039: import de.ug2t.xmlScript.*;
040:
041: public final class HoSrvGenericTreeView extends AHoSrvGenericComponent
042: implements IUnTreeView {
043: private KeTreeNode pem_root = null;
044: private boolean pem_multiSelection = false;
045: private HoGenericDataContainer pem_container = null;
046: private KeTreeNode pem_toggled = null;
047: private int pem_xScroll = 0;
048: private int pem_yScroll = 0;
049: private IKeExecutable pem_cHandler = null;
050:
051: public HoSrvGenericTreeView(String xName, KeTreeNode xRoot,
052: IUnApplication xAppl, String xClass) throws Exception {
053: super (xName);
054: this .pcmf_setAppl(xAppl);
055: this .pcmf_setEventOnChange(true);
056:
057: if (xRoot != null)
058: this .pem_root = xRoot;
059: else
060: this .pem_root = this ;
061:
062: if (xClass == null)
063: pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingTreeView";
064: else
065: pdm_clientClass = xClass;
066:
067: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
068: "");
069: // Deklaration
070: if (this .pdm_session.pcmf_isInTransaction()) {
071: ScXmlScript.pcmf_createPBody(l_remCall);
072: } else {
073: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
074: ScXmlScript.pcmf_addProc(l_remCall, null);
075: }
076: ;
077: ScXmlScript.pcmf_addDecl(l_remCall, this .pcmf_getRemName(),
078: this .pdm_clientClass, "global");
079: ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false",
080: "java.lang.String");
081:
082: if (xRoot != null)
083: ScXmlScript.pcmf_addDeclPar(l_remCall, xRoot
084: .pcmf_getRemName(), "true",
085: "de.ug2t.kernel.KeTreeNode");
086: else
087: ScXmlScript.pcmf_addDeclPar(l_remCall, "null", "true",
088: "de.ug2t.kernel.KeTreeNode");
089:
090: ScXmlScript.pcmf_addDeclPar(l_remCall,
091: ((HoSrvGenericApplication) xAppl).pcmf_getRemName(),
092: "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
093: ScXmlScript.pcmf_endAll(l_remCall);
094:
095: this .pdm_session.pcmf_call(l_remCall.toString(), this );
096: this .pcmf_enableSubmit();
097:
098: return;
099: };
100:
101: public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception {
102: AHoSrvGenericComponent l_obj = new HoSrvGenericTreeView(this
103: .pcmf_getName(), this .pem_root, this .pcmf_getAppl(),
104: this .pdm_clientClass);
105: if (this .pcmf_isSubmit() == false)
106: l_obj.pcmf_disableSubmit();
107:
108: l_obj.pcmf_setGlobal(true);
109: this .pcmf_setGlobal(true);
110: l_obj.pcmf_setAutoEcho(this .pcmf_doAutoEcho());
111: l_obj.pcmf_setRefFrom(this );
112: this .pcmf_addRef(l_obj);
113:
114: return (l_obj);
115: };
116:
117: public void pcmf_echoValue(Object xValue) {
118: Object l_obj = xValue;
119: if (xValue instanceof KeTreeElement == false
120: && xValue instanceof HoGenericDataContainer == false) {
121: String l_oc = xValue.toString().substring(0, 1);
122: xValue = KeRegisteredObject.pcmf_getObjByLongName(xValue
123: .toString().substring(1));
124:
125: if (l_oc.equals("O") && xValue instanceof KeTreeNode)
126: return;
127: else if (l_oc.equals("C") && xValue instanceof KeTreeNode)
128: return;
129:
130: if (xValue == null)
131: xValue = l_obj;
132:
133: if (xValue instanceof HoGenericDataContainer)
134: ((HoGenericDataContainer) xValue).pcmf_echoValues();
135: } else if (xValue instanceof HoGenericDataContainer)
136: ((HoGenericDataContainer) xValue).pcmf_echoValues();
137:
138: super .pcmf_echoValue(xValue);
139: }
140:
141: public void pcmf_setValues(HoGenericDataContainer xValues) {
142: this .pcmf_setValue(xValues);
143: }
144:
145: public void pcmf_setValue(Object xObj) {
146: if (xObj != null
147: && (xObj instanceof KeTreeElement == false && xObj instanceof HoGenericDataContainer == false))
148: xObj = KeRegisteredObject.pcmf_getObjByLongName(xObj
149: .toString());
150:
151: super .pcmf_setValue(xObj);
152:
153: return;
154: };
155:
156: public void pcmf_setLocalValue(Object xValue) {
157: Object l_obj = xValue;
158: if (xValue instanceof KeTreeElement == false
159: && xValue instanceof HoGenericDataContainer == false) {
160: String l_oc = xValue.toString().substring(0, 1);
161: xValue = KeRegisteredObject.pcmf_getObjByLongName(xValue
162: .toString().substring(1));
163:
164: if (l_oc.equals("O") && xValue instanceof KeTreeNode) {
165: ((KeTreeNode) xValue).pcmf_unhide();
166: this .pem_toggled = ((KeTreeNode) xValue);
167: return;
168: } else if (l_oc.equals("C") && xValue instanceof KeTreeNode) {
169: ((KeTreeNode) xValue).pcmf_hide();
170: this .pem_toggled = ((KeTreeNode) xValue);
171: return;
172: }
173: this .pem_toggled = null;
174:
175: if (xValue == null)
176: xValue = l_obj;
177: }
178:
179: super .pcmf_setLocalValue(xValue);
180:
181: return;
182: };
183:
184: public KeTreeNode pcmf_setRoot(KeTreeNode xRoot) {
185: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
186: "");
187:
188: if (this .pdm_session.pcmf_isInTransaction()) {
189: ScXmlScript.pcmf_createPBody(l_remCall);
190: } else {
191: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
192: ScXmlScript.pcmf_addProc(l_remCall, null);
193: }
194: ;
195: ScXmlScript.pcmf_addCall(l_remCall, null, this
196: .pcmf_getRemName(), "pcmf_setRoot");
197: ScXmlScript.pcmf_addCallPar(l_remCall, xRoot.pcmf_getRemName(),
198: "true", "de.ug2t.kernel.KeTreeNode");
199: ScXmlScript.pcmf_endAll(l_remCall);
200:
201: this .pdm_session.pcmf_call(l_remCall.toString(), this );
202:
203: KeTreeNode l_node = this .pem_root;
204: this .pem_root = xRoot;
205:
206: return (l_node);
207: };
208:
209: public void pcmf_setEditable(boolean xEditable) {
210: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
211: "");
212:
213: if (this .pdm_session.pcmf_isInTransaction()) {
214: ScXmlScript.pcmf_createPBody(l_remCall);
215: } else {
216: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
217: ScXmlScript.pcmf_addProc(l_remCall, null);
218: }
219: ;
220: ScXmlScript.pcmf_addCall(l_remCall, null, this
221: .pcmf_getRemName(), "pcmf_setEditable");
222: ScXmlScript.pcmf_addCallPar(l_remCall, xEditable ? "true"
223: : "false", "false", "boolean");
224: ScXmlScript.pcmf_endAll(l_remCall);
225:
226: this .pdm_session.pcmf_call(l_remCall.toString(), this );
227:
228: return;
229: }
230:
231: public boolean pcmf_setMultiSelection(boolean xMulti) {
232: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
233: "");
234:
235: if (xMulti == true && this .pem_container == null)
236: this .pem_container = new HoGenericDataContainer();
237:
238: if (this .pdm_session.pcmf_isInTransaction()) {
239: ScXmlScript.pcmf_createPBody(l_remCall);
240: } else {
241: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
242: ScXmlScript.pcmf_addProc(l_remCall, null);
243: }
244: ;
245: ScXmlScript.pcmf_addCall(l_remCall, null, this
246: .pcmf_getRemName(), "pcmf_setMultiSelection");
247:
248: if (xMulti == true)
249: ScXmlScript.pcmf_addCallPar(l_remCall, this .pem_container
250: .pcmf_getRemName(), "true",
251: "de.ug2t.channel.ho.HoGenericDataContainer");
252: else
253: ScXmlScript.pcmf_endAll(l_remCall);
254:
255: this .pdm_session.pcmf_call(l_remCall.toString(), this );
256:
257: boolean l_old = this .pem_multiSelection;
258: this .pem_multiSelection = xMulti;
259:
260: return (l_old);
261: };
262:
263: public boolean pcmf_isMultiSelection() {
264: return (this .pem_multiSelection);
265: }
266:
267: public KeTreeNode pcmf_getRoot() {
268: return (this .pem_root);
269: };
270:
271: public Object pcmf_getValue() {
272: Object l_obj = super .pcmf_getValue();
273: if (l_obj instanceof HoGenericDataContainer) {
274: ArrayList l_vect = ((HoGenericDataContainer) l_obj)
275: .pcmf_getValueArray();
276: if (l_vect.size() > 0)
277: return (l_vect.get(l_vect.size() - 1));
278: }
279: return (l_obj);
280: }
281:
282: public HoGenericDataContainer pcmf_getValues() {
283: Object l_obj = super .pcmf_getValue();
284: if (l_obj instanceof HoGenericDataContainer)
285: return (((HoGenericDataContainer) l_obj));
286: else
287: return (null);
288: }
289:
290: public void finalize() {
291: try {
292: if (this .pem_container != null)
293: this .pem_container.pcmf_delete();
294: } catch (Exception e) {
295: KeLog.pcmf_logException("ug2t", this , e);
296: }
297: }
298:
299: public void pcmf_disable() {
300: Iterator l_it = this .pem_root.pcmf_getSubIterator();
301: while (l_it.hasNext())
302: ((KeTreeElement) l_it.next()).pcmf_disable();
303:
304: super .pcmf_disable();
305: };
306:
307: public void pcmf_enable() {
308: Iterator l_it = this .pem_root.pcmf_getSubIterator();
309: while (l_it.hasNext())
310: ((KeTreeElement) l_it.next()).pcmf_enable();
311:
312: super .pcmf_enable();
313: };
314:
315: public void pcmf_scrollXRel(int xPx) {
316: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
317: "");
318:
319: if (this .pdm_session.pcmf_isInTransaction()) {
320: ScXmlScript.pcmf_createPBody(l_remCall);
321: } else {
322: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
323: ScXmlScript.pcmf_addProc(l_remCall, null);
324: }
325: ;
326: ScXmlScript.pcmf_addCall(l_remCall, null, this
327: .pcmf_getRemName(), "pcmf_scrollXRel");
328: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPx),
329: "false", "int");
330: ScXmlScript.pcmf_endAll(l_remCall);
331:
332: this .pdm_session.pcmf_call(l_remCall.toString(), this );
333:
334: return;
335: }
336:
337: public void pcmf_scrollXAbs(int xPx) {
338: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
339: "");
340:
341: if (this .pdm_session.pcmf_isInTransaction()) {
342: ScXmlScript.pcmf_createPBody(l_remCall);
343: } else {
344: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
345: ScXmlScript.pcmf_addProc(l_remCall, null);
346: }
347: ;
348: ScXmlScript.pcmf_addCall(l_remCall, null, this
349: .pcmf_getRemName(), "pcmf_scrollXAbs");
350: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPx),
351: "false", "int");
352: ScXmlScript.pcmf_endAll(l_remCall);
353:
354: this .pdm_session.pcmf_call(l_remCall.toString(), this );
355:
356: return;
357: }
358:
359: public void pcmf_scrollYRel(int xPy) {
360: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
361: "");
362:
363: if (this .pdm_session.pcmf_isInTransaction()) {
364: ScXmlScript.pcmf_createPBody(l_remCall);
365: } else {
366: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
367: ScXmlScript.pcmf_addProc(l_remCall, null);
368: }
369: ;
370: ScXmlScript.pcmf_addCall(l_remCall, null, this
371: .pcmf_getRemName(), "pcmf_scrollYRel");
372: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPy),
373: "false", "int");
374: ScXmlScript.pcmf_endAll(l_remCall);
375:
376: this .pdm_session.pcmf_call(l_remCall.toString(), this );
377:
378: return;
379: }
380:
381: public void pcmf_scrollYAbs(int xPy) {
382: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
383: "");
384:
385: if (this .pdm_session.pcmf_isInTransaction()) {
386: ScXmlScript.pcmf_createPBody(l_remCall);
387: } else {
388: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
389: ScXmlScript.pcmf_addProc(l_remCall, null);
390: }
391: ;
392: ScXmlScript.pcmf_addCall(l_remCall, null, this
393: .pcmf_getRemName(), "pcmf_scrollYAbs");
394: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(xPy),
395: "false", "int");
396: ScXmlScript.pcmf_endAll(l_remCall);
397:
398: this .pdm_session.pcmf_call(l_remCall.toString(), this );
399:
400: return;
401: }
402:
403: public void pcmf_setCommitHandler(IKeExecutable xHandler) {
404: this .pem_cHandler = xHandler;
405: }
406:
407: public void pcmf_clearCommitHandler() {
408: this .pem_cHandler = null;
409: }
410:
411: public void pcmf_commitTree() {
412: if (this .pem_cHandler != null)
413: this .pem_cHandler.pcmf_execObj(this );
414:
415: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
416: "");
417:
418: if (this .pdm_session.pcmf_isInTransaction()) {
419: ScXmlScript.pcmf_createPBody(l_remCall);
420: } else {
421: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
422: ScXmlScript.pcmf_addProc(l_remCall, null);
423: }
424: ;
425: ScXmlScript.pcmf_addCall(l_remCall, null, this
426: .pcmf_getRemName(), "pcmf_commitTree");
427: ScXmlScript.pcmf_endAll(l_remCall);
428:
429: this .pdm_session.pcmf_call(l_remCall.toString(), this );
430:
431: return;
432: }
433:
434: public int pcmf_getXScroll() {
435: return (this .pem_xScroll);
436: }
437:
438: public int pcmf_getYScroll() {
439: return (this .pem_yScroll);
440: }
441:
442: public KeTreeNode pcmf_getToggled() {
443: return (this .pem_toggled);
444: }
445:
446: public void pcmf_setScrollInfo(int xX, int xY) {
447: if (xX != this .pem_xScroll || xY != this .pem_yScroll) {
448: this .pem_xScroll = xX;
449: this .pem_yScroll = xY;
450:
451: Iterator l_it = this .pcmf_getSubIterator();
452: while (l_it.hasNext()) {
453: Object l_obj = l_it.next();
454: if (l_obj instanceof IUnEventChannel) {
455: if (((IUnEventChannel) l_obj).pcmf_getType() == IUnEventChannel.EVENT_SCROLL) {
456: IUnEventChannel l_ch = (IUnEventChannel) l_obj;
457:
458: l_ch
459: .pcmf_getUnComponent()
460: .pcmf_setValue(
461: IUnEventChannel.EVENTs[IUnEventChannel.EVENT_SCROLL]
462: + ":" + xX + "," + xY);
463: l_ch.pcmf_getUnComponent().pcmf_setRefresh();
464:
465: if (l_ch.pcmf_isRefreshParent())
466: ((UnComponent) l_ch.pcmf_getUnComponent()
467: .pcmf_getParentNode())
468: .pcmf_setRefresh();
469:
470: try {
471: if (l_ch.pcmf_getUnComponent()
472: .pcmf_isSubmit())
473: l_ch.pcmf_getUnComponent()
474: .pcmf_dispatchEvent();
475: } catch (Exception e) {
476: KeLog.pcmf_logException("ug2t", this , e);
477: KeLog.pcmf_log("ug2t",
478: "error dispatch scroll event",
479: this, KeLog.ERROR);
480: }
481: }
482: break;
483: }
484: }
485: }
486: }
487: }
|