01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.client.gwt.widget;
22:
23: import java.util.ArrayList;
24: import java.util.List;
25: import com.google.gwt.user.client.ui.*;
26:
27: public class TabContainer extends Container {
28:
29: private TabBar _tabs = new TabBar();
30:
31: private List _listeners = new ArrayList();
32:
33: public TabContainer() {
34: setWidget(0, 0, _tabs);
35: }
36:
37: public synchronized void addTabListener(TabListener listener) {
38: _listeners.add(listener);
39: _tabs.addTabListener(listener);
40: }
41:
42: public void addTab(String html) {
43: _tabs.addTab(html, true);
44: }
45:
46: public void clearTabs() {
47: while (_tabs.getTabCount() > 0) {
48: _tabs.removeTab(0);
49: }
50: }
51:
52: public synchronized void setActiveTab(int index) {
53: //need to remove all listener first
54: for (int i = 0; i < _listeners.size(); i++) {
55: _tabs.removeTabListener((TabListener) _listeners.get(i));
56: }
57: _tabs.selectTab(index);
58: for (int i = 0; i < _listeners.size(); i++) {
59: _tabs.addTabListener((TabListener) _listeners.get(i));
60: }
61: }
62:
63: public void setContent(Widget w) {
64: if (this .getRowCount() > 1) {
65: Widget oldW = getWidget(1, 0);
66: }
67: setWidget(1, 0, w);
68: }
69: }
|