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 de.ug2t.channel.markup.html.renderer.*;
034: import de.ug2t.connector.*;
035: import de.ug2t.kernel.*;
036: import de.ug2t.unifiedGui.*;
037: import de.ug2t.unifiedGui.interfaces.*;
038:
039: class MuGenericContextMenuListener implements IUnGuiEventListener {
040: public void pcmf_execListener(UnComponent xParam) {
041: MuGenericContextMenu l_menu = (MuGenericContextMenu) xParam;
042: Object l_clicked = l_menu.pcmf_getValue();
043:
044: if (l_clicked instanceof UnMenuFunction) {
045: Object l_ret = ((UnMenuFunction) l_clicked)
046: .pcmf_execObj(xParam);
047: if (l_ret == null)
048: KeLog.pcmf_log("ug2t",
049: "calling disabled menuItem (no function executed): "
050: + l_clicked, this , KeLog.MESSAGE);
051: else
052: KeLog.pcmf_log("ug2t",
053: "calling menuItem: " + l_clicked, this ,
054: KeLog.MESSAGE);
055: }
056: ;
057:
058: return;
059: };
060: };
061:
062: public final class MuGenericContextMenu extends MuGenericComponent
063: implements IUnContextMenu, IKePoolable {
064: protected KeTreeNode pdm_root = null;
065: private IKeView pem_view = new HtmlContextMenuRenderer();
066: private static MuGenericContextMenuListener pem_stdListener = new MuGenericContextMenuListener();
067: private boolean pem_showInPage = false;
068:
069: /**
070: * <p>
071: * Does...
072: * </p>
073: * <p>
074: *
075: * @return a Type with
076: * </p>
077: * <p>
078: * @param
079: * </p>
080: */
081: public MuGenericContextMenu(String xName, KeTreeNode xRoot,
082: ACoDataGetter xTplGetter, Object xTplName,
083: MuGenericApplication xAppl) throws Exception {
084: super (xName, xTplGetter, xTplName, xAppl);
085:
086: if (xRoot == null)
087: pdm_root = this ;
088: else
089: this .pdm_root = xRoot;
090:
091: this .pcmf_setView(pem_view);
092: this .pcmf_setValue(xName);
093: this .pcmf_addListener(pem_stdListener);
094: this .pcmf_setEventOnChange(true);
095: this .pcmf_setBgColor("#D8D8D8");
096:
097: pdm_root.pcmf_hideLevel(1);
098:
099: return;
100: };
101:
102: // @@
103:
104: public Object pcmf_execView() {
105: try {
106: if (this .pem_showInPage == false) {
107: ((MuGenericApplication) this .pcmf_getAppl())
108: .pcmf_getRenderer().pcmf_addCtxMenu(this );
109: return ("");
110: } else {
111: if (this .pcmf_isHidden() || this .pcmf_isDisabled())
112: return (((MuGenericApplication) this .pcmf_getAppl())
113: .pcmf_getRenderer().pcmf_wrapMarkup("",
114: this ));
115:
116: return (((MuGenericApplication) this .pcmf_getAppl())
117: .pcmf_getRenderer().pcmf_wrapMarkup(
118: pdm_NodeView.pcmf_output(this ).toString()
119: + pcmf_evChannelandMenuOut(), this ));
120: }
121: } catch (Exception e) {
122: KeLog.pcmf_logException("ug2t", this , e);
123: return ("ERROR");
124: }
125: };
126:
127: public void pcmf_setValue(Object xObj) {
128: if (xObj instanceof KeTreeElement == false && xObj != null)
129: xObj = KeRegisteredObject
130: .pcmf_getObjByName(xObj.toString());
131:
132: pdm_Element = xObj;
133:
134: return;
135: };
136:
137: public KeTreeNode pcmf_getRoot() {
138: return (this .pdm_root);
139: }
140:
141: public void pcmf_commitMenu() {
142: pdm_root.pcmf_hideLevel(1);
143: this .pcmf_setPropChanged(true);
144: return;
145: }
146:
147: public KeTreeNode pcmf_setRoot(KeTreeNode xRoot) {
148: if (xRoot == this .pdm_root)
149: return (xRoot);
150:
151: KeTreeNode l_node = this .pdm_root;
152: this .pdm_root = xRoot;
153: this .pcmf_setPropChanged(true);
154:
155: return (l_node);
156: };
157:
158: public void pcmf_setShowInPage(boolean xShow) {
159: this .pem_showInPage = xShow;
160: }
161:
162: public KeTreeNode pcmf_getToggled() {
163: return (null);
164: };
165:
166: public void pcmf_commitTree() {
167: this .pcmf_setPropChanged(true);
168: return;
169: };
170:
171: public void pcmf_setMenuWidth(int xWi) {
172: // Does nothing
173: KeLog.pcmf_log("ug2t", "pcmf_setMenuWidth is not implemented",
174: this , KeLog.DEBUG);
175: }
176:
177: // @@
178:
179: public void pcmf_delete() throws Exception {
180: if (this .pdm_deleted == true)
181: return;
182:
183: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
184: .pcmf_removeCtxMenu(this );
185:
186: super .pcmf_delete();
187:
188: return;
189: };
190:
191: // @@
192:
193: }
|