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.ho.*;
036: import de.ug2t.channel.markup.html.renderer.*;
037: import de.ug2t.connector.*;
038: import de.ug2t.kernel.*;
039: import de.ug2t.unifiedGui.*;
040: import de.ug2t.unifiedGui.interfaces.*;
041:
042: public class MuGenericTreeView extends MuGenericComponent implements
043: IUnTreeView, IKePoolable {
044: protected KeTreeNode pdm_root = null;
045: private IKeView pem_view = new HtmlTreeViewRenderer();
046:
047: private boolean pem_multiSelection = false;
048: private HoGenericDataContainer pem_container = null;
049: protected MuGenericScrollController pdm_scrCrt = null;
050: protected int pdm_renderedLines = 0;
051: private KeTreeNode pem_toggled = null;
052: private UnComponent pem_metaKey = null;
053: private IKeExecutable pem_cHandler = null;
054:
055: public boolean pcmf_setMultiSelection(boolean xMulti) {
056: if (xMulti == this .pem_multiSelection)
057: return (xMulti);
058:
059: boolean l_old = this .pem_multiSelection;
060:
061: if (this .pem_container == null && xMulti == true)
062: this .pem_container = new HoGenericDataContainer();
063:
064: this .pem_multiSelection = xMulti;
065: this .pcmf_setPropChanged(true);
066:
067: return (l_old);
068: };
069:
070: public boolean pcmf_isMultiSelection() {
071: return (this .pem_multiSelection);
072: }
073:
074: public HoGenericDataContainer pcmf_getValues() {
075: return (this .pem_container);
076: }
077:
078: public MuGenericTreeView(String xName, KeTreeNode xRoot,
079: ACoDataGetter xTplGetter, Object xTplName,
080: MuGenericApplication xAppl) throws Exception {
081: super (xName, xTplGetter, xTplName, xAppl);
082: this .pdm_scrCrt = new MuGenericScrollController("myscrcrt",
083: this );
084: this .pcmf_setEventOnChange(true);
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_setBgColor("white");
094: this .pcmf_setFill(true, true);
095: this .pdm_getMaxSpace = true;
096:
097: this .pem_metaKey = (UnComponent) KeRegisteredObject
098: .pcmf_getObjByName(IUnApplication.MY_META_KEY);
099: pdm_root.pcmf_hideLevel(1);
100: this .pcmf_enableSubmit();
101:
102: return;
103: };
104:
105: // @@
106:
107: public int pcmf_getRendererLines() {
108: return (this .pdm_renderedLines);
109: }
110:
111: public void pcmf_setRendererLines(int xLines) {
112: this .pdm_renderedLines = xLines;
113: }
114:
115: public void pcmf_incRendererLines() {
116: this .pdm_renderedLines++;
117: }
118:
119: public void pcmf_disable() {
120: Iterator l_it = this .pdm_root.pcmf_getSubIterator();
121: while (l_it.hasNext())
122: ((KeTreeElement) l_it.next()).pcmf_disable();
123:
124: if (this .pdm_root != this ) {
125: l_it = this .pcmf_getSubIterator();
126: while (l_it.hasNext())
127: ((KeTreeElement) l_it.next()).pcmf_disable();
128: }
129:
130: super .pcmf_disableThis();
131: };
132:
133: public void pcmf_enable() {
134: Iterator l_it = this .pdm_root.pcmf_getSubIterator();
135: while (l_it.hasNext())
136: ((KeTreeElement) l_it.next()).pcmf_enable();
137:
138: if (this .pdm_root != this ) {
139: l_it = this .pcmf_getSubIterator();
140: while (l_it.hasNext())
141: ((KeTreeElement) l_it.next()).pcmf_enable();
142: }
143:
144: super .pcmf_enableThis();
145: };
146:
147: public void pcmf_setValues(HoGenericDataContainer xValues) {
148: this .pcmf_setValue(xValues);
149: }
150:
151: public void pcmf_setValue(Object xObj) {
152: this .pem_toggled = null;
153:
154: if (xObj instanceof HoGenericDataContainer
155: && this .pem_multiSelection) {
156: this .pem_container.pcmf_copy((HoGenericDataContainer) xObj);
157:
158: Iterator l_it = this .pem_container.pcmf_getValueIt();
159: Object l_cobj = null;
160: while (l_it.hasNext()) {
161: l_cobj = l_it.next();
162: if (l_cobj != null) {
163: KeTreeNode l_node = ((KeTreeElement) l_cobj)
164: .pcmf_getParentNode();
165: while (l_node != this .pdm_root && l_node != null) {
166: l_node.pcmf_unhide();
167: l_node = l_node.pcmf_getParentNode();
168: }
169: }
170: }
171: } else if (xObj instanceof KeTreeElement == false
172: && xObj != null) {
173: String l_str = xObj.toString();
174: if (l_str.length() != 0) {
175: String l_oc = l_str.substring(0, 1);
176: xObj = KeRegisteredObject.pcmf_getObjByName(l_str
177: .substring(1));
178:
179: if (l_oc.equals("O") && xObj instanceof KeTreeNode) {
180: ((KeTreeNode) xObj).pcmf_unhide();
181: this .pem_toggled = ((KeTreeNode) xObj);
182: this .pcmf_setPropChanged(true);
183: return;
184: } else if (l_oc.equals("C")
185: && xObj instanceof KeTreeNode) {
186: ((KeTreeNode) xObj).pcmf_hide();
187: this .pem_toggled = ((KeTreeNode) xObj);
188: this .pcmf_setPropChanged(true);
189: return;
190: }
191: }
192: }
193: if (this .pem_multiSelection
194: && xObj instanceof HoGenericDataContainer == false) {
195: if (pem_metaKey.pcmf_getValue().equals("CTRL")) {
196: if (this .pem_container.pcmf_contains(xObj)) {
197: this .pem_container.pcmf_removeValue(xObj);
198: } else {
199: if (xObj instanceof KeRegisteredObject)
200: this .pem_container
201: .pcmf_addValue((KeRegisteredObject) xObj);
202: }
203: } else {
204: this .pem_container.pcmf_clearValues();
205: if (xObj instanceof KeRegisteredObject)
206: this .pem_container
207: .pcmf_addValue((KeRegisteredObject) xObj);
208: }
209: }
210: if (this .pem_multiSelection) {
211: if (this .pem_container.pcmf_size() > 0)
212: xObj = this .pem_container
213: .pcmf_getValueAt(this .pem_container.pcmf_size() - 1);
214: else
215: xObj = this .pdm_root;
216: }
217: if (xObj != null && xObj instanceof KeTreeElement) {
218: KeTreeNode l_node = ((KeTreeElement) xObj)
219: .pcmf_getParentNode();
220: while (l_node != this .pdm_root && l_node != null) {
221: l_node.pcmf_unhide();
222: l_node = l_node.pcmf_getParentNode();
223: }
224: }
225:
226: super .pcmf_setValue(xObj);
227:
228: return;
229: };
230:
231: public KeTreeNode pcmf_getRoot() {
232: return (this .pdm_root);
233: }
234:
235: public KeTreeNode pcmf_setRoot(KeTreeNode xRoot) {
236: if (xRoot == this .pdm_root)
237: return (xRoot);
238:
239: KeTreeNode l_node = this .pdm_root;
240:
241: if (l_node != null && l_node != this )
242: this .pcmf_removeNode(l_node);
243:
244: this .pdm_root = xRoot;
245:
246: if (xRoot != this )
247: this .pcmf_addNode(xRoot.pcmf_getName(), xRoot);
248:
249: this .pcmf_setPropChanged(true);
250:
251: return (l_node);
252: };
253:
254: public void pcmf_scrollXRel(int xPx) {
255: this .pdm_scrCrt.pcmf_scrollXRel(xPx);
256: }
257:
258: public void pcmf_scrollXAbs(int xPx) {
259: this .pdm_scrCrt.pcmf_scrollXAbs(xPx);
260: }
261:
262: public void pcmf_scrollYRel(int xPy) {
263: this .pdm_scrCrt.pcmf_scrollYRel(xPy);
264: }
265:
266: public void pcmf_scrollYAbs(int xPy) {
267: this .pdm_scrCrt.pcmf_scrollYAbs(xPy);
268: }
269:
270: public int pcmf_getXScroll() {
271: return (this .pdm_scrCrt.pcmf_getX());
272: }
273:
274: public int pcmf_getYScroll() {
275: return (this .pdm_scrCrt.pcmf_getY());
276: }
277:
278: public KeTreeNode pcmf_getToggled() {
279: return (this .pem_toggled);
280: }
281:
282: public void pcmf_setCommitHandler(IKeExecutable xHandler) {
283: this .pem_cHandler = xHandler;
284: }
285:
286: public void pcmf_clearCommitHandler() {
287: this .pem_cHandler = null;
288: }
289:
290: public void pcmf_commitTree() {
291: if (this .pem_cHandler != null)
292: this .pem_cHandler.pcmf_execObj(this );
293:
294: this .pcmf_setPropChanged(true);
295:
296: return;
297: }
298:
299: public MuGenericScrollController pcmf_getScrollCrt() {
300: return (this .pdm_scrCrt);
301: }
302:
303: public void pcmf_setEditable(boolean xEditable) {
304: // Not implemented in Markup-Channel
305: return;
306: }
307:
308: public void pcmf_setPartialRenderLineLimit(int xLimit) {
309: // @@
310: }
311:
312: public int pcmf_getPartialRenderLineLimit() {
313: int l_ret = 0;
314: // @@
315: return (l_ret);
316: }
317:
318: public void pcmf_delete() throws Exception {
319: if (this .pdm_deleted == true)
320: return;
321:
322: this .pdm_scrCrt.pcmf_delete();
323: if (this .pem_container != null)
324: this .pem_container.pcmf_delete();
325:
326: super .pcmf_delete();
327: }
328:
329: // @@
330: }
|