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.connector.*;
034: import de.ug2t.kernel.*;
035: import de.ug2t.unifiedGui.*;
036: import de.ug2t.unifiedGui.interfaces.*;
037:
038: public final class MuGenericOptionDialog extends MuGenericComponent
039: implements IUnOptionDialog, IKePoolable {
040: public static final int DLG_ALERT = 1;
041: public static final int DLG_OPTION = 2;
042: public static final int DLG_INPUT = 3;
043: public static final int DLG_OFF = 0;
044:
045: private int pem_state = MuGenericOptionDialog.DLG_OFF;
046: private String pem_message = "";
047:
048: /**
049: *
050: */
051:
052: class MuGenericOptionDialogListener implements IUnGuiEventListener {
053: public void pcmf_execListener(UnComponent xParam) {
054: MuGenericOptionDialog.this .pcmf_getAppl()
055: .pcmf_getUnComponent().pcmf_repaint();
056: return;
057: }
058: }
059:
060: public MuGenericOptionDialog(String xValue,
061: ACoDataGetter xTplGetter, Object xTplName,
062: MuGenericApplication xAppl) throws Exception {
063: super (xValue, xTplGetter, xTplName, xAppl);
064: this .pcmf_setValue(xValue);
065: this .pcmf_setEventOnChange(true);
066: this .pcmf_addListener(new MuGenericOptionDialogListener());
067:
068: return;
069: };
070:
071: // @@
072:
073: public void pcmf_showAlert(String xMessage) {
074: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
075: this .pem_message = xMessage;
076: this .pem_state = MuGenericOptionDialog.DLG_ALERT;
077: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
078: .pcmf_addDlg(this );
079: }
080:
081: public void pcmf_showOption(String xMessage) {
082: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
083: this .pem_message = xMessage;
084: this .pem_state = MuGenericOptionDialog.DLG_OPTION;
085: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
086: .pcmf_addDlg(this );
087: }
088:
089: public void pcmf_showTextInput(String xMessage) {
090: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
091: this .pem_message = xMessage;
092: this .pem_state = MuGenericOptionDialog.DLG_INPUT;
093: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
094: .pcmf_addDlg(this );
095: }
096:
097: public Object pcmf_execView() {
098: if (this .pcmf_isHidden() || this .pcmf_isDisabled())
099: return (new KeStringTemplate(""));
100:
101: this .pcmf_evalRepaint();
102:
103: try {
104: KeStringTemplate l_tpl = this .pcmf_getMarkupString("BODY");
105: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$NAME", this
106: .pcmf_getObjName());
107:
108: return (l_tpl);
109: } catch (Exception e) {
110: KeLog.pcmf_logException("ug2t", this , e);
111: return (new KeStringTemplate("ERROR"));
112: }
113: }
114:
115: public Object pcmf_getOnLoadScript() {
116: if (this .pcmf_isHidden() || this .pcmf_isDisabled())
117: return (new KeStringTemplate(""));
118:
119: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
120: .pcmf_removeDlg(this );
121:
122: switch (this .pem_state) {
123: case MuGenericOptionDialog.DLG_OFF:
124: return (new KeStringTemplate(""));
125:
126: case MuGenericOptionDialog.DLG_ALERT: {
127: this .pem_state = MuGenericOptionDialog.DLG_OFF;
128:
129: KeStringTemplate l_tpl = this .pcmf_getMarkupString("ALERT");
130: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$MESSAGE",
131: this .pem_message);
132: if (this .pcmf_isSubmit())
133: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", this
134: .pcmf_getMarkupString("SUBMIT"));
135: else
136: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", "");
137:
138: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$NAME", this
139: .pcmf_getObjName());
140:
141: return (l_tpl);
142: }
143:
144: case MuGenericOptionDialog.DLG_OPTION: {
145: this .pem_state = MuGenericOptionDialog.DLG_OFF;
146:
147: KeStringTemplate l_tpl = this
148: .pcmf_getMarkupString("OPTION");
149: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$MESSAGE",
150: this .pem_message);
151:
152: if (this .pcmf_isSubmit())
153: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", this
154: .pcmf_getMarkupString("SUBMIT"));
155: else
156: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", "");
157:
158: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$NAME", this
159: .pcmf_getObjName());
160:
161: return (l_tpl);
162: }
163:
164: case MuGenericOptionDialog.DLG_INPUT: {
165: this .pem_state = MuGenericOptionDialog.DLG_OFF;
166:
167: KeStringTemplate l_tpl = this .pcmf_getMarkupString("INPUT");
168: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$MESSAGE",
169: this .pem_message);
170: if (this .pcmf_isSubmit())
171: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", this
172: .pcmf_getMarkupString("SUBMIT"));
173: else
174: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$SUBMIT", "");
175:
176: l_tpl = KeTools.pcmf_stringSubst(l_tpl, "$NAME", this
177: .pcmf_getObjName());
178:
179: return (l_tpl);
180: }
181: }
182:
183: return (new KeStringTemplate(""));
184: }
185:
186: public int pcmf_getState() {
187: return (this .pem_state);
188: }
189:
190: // @@
191:
192: public void pcmf_delete() throws Exception {
193: if (this .pdm_deleted == true)
194: return;
195:
196: IUnApplication l_appl = this .pcmf_getAppl();
197: if (l_appl != null)
198: ((MuGenericApplication) l_appl).pcmf_getRenderer()
199: .pcmf_removeDlg(this);
200:
201: super.pcmf_delete();
202:
203: return;
204: };
205: }
|