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.ho.client.swing;
032:
033: import java.awt.*;
034: import java.util.*;
035:
036: import javax.swing.*;
037: import javax.swing.event.*;
038:
039: import de.ug2t.channel.ho.client.swing.enhanced.*;
040: import de.ug2t.kernel.*;
041: import de.ug2t.unifiedGui.interfaces.*;
042:
043: public final class HoSwingTabbedPane extends HoSwingComponent implements
044: IUnTabbedPane {
045: protected EnhancedTabbedPane pdm_swingObj = null;
046:
047: public HoSwingTabbedPane(String xName, boolean xTabsDown,
048: IUnApplication xAppl) throws Exception {
049: this (xName, xAppl);
050: if (xTabsDown == true)
051: this .pdm_swingObj.setTabPlacement(JTabbedPane.BOTTOM);
052: }
053:
054: public HoSwingTabbedPane(String xName, IUnApplication xAppl)
055: throws Exception {
056: super (xName, xAppl);
057:
058: this .pdm_swingObj = new EnhancedTabbedPane(JTabbedPane.TOP);
059:
060: // Test
061: // JComponent l_cont1 = new JButton("Dirk1");
062: // JComponent l_cont2 = new JButton("Dirk2");
063: // JPanel l_panel = new JPanel();
064: // l_panel.setLayout(new FlowLayout());
065: // l_panel.add(l_cont1);
066: // l_panel.add(l_cont2);
067: // l_panel.setBackground(Color.GREEN);
068: //
069: // l_cont2.setToolTipText("test");
070: //
071: // ((EnhancedTabbedPane)this.pdm_swingObj).pcmf_addTabComponent(0, l_panel);
072: // Test Ende
073:
074: super .pdm_realSwingCmp = this .pdm_swingObj;
075: ((HoSwingClient) xAppl).pcmf_addKeyDispatcher(this );
076:
077: this .pcmf_setLocalValue("");
078:
079: ChangeListener l = new ChangeListener() {
080: public void stateChanged(ChangeEvent ev) {
081: try {
082: // Listener wird auch während des Aufbaus aufgerufen, wenn noch keine
083: // Seite akiviert ist.
084: if (HoSwingTabbedPane.this .pcmf_getAppl() == null
085: || HoSwingTabbedPane.this .pcmf_getAppl()
086: .pcmf_getActive() == null)
087: return;
088:
089: String l_objName = HoSwingTabbedPane.this
090: .pcmf_getObjName();
091:
092: // Lokale Listener aufrufen
093: int l_selIdx = HoSwingTabbedPane.this .pdm_swingObj
094: .getSelectedIndex();
095: if (l_selIdx != -1) {
096: ArrayList l_subs = HoSwingTabbedPane.this
097: .pcmf_getAllSubNames();
098: if (l_subs.size() == 0)
099: return;
100:
101: Object l_selObj = l_subs.get(l_selIdx);
102: HoSwingTabbedPane.this
103: .pcmf_setLocalValue(l_selObj);
104: }
105:
106: HoSwingTabbedPane.this .pcmf_setRefresh();
107: HoSwingTabbedPane.this .pcmf_dispatchEvent();
108:
109: if (HoSwingTabbedPane.this .pem_session
110: .pcmf_isDisabled())
111: return;
112:
113: // Werte setzen um diese zum Server zu übertragen
114: ((HoSwingPage) HoSwingTabbedPane.this
115: .pcmf_getAppl().pcmf_getActive())
116: .pcmf_setSubmitValue(l_objName,
117: HoSwingTabbedPane.this
118: .pcmf_getValue().toString());
119: HoSwingTabbedPane.this .pcmf_addSyncedWidgets(
120: (HoSwingPage) HoSwingTabbedPane.this
121: .pcmf_getAppl().pcmf_getActive(),
122: HoSwingTabbedPane.this );
123: if (HoSwingTabbedPane.this .pcmf_getUnComponent()
124: .pcmf_isSubmit() == true)
125: ((HoSwingPage) HoSwingTabbedPane.this
126: .pcmf_getAppl().pcmf_getActive())
127: .pcmf_submit();
128:
129: HoSwingTabbedPane.this .pcmf_repaint();
130: } catch (Exception e) {
131: KeLog.pcmf_logException("ug2t", this , e);
132: }
133: ;
134: };
135: };
136:
137: this .pdm_swingObj.addChangeListener(l);
138:
139: return;
140: };
141:
142: public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
143: KeTreeNode l_ret = super .pcmf_addNode(xName, xNode);
144:
145: this .pdm_swingObj.setTitleAt(this .pdm_swingObj
146: .getComponentCount() - 1, xName);
147: if (xNode instanceof HoSwingForm) {
148: HoSwingImage l_image = (HoSwingImage) ((HoSwingForm) xNode)
149: .pcmf_getIcon();
150: if (l_image != null)
151: this .pdm_swingObj.setIconAt(this .pdm_swingObj
152: .getComponentCount() - 1, ((JLabel) l_image
153: .pcmf_getRealSwingObj()).getIcon());
154: }
155:
156: return (l_ret);
157: };
158:
159: public KeTreeElement pcmf_addElement(String xName,
160: KeTreeElement xNode) {
161: KeTreeElement l_ret = super .pcmf_addElement(xName, xNode);
162:
163: this .pdm_swingObj.setTitleAt(this .pdm_swingObj
164: .getComponentCount() - 1, xName);
165: if (xNode instanceof HoSwingForm) {
166: HoSwingImage l_image = (HoSwingImage) ((HoSwingForm) xNode)
167: .pcmf_getIcon();
168: if (l_image != null)
169: this .pdm_swingObj.setIconAt(this .pdm_swingObj
170: .getComponentCount() - 1, ((JLabel) l_image
171: .pcmf_getRealSwingObj()).getIcon());
172: }
173:
174: return (l_ret);
175: };
176:
177: public void pcmf_commitTabs() {
178: Iterator l_it = this .pcmf_getSubIterator();
179: HoSwingForm l_form = null;
180: int i = 0;
181: HoSwingImage l_image = null;
182:
183: while (l_it.hasNext()) {
184: l_form = (HoSwingForm) l_it.next();
185: l_image = (HoSwingImage) l_form.pcmf_getIcon();
186: if (l_image != null)
187: this .pdm_swingObj.setIconAt(i, ((JLabel) l_image
188: .pcmf_getRealSwingObj()).getIcon());
189:
190: if (l_form.pcmf_isDisabled())
191: this .pdm_swingObj.setEnabledAt(i, false);
192:
193: i++;
194: }
195:
196: this .pdm_swingObj.repaint();
197:
198: return;
199: };
200:
201: public void pcmf_setValue(Object xValue) {
202: Component l_pane = null;
203: HoSwingComponent l_sobj = ((HoSwingComponent) this
204: .pcmf_getSubNode(xValue.toString()));
205:
206: if (l_sobj == null) {
207: KeLog.pcmf_log("ug2t",
208: "can not set value to tabpane, tab not found: "
209: + xValue, this , KeLog.MESSAGE);
210: return;
211: }
212: l_pane = l_sobj.pcmf_getRealSwingObj();
213: this .pdm_swingObj.setSelectedComponent(l_pane);
214:
215: super .pcmf_setValue(xValue);
216:
217: return;
218: };
219:
220: public void pcmf_addTab(String xName, IUnForm xForm) {
221: this .pcmf_addNode(xName, xForm.pcmf_getUnComponent());
222: }
223:
224: public void pcmf_removeTab(String xName) {
225: this .pcmf_removeNode(xName);
226: }
227:
228: public void pcmf_setReadOnly(boolean xReadOnly) {
229: this .pdm_swingObj.setEnabled(!xReadOnly);
230: }
231:
232: public boolean pcmf_isReadOnly() {
233: return (!this .pdm_swingObj.isEnabled());
234: }
235:
236: public java.awt.Container pcmf_getSwingWidget() {
237: return (this .pdm_swingObj);
238: }
239:
240: public boolean pcmf_isTabDown() {
241: return (this .pdm_swingObj.getTabPlacement() == JTabbedPane.BOTTOM);
242: }
243:
244: public void pcmf_reorgTabComponents() {
245: this .pdm_swingObj.pcmf_reorgTabComponents();
246: }
247:
248: public void pcmf_setTabComponent(int xIdx, IUnComponent xComp) {
249: this .pdm_swingObj.pcmf_setTabComponent(xIdx,
250: ((HoSwingComponent) xComp).pcmf_getRealSwingObj());
251: }
252:
253: public void pcmf_removeTabComponent(int xIdx) {
254: this .pdm_swingObj.pcmf_removeTabComponent(xIdx);
255: }
256:
257: public void pcmf_delete() throws Exception {
258: this .pdm_swingObj.pcmf_cleanup();
259:
260: super .pcmf_delete();
261: }
262:
263: public void pcmf_activateFirst() {
264: throw (new UnsupportedOperationException());
265: }
266:
267: public void pcmf_setActivatedIndex(int xIdx) {
268: throw (new UnsupportedOperationException());
269: }
270:
271: public void pcmf_activateNext() {
272: throw (new UnsupportedOperationException());
273: }
274:
275: public void pcmf_activatePrev() {
276: throw (new UnsupportedOperationException());
277: }
278:
279: public void pcmf_activateLast() {
280: throw (new UnsupportedOperationException());
281: }
282:
283: public int pcmf_getActivatedIndex() {
284: throw (new UnsupportedOperationException());
285: }
286: }
|