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.*;
039: import de.ug2t.unifiedGui.interfaces.*;
040:
041: public final class MuGenericTabbedPane extends MuGenericComponent
042: implements IUnTabbedPane, IKePoolable {
043: private IKeView pem_view = new HtmlTabbedPaneRenderer();
044: private UnComponent pem_active = null;
045: private String pem_aName = "";
046: protected boolean pdm_tabsDown = false;
047: private TreeMap pem_headers = null;
048:
049: final class MuTabbedPaneListener implements IUnGuiEventListener {
050: public void pcmf_execListener(UnComponent xParam) {
051: MuGenericTabbedPane l_view = (MuGenericTabbedPane) xParam;
052: l_view.pcmf_setActive(l_view.toString());
053:
054: return;
055: };
056: };
057:
058: public MuGenericTabbedPane(String xName, boolean xTabsDown,
059: ACoDataGetter xTplGetter, Object xTplName,
060: MuGenericApplication xAppl) throws Exception {
061: this (xName, xTplGetter, xTplName, xAppl);
062: this .pdm_tabsDown = xTabsDown;
063: }
064:
065: public MuGenericTabbedPane(String xName, ACoDataGetter xTplGetter,
066: Object xTplName, MuGenericApplication xAppl)
067: throws Exception {
068: super (xName, xTplGetter, xTplName, xAppl);
069:
070: this .pcmf_setView(pem_view);
071: this .pcmf_setValue(xName);
072: this .pcmf_setFill(true, true);
073: this .pdm_getMaxSpace = true;
074:
075: this .pcmf_addListener(new MuTabbedPaneListener());
076:
077: return;
078: };
079:
080: // @@
081:
082: public UnComponent pcmf_setActive(String xName) {
083: Object l_old = this .pem_active;
084:
085: pem_active = (UnComponent) this .pcmf_getSubNode(xName);
086: if (pem_active == null)
087: pem_active = (UnComponent) this .pcmf_getSubElement(xName);
088:
089: if (pem_active == null) {
090: if (this .pcmf_getChildCount() > 0) {
091: KeLog.pcmf_log("ug2t", "tabpane does not contain: "
092: + xName + ", trying to set first pane", this ,
093: KeLog.ERROR);
094: pem_active = (UnComponent) this .pcmf_getAllSubs()
095: .get(0);
096: }
097: }
098: ;
099:
100: if (pem_active != null)
101: this .pem_aName = xName;
102:
103: if (l_old != this .pem_active)
104: this .pcmf_setPropChanged(true);
105:
106: return (pem_active);
107: };
108:
109: public String pcmf_getActiveName() {
110: return (this .pem_aName);
111: };
112:
113: public UnComponent pcmf_getActive() {
114: if (pem_active == null)
115: pem_active = (UnComponent) this .pcmf_getElementAt(0);
116:
117: return (pem_active);
118: };
119:
120: public void pcmf_commitTabs() {
121: if (this .pcmf_getAllSubNames().size() == 0)
122: return;
123:
124: String l_first = (String) this .pcmf_getAllSubNames().get(0);
125: if (l_first != null)
126: this .pcmf_setValue(l_first);
127: }
128:
129: public void pcmf_setValue(Object xObj) {
130: if (xObj != null)
131: this .pcmf_setActive(xObj.toString());
132:
133: super .pcmf_setValue(xObj);
134: }
135:
136: public void pcmf_addTab(String xName, IUnForm xForm) {
137: this .pcmf_addNode(xName, xForm.pcmf_getUnComponent());
138: }
139:
140: public void pcmf_removeTab(String xName) {
141: this .pcmf_removeNode(xName);
142: }
143:
144: public boolean pcmf_isTabDown() {
145: return (this .pdm_tabsDown);
146: }
147:
148: private boolean pem_readOnly = false;
149:
150: public void pcmf_setReadOnly(boolean xReadOnly) {
151: if (this .pem_readOnly == xReadOnly)
152: return;
153:
154: this .pem_readOnly = xReadOnly;
155: this .pcmf_setPropChanged(true);
156: }
157:
158: public boolean pcmf_isReadOnly() {
159: return (this .pem_readOnly);
160: }
161:
162: public void pcmf_reorgTabComponents() {
163: TreeMap l_new = new TreeMap();
164: Iterator l_it = this .pem_headers.values().iterator();
165: int i = 0;
166: while (l_it.hasNext())
167: l_new.put(new Integer(i++), l_it.next());
168:
169: this .pem_headers = l_new;
170: }
171:
172: public void pcmf_setTabComponent(int xIdx, IUnComponent xComp) {
173: if (this .pem_headers == null)
174: this .pem_headers = new TreeMap();
175:
176: this .pem_headers.put(new Integer(xIdx), xComp);
177: }
178:
179: public void pcmf_removeTabComponent(int xIdx) {
180: if (this .pem_headers == null)
181: return;
182:
183: this .pem_headers.remove(new Integer(xIdx));
184: if (this .pem_headers.size() == 0)
185: this .pem_headers = null;
186:
187: return;
188: }
189:
190: public MuGenericComponent pcmf_getTabComponent(int xIdx) {
191: if (this .pem_headers == null)
192: return (null);
193: else
194: return ((MuGenericComponent) this .pem_headers
195: .get(new Integer(xIdx)));
196: }
197:
198: public void pcmf_activateFirst() {
199: KeTreeNode l_node = this .pcmf_getNodeAt(0);
200: if (l_node instanceof IUnMenu)
201: l_node = this .pcmf_getNodeAt(1);
202:
203: this .pcmf_setActive(l_node.pcmf_getName());
204: }
205:
206: public void pcmf_activateNext() {
207: int l_idx = this .pcmf_indexOf(this .pcmf_getActive());
208: KeTreeNode l_node = this .pcmf_getNodeAt(l_idx + 1);
209: if (l_node instanceof IUnMenu)
210: l_node = this .pcmf_getNodeAt(l_idx + 2);
211:
212: this .pcmf_setActive(l_node.pcmf_getName());
213: }
214:
215: public void pcmf_activatePrev() {
216: int l_idx = this .pcmf_indexOf(this .pcmf_getActive());
217: KeTreeNode l_node = this .pcmf_getNodeAt(l_idx - 1);
218: if (l_node instanceof IUnMenu)
219: l_node = this .pcmf_getNodeAt(l_idx - 2);
220:
221: this .pcmf_setActive(l_node.pcmf_getName());
222: }
223:
224: public void pcmf_activateLast() {
225: KeTreeNode l_node = this .pcmf_getNodeAt(this
226: .pcmf_getChildCount() - 1);
227: if (l_node instanceof IUnMenu)
228: l_node = this .pcmf_getNodeAt(this .pcmf_getChildCount() - 2);
229:
230: this .pcmf_setActive(l_node.pcmf_getName());
231: }
232:
233: public int pcmf_getActivatedIndex() {
234: return (this .pcmf_indexOf(this .pcmf_getActive()));
235: }
236:
237: public void pcmf_setActivatedIndex(int xIdx) {
238: this .pcmf_setValue(this .pcmf_getNodeAt(xIdx).pcmf_getName());
239: }
240:
241: // @@
242: }
|