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 MuGenericFileChooser extends MuGenericComponent
039: implements IUnFileChooser, IKePoolable, IUnGuiEventListener {
040: private IUnButton pem_submit = null;
041: private char pem_mode = 'r';
042: private boolean pem_open = false;
043: private boolean pem_upload = false;
044:
045: class MuGenericFcListener implements IUnGuiEventListener {
046: public void pcmf_execListener(UnComponent xParam) {
047: if (xParam.pcmf_getValue().toString().trim().equals(""))
048: xParam.pcmf_consumeEvent();
049:
050: MuGenericFileChooser.this .pem_open = false;
051: return;
052: }
053: }
054:
055: /**
056: * @param xName
057: * @param xTplGetter
058: * @param xTplName
059: * @param xAppl
060: * @throws Exception
061: */
062: public MuGenericFileChooser(String xName, String xValue,
063: ACoDataGetter xTplGetter, Object xTplName,
064: MuGenericApplication xAppl) throws Exception {
065: super (xName, xTplGetter, xTplName, xAppl);
066: super .pcmf_setValue(xValue);
067: this .pcmf_setEventOnChange(true);
068:
069: this .pem_submit = this .pcmf_getAppl()
070: .pcmf_getComponentFactory().pcmf_createButton(
071: UnComponentFactory.MARKUP, " OK ",
072: this .pcmf_getAppl());
073:
074: this .pcmf_setBgColor("silver");
075: this .pcmf_setPosition(300, 200, 0, 0, null);
076: this .pcmf_setEventOnChange(true);
077: this .pcmf_addListener(new MuGenericFcListener());
078:
079: return;
080: }
081:
082: // @@
083:
084: public void pcmf_setUploadReadFile(boolean xUpload) {
085: this .pem_upload = xUpload;
086: }
087:
088: /**
089: * <p>
090: * Does...
091: * </p>
092: * <p>
093: *
094: * @return a Type with
095: * </p>
096: * <p>
097: * @param
098: * </p>
099: */
100: public void pcmf_selectReadFile() {
101: this .pem_open = true;
102: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
103: this .pem_mode = 'r';
104: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
105: .pcmf_addDlg(this );
106: }
107:
108: /**
109: * <p>
110: * Does...
111: * </p>
112: * <p>
113: *
114: * @return a Type with
115: * </p>
116: * <p>
117: * @param
118: * </p>
119: */
120: public void pcmf_selectFile() {
121: this .pem_open = true;
122: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
123: this .pem_mode = 's';
124: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
125: .pcmf_addDlg(this );
126: }
127:
128: /**
129: * <p>
130: * Does...
131: * </p>
132: * <p>
133: *
134: * @return a Type with
135: * </p>
136: * <p>
137: * @param
138: * </p>
139: */
140: public void pcmf_selectWriteFile() {
141: this .pem_open = true;
142: this .pcmf_getAppl().pcmf_getUnComponent().pcmf_repaint();
143: this .pem_mode = 'w';
144: ((MuGenericApplication) this .pcmf_getAppl()).pcmf_getRenderer()
145: .pcmf_addDlg(this );
146: }
147:
148: /**
149: * <p>
150: * Does...
151: * </p>
152: * <p>
153: *
154: * @return a Type with
155: * </p>
156: * <p>
157: * @param
158: * </p>
159: */
160: public char pcmf_getMode() {
161: return (this .pem_mode);
162: };
163:
164: public Object pcmf_execView() {
165: try {
166: if (!this .pem_upload)
167: this .pcmf_evalRepaint();
168:
169: if (this .pcmf_isHidden() || this .pcmf_isDisabled()
170: || this .pem_open == false)
171: return (((MuGenericApplication) this .pcmf_getAppl())
172: .pcmf_getRenderer().pcmf_wrapMarkup("", this ));
173:
174: if (this .pem_upload)
175: ((MuGenericApplication) this .pcmf_getAppl())
176: .pcmf_setMultiPart(true);
177:
178: KeStringTemplate l_string = this
179: .pcmf_getMarkupString("MAIN");
180:
181: l_string.pcmf_beginTR();
182:
183: l_string = KeTools.pcmf_stringSubst(l_string, "$OID", this
184: .pcmf_getObjName());
185: l_string = KeTools.pcmf_stringSubst(l_string, "$NAME", this
186: .pcmf_getObjName());
187: l_string = KeTools.pcmf_stringSubst(l_string, "$SUBMIT",
188: this .pem_submit.pcmf_getUnComponent()
189: .pcmf_execView().toString());
190:
191: l_string.pcmf_endTR(true);
192:
193: l_string = this .pcmf_insertToolTip(l_string);
194: l_string = this .pcmf_insertColorandFontandBorder(l_string);
195: l_string = this .pcmf_insertPosition(l_string);
196: l_string = this .pcmf_insertChannelandMenu(l_string);
197:
198: return (((MuGenericApplication) this .pcmf_getAppl())
199: .pcmf_getRenderer().pcmf_wrapMarkup(l_string
200: .toString(), this ));
201: } catch (Exception e) {
202: KeLog.pcmf_logException("ug2t", this , e);
203: return ("ERROR");
204: }
205: };
206:
207: // @@
208:
209: public void pcmf_delete() throws Exception {
210: if (this .pdm_deleted == true)
211: return;
212:
213: this .pem_submit.pcmf_getUnComponent().pcmf_delete();
214: this .pem_submit = null;
215:
216: IUnApplication l_appl = this .pcmf_getAppl();
217: if (l_appl != null)
218: ((MuGenericApplication) l_appl).pcmf_getRenderer()
219: .pcmf_removeDlg(this );
220:
221: super .pcmf_delete();
222:
223: return;
224: }
225:
226: public void pcmf_setValue(Object xObj) {
227: this .pcmf_setPropChanged(true);
228: super .pcmf_setValue(xObj);
229: };
230:
231: public void pcmf_execListener(UnComponent xParam) throws Exception {
232: this.pcmf_selectFile();
233: }
234: }
|