1 /*--------------------------------------------------------------------------
2 * Copyright 2007 utgenome.org
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *--------------------------------------------------------------------------*/
16 //--------------------------------------
17 // Aqua Project
18 //
19 // TabEntry.java
20 // Since: 2007/03/24
21 //
22 // $URL$
23 // $Author$
24 //--------------------------------------
25 package org.utgenome.gwt.utgb.client.ui.tab;
26
27 import com.google.gwt.user.client.ui.Composite;
28
29 /**
30 * A TabEntry is a single panel of the TabViewer. They are meant to be lazily
31 * instantiated so that the viewer doesn't load all of the tabbed panels.
32 *
33 * Each TabEntry is expected to have a static <code>factory()</code> method that
34 * will be called by the TabViewer on startup.
35 *
36 * <code>createInstance()</code> must be defined in eath TabEntryFactory.
37 *
38 * Example: <code>
39 * clsss MyTab extends TabEntry
40 * {
41 * pubic static TabEntryFactory factory()
42 * {
43 * return new TabEntryFactory("my tab", "a description of the tab") {
44 * public TabEntry createInstance() {
45 * return new MyTab();
46 * }
47 * };
48 * }
49 * }
50 * </code>
51 *
52 * @author leo
53 *
54 */
55 public abstract class TabEntry extends Composite implements TabEventListener
56 {
57
58 /**
59 * Encapsulated information about a TabEntry.
60 *
61 * @author leo
62 */
63 public abstract static class TabEntryFactory
64 {
65 private TabEntry _instance = null;
66
67 private String _tabName, _description;
68
69 public TabEntryFactory(String name, String description)
70 {
71 _tabName = name;
72 _description = description;
73 }
74
75 public String getDescription()
76 {
77 return _description;
78 }
79
80 public String getTabName()
81 {
82 return _tabName;
83 }
84
85 public abstract TabEntry createInstance();
86
87 public boolean isInstanciated()
88 {
89 return _instance != null;
90 }
91
92 public final TabEntry getInstance()
93 {
94 if (_instance != null)
95 return _instance;
96
97 return (_instance = createInstance());
98 }
99 }
100
101 public void onFocus()
102 {
103 // do nothing
104 }
105
106 public void onLostFocus()
107 {
108 // do nothing
109 }
110
111 }