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 java.util.*;
034:
035: import de.ug2t.channel.markup.html.renderer.*;
036: import de.ug2t.connector.*;
037: import de.ug2t.kernel.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039:
040: public final class MuGenericListBox extends MuGenericComponent
041: implements IUnListBox, IKePoolable {
042: private HashMap pem_values = new LinkedHashMap();
043: private IKeView pem_view = new HtmlListBoxRenderer();
044: private int pem_size;
045: protected MuGenericScrollController pdm_scrCrt = null;
046:
047: public MuGenericListBox(String xName, String xValue,
048: String xString, int xSize, ACoDataGetter xTplGetter,
049: Object xTplName, MuGenericApplication xAppl)
050: throws Exception {
051: super (xName, xTplGetter, xTplName, xAppl);
052:
053: this .pcmf_setView(pem_view);
054: if (xString != null && xString.equals("") == false) {
055: this .pcmf_addValue(xValue, xString);
056: this .pcmf_setValue(xValue);
057: }
058: this .pem_size = xSize;
059: this .pdm_scrCrt = new MuGenericScrollController("myscrcrt",
060: this );
061: this .pcmf_setFill(true, true);
062: this .pcmf_setBgColor("white");
063:
064: return;
065: };
066:
067: // @@
068:
069: public void pcmf_addValueObj(String xValue, KeRegisteredObject xObj) {
070: this .pcmf_addValue(xValue, xObj);
071: this .pcmf_setPropChanged(true);
072: }
073:
074: public void pcmf_addValue(String xValue, String xString) {
075: pem_values.put(xValue, xString);
076: this .pcmf_setPropChanged(true);
077: };
078:
079: private void pcmf_addValue(String xValue, Object xString) {
080: if (xString instanceof KeTreeNode)
081: this .pcmf_addNode(xValue, (KeTreeNode) xString);
082:
083: pem_values.put(xValue, xString);
084: this .pcmf_setPropChanged(true);
085: };
086:
087: public void pcmf_removeValue(String xValue) {
088: this .pcmf_removeNode(xValue);
089: pem_values.remove(xValue);
090: this .pcmf_setPropChanged(true);
091: };
092:
093: public int pcmf_getVisibleRows() {
094: return (pem_size);
095: };
096:
097: public void pcmf_setVisibleRows(int xSize) {
098: if (xSize == this .pem_size)
099: return;
100:
101: this .pem_size = xSize;
102: if (this .pem_view instanceof HtmlListBoxRenderer)
103: ((HtmlListBoxRenderer) this .pem_view).pcmf_setSize(true);
104:
105: this .pcmf_setPropChanged(true);
106: }
107:
108: public void pcmf_clearListBox() {
109: this .pem_values.clear();
110:
111: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
112: .iterator();
113: Object l_obj = null;
114: while (l_it.hasNext()) {
115: l_obj = l_it.next();
116: if (l_obj instanceof IUnContextMenu
117: || l_obj instanceof IUnEventChannel)
118: continue;
119:
120: this .pcmf_removeNode((KeTreeNode) l_obj);
121: }
122:
123: this .pcmf_setPropChanged(true);
124: }
125:
126: public void pcmf_clearAndReleaseListBox() {
127: this .pem_values.clear();
128:
129: Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
130: .iterator();
131: Object l_obj = null;
132: while (l_it.hasNext()) {
133: l_obj = l_it.next();
134: if (l_obj instanceof IUnContextMenu
135: || l_obj instanceof IUnEventChannel)
136: continue;
137:
138: this .pcmf_removeNode((KeTreeNode) l_obj);
139: ((KeTreeNode) l_obj).pcmf_releaseSubs();
140: }
141:
142: this .pcmf_setPropChanged(true);
143: }
144:
145: public Object pcmf_getSelectedObject() {
146: int l_idx = this .pcmf_getSelectedRow();
147: if (l_idx == -1)
148: return (null);
149:
150: Object l_ret = this .pem_values.keySet().toArray()[l_idx];
151: return (l_ret);
152: }
153:
154: public Object pcmf_setSelectedRow(int xRow) {
155: if (xRow >= this .pem_values.size())
156: return (null);
157:
158: Object l_ret = this .pem_values.keySet().toArray()[xRow];
159: this .pcmf_setValue(l_ret);
160:
161: return (l_ret);
162: }
163:
164: public int pcmf_getSelectedRow() {
165: return (new ArrayList(this .pem_values.keySet()).indexOf(this
166: .pcmf_getValue()));
167: }
168:
169: public void pcmf_scrollXRel(int xPx) {
170: this .pdm_scrCrt.pcmf_scrollXRel(xPx);
171: }
172:
173: public void pcmf_scrollXAbs(int xPx) {
174: this .pdm_scrCrt.pcmf_scrollXAbs(xPx);
175: }
176:
177: public void pcmf_scrollYRel(int xPy) {
178: this .pdm_scrCrt.pcmf_scrollYRel(xPy);
179: }
180:
181: public void pcmf_scrollYAbs(int xPy) {
182: this .pdm_scrCrt.pcmf_scrollYAbs(xPy);
183: }
184:
185: public int pcmf_getXScroll() {
186: return (this .pdm_scrCrt.pcmf_getX());
187: }
188:
189: public int pcmf_getYScroll() {
190: return (this .pdm_scrCrt.pcmf_getY());
191: }
192:
193: public MuGenericScrollController pcmf_getScrollCrt() {
194: return (this .pdm_scrCrt);
195: }
196:
197: private boolean pem_readOnly = false;
198:
199: public void pcmf_setReadOnly(boolean xReadOnly) {
200: if (this .pem_readOnly == xReadOnly)
201: return;
202:
203: this .pem_readOnly = xReadOnly;
204: this .pcmf_setPropChanged(true);
205: }
206:
207: public boolean pcmf_isReadOnly() {
208: return (this .pem_readOnly);
209: }
210:
211: public void pcmf_delete() throws Exception {
212: if (this .pdm_deleted == true)
213: return;
214:
215: this .pdm_scrCrt.pcmf_delete();
216:
217: super .pcmf_delete();
218: }
219:
220: // @@
221:
222: public HashMap pcmf_getValues() {
223: return (pem_values);
224: }
225:
226: public void pcmf_clearListWidget() {
227: this .pcmf_clearListBox();
228: }
229:
230: public void pcmf_clearAndReleaseListWidget() {
231: this .pcmf_clearAndReleaseListBox();
232: }
233:
234: public void pcmf_beginTr() {
235: return;
236: }
237:
238: public void pcmf_commitTr() {
239: return;
240: }
241:
242: public boolean pcmf_isSelectable() {
243: return (true);
244: }
245: }
|