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 de.ug2t.kernel.*;
034: import de.ug2t.unifiedGui.*;
035: import de.ug2t.unifiedGui.interfaces.*;
036: import de.ug2t.xmlScript.*;
037:
038: public final class HoSrvGenericContextMenu extends
039: AHoSrvGenericComponent implements IUnContextMenu {
040: protected UnMenuFunction pdm_active;
041: private KeTreeNode pem_root = null;
042: private boolean pem_autoShow = false;
043:
044: final class HoContextMenuListener implements IUnGuiEventListener {
045: public void pcmf_execListener(UnComponent xParam) {
046: HoSrvGenericContextMenu l_menu = (HoSrvGenericContextMenu) xParam;
047: String l_mString = l_menu.toString();
048: if (l_mString.startsWith(IUnContextMenu.CTX_MENU_OPENED)) {
049: l_menu.pcmf_show(KeTools.pcmf_getX(l_mString), KeTools
050: .pcmf_getY(l_mString));
051: l_menu.pcmf_consumeEvent();
052: } else {
053: Object l_clicked = KeRegisteredObject
054: .pcmf_getObjByName(l_mString);
055:
056: KeLog.pcmf_log("ug2t",
057: "calling menuItem: " + l_clicked, this ,
058: KeLog.MESSAGE);
059:
060: if (l_clicked instanceof UnMenuFunction) {
061: ((UnMenuFunction) l_clicked).pcmf_execObj(xParam);
062: l_menu.pdm_active = (UnMenuFunction) l_clicked;
063: }
064: ;
065:
066: xParam.pcmf_setValue(l_clicked);
067: xParam.pcmf_getAppl().pcmf_setActive(null);
068: }
069: return;
070: };
071: };
072:
073: public HoSrvGenericContextMenu(String xName, KeTreeNode xRoot,
074: IUnApplication xAppl, String xClass) throws Exception {
075: super (xName);
076: this .pcmf_setAppl(xAppl);
077: this .pcmf_setLocalValue("0");
078: this .pcmf_setEventOnChange(true);
079:
080: if (xClass == null)
081: pdm_clientClass = "de.ug2t.channel.ho.client.swing.HoSwingContextMenu";
082: else
083: pdm_clientClass = xClass;
084:
085: if (xRoot == null)
086: this .pem_root = this ;
087: else
088: this .pem_root = xRoot;
089:
090: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
091: "");
092: // Deklaration
093: if (this .pdm_session.pcmf_isInTransaction()) {
094: ScXmlScript.pcmf_createPBody(l_remCall);
095: } else {
096: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
097: ScXmlScript.pcmf_addProc(l_remCall, null);
098: }
099: ;
100: ScXmlScript.pcmf_addDecl(l_remCall, this .pcmf_getRemName(),
101: this .pdm_clientClass, "global");
102: ScXmlScript.pcmf_addDeclPar(l_remCall, xName, "false",
103: "java.lang.String");
104:
105: if (xRoot == null)
106: ScXmlScript.pcmf_addDeclPar(l_remCall, "null", "true",
107: "de.ug2t.kernel.KeTreeNode");
108: else
109: ScXmlScript.pcmf_addDeclPar(l_remCall, xRoot
110: .pcmf_getRemName(), "true",
111: "de.ug2t.kernel.KeTreeNode");
112:
113: ScXmlScript.pcmf_addDeclPar(l_remCall,
114: ((HoSrvGenericApplication) xAppl).pcmf_getRemName(),
115: "true", "de.ug2t.unifiedGui.interfaces.IUnApplication");
116: ScXmlScript.pcmf_endAll(l_remCall);
117:
118: this .pdm_session.pcmf_call(l_remCall.toString(), this );
119: this .pcmf_enableSubmit();
120:
121: this .pcmf_addListener(new HoContextMenuListener());
122:
123: return;
124: };
125:
126: public AHoSrvGenericComponent pcmf_buildRefObj() throws Exception {
127: AHoSrvGenericComponent l_obj = new HoSrvGenericContextMenu(this
128: .pcmf_getName(), this .pem_root, this .pcmf_getAppl(),
129: this .pdm_clientClass);
130: if (this .pcmf_isSubmit() == false)
131: l_obj.pcmf_disableSubmit();
132:
133: l_obj.pcmf_setGlobal(true);
134: this .pcmf_setGlobal(true);
135: l_obj.pcmf_setAutoEcho(this .pcmf_doAutoEcho());
136: l_obj.pcmf_setRefFrom(this );
137: this .pcmf_addRef(l_obj);
138:
139: return (l_obj);
140: };
141:
142: public void pcmf_commitMenu() {
143: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
144: "");
145:
146: if (this .pdm_session.pcmf_isInTransaction()) {
147: ScXmlScript.pcmf_createPBody(l_remCall);
148: } else {
149: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
150: ScXmlScript.pcmf_addProc(l_remCall, null);
151: }
152: ;
153: ScXmlScript.pcmf_addCall(l_remCall, null, this
154: .pcmf_getRemName(), "pcmf_commitMenu");
155: ScXmlScript.pcmf_endAll(l_remCall);
156:
157: this .pdm_session.pcmf_call(l_remCall.toString(), this );
158:
159: return;
160: };
161:
162: public KeTreeNode pcmf_setRoot(KeTreeNode xRoot) {
163: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
164: "");
165:
166: if (this .pdm_session.pcmf_isInTransaction()) {
167: ScXmlScript.pcmf_createPBody(l_remCall);
168: } else {
169: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
170: ScXmlScript.pcmf_addProc(l_remCall, null);
171: }
172: ;
173: ScXmlScript.pcmf_addCall(l_remCall, null, this
174: .pcmf_getRemName(), "pcmf_setRoot");
175: ScXmlScript.pcmf_addCallPar(l_remCall, xRoot.pcmf_getRemName(),
176: "true", "de.ug2t.kernel.KeTreeNode");
177: ScXmlScript.pcmf_endAll(l_remCall);
178:
179: this .pdm_session.pcmf_call(l_remCall.toString(), this );
180:
181: KeTreeNode l_node = this .pem_root;
182: this .pem_root = xRoot;
183:
184: return (l_node);
185: };
186:
187: public void pcmf_setMenuWidth(int xWi) {
188: // Does nothing
189: KeLog.pcmf_log("ug2t", "pcmf_setMenuWidth is not implemented",
190: this , KeLog.DEBUG);
191: }
192:
193: public void pcmf_show(int x, int y) {
194: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
195: "");
196:
197: if (this .pdm_session.pcmf_isInTransaction()) {
198: ScXmlScript.pcmf_createPBody(l_remCall);
199: } else {
200: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
201: ScXmlScript.pcmf_addProc(l_remCall, null);
202: }
203: ;
204: ScXmlScript.pcmf_addCall(l_remCall, null, this
205: .pcmf_getRemName(), "pcmf_show");
206: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(x),
207: "false", "int");
208: ScXmlScript.pcmf_addCallPar(l_remCall, Integer.toString(y),
209: "false", "int");
210:
211: ScXmlScript.pcmf_endAll(l_remCall);
212:
213: this .pdm_session.pcmf_call(l_remCall.toString(), this );
214:
215: return;
216: };
217:
218: public void pcmf_setAutoShow(boolean xAS) {
219: KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
220: "");
221:
222: if (this .pdm_session.pcmf_isInTransaction()) {
223: ScXmlScript.pcmf_createPBody(l_remCall);
224: } else {
225: ScXmlScript.pcmf_createxScriptString(l_remCall, null);
226: ScXmlScript.pcmf_addProc(l_remCall, null);
227: }
228: ;
229: ScXmlScript.pcmf_addCall(l_remCall, null, this
230: .pcmf_getRemName(), "pcmf_setAutoShow");
231: ScXmlScript.pcmf_addCallPar(l_remCall, Boolean.toString(xAS),
232: "false", "boolean");
233:
234: ScXmlScript.pcmf_endAll(l_remCall);
235:
236: this .pdm_session.pcmf_call(l_remCall.toString(), this );
237:
238: this .pem_autoShow = xAS;
239: }
240:
241: public boolean pcmf_getAutoShow() {
242: return this.pem_autoShow;
243: }
244: }
|