2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.swing.tabcontrol;
44
import org.netbeans.swing.tabcontrol.event.ComplexListDataListener;
47
import javax.swing.event.ChangeListener;
48
import java.util.Collections;
49
import java.util.List;
52
* A data model representing a set of tabs and their associated data. Allows for
53
* atomic add/remove/modification operations any of which are guaranteed to fire
54
* only one event on completion. Note that for modification operations
55
* (<code>setText()</code>, <code>setIcon</code>, <code>setIconsAndText</code>,
56
* no event will be fired unless data is actually changed - calling these
57
* methods with the same values that the tabs already have will not generate
58
* events. The <code>isWidthChanged</code> method for generated events will
59
* return <code>true</code> for events which can affect the area needed to
60
* display a tab (such as text or icon width changes).
62
* Note: The standard UI implementations which use this model make no provisions
63
* for thread-safety. All changes fired from a TabDataModel should happen on the
66
* @author Tim Boudreau
68
public interface TabDataModel {
70
* The number of tabs contained in the model.
72
* @return The number of tabs
77
* Retrieve data for a given tab
79
* @param index The index for which to retrieve tab data
80
* @return Data describing the tab
82
public TabData getTab(int index);
85
* Set the tab data for a given tab to the passed value
87
* @param index The index of the tab to be changed
88
* @param data The new tab data for this index
90
public void setTab(int index, TabData data);
93
* Set the icon for a given tab. Will trigger a list data event, and the
94
* resulting event's widthChanged property will be set appropriately if the
95
* displayed width has changed.
97
* @param index The index to set the icon for
98
* @param i The icon to use for the tab
100
public void setIcon(int index, Icon i);
103
* Set the text for a given tab. Triggers a list data event.
105
* @param index The index of the tab
106
* @param txt The replacement text
108
public void setText(int index, String txt);
111
* Atomically set the icons for a set of indices. Fires a single list data
112
* event with the indexes of any tabs in which the data was actually
113
* changed. If the passed data perfectly match the existing data, no event
116
* @param indices The indices for which the corresponding icons should be
118
* @param icons The replacement icons. This array must be the same length
119
* as the indices parameter
121
public void setIcon(int[] indices, Icon[] icons);
124
* Atomically set the text for a number of tabs. Fires a single list data
125
* event with the indexes of any tabs in which the data was actually
126
* changed. If the passed data perfectly match the existing data, no event
129
* @param indices The indices of the tabs to change
130
* @param txt The text values for the tabs
132
public void setText(int[] indices, String[] txt);
135
* Atomically set the icons and text simultaneously for more than one tab.
136
* Fires a single list data event with the indexes of any tabs in which the
137
* data was actually changed. If the passed data perfectly match the
138
* existing data, no event will be fired.1
140
* @param indices The indices which should have their data changed
141
* @param txt The replacement text values corresponding to the passed
143
* @param icons The replacement icons corresponding to the passed indices
145
public void setIconsAndText(int[] indices, String[] txt, Icon[] icons);
148
* Atomically add a set of tabs at the specified index
150
* @param start The insert point for new tabs
151
* @param data The tab data to insert
153
public void addTabs(int start, TabData[] data);
156
* Remove the tab at the specified index
158
* @param index The tab index
160
public void removeTab(int index);
163
* Add the specified tabs at the specified indices
165
* @param indices The indices at which tabs will be added
166
* @param data The tabs to add, in order corresponding to the indices
169
public void addTabs(int[] indices, TabData[] data);
172
* Replace the entire set of tabs represented by the model
174
public void setTabs(TabData[] data);
177
* Remove the tabs at the specified indices
179
* @param indices The indices at which tabs should be removed
181
public void removeTabs(int[] indices);
184
* Remove a range of tabs
186
* @param start the start index
187
* @param end the end index
189
public void removeTabs(int start, int end);
192
* Add a single tab at the specified location
194
public void addTab(int index, TabData data);
197
* Retrieve all the tab data contained in the model as a List
199
* @return a List of TabData objects
201
public java.util.List<TabData> getTabs();
204
* Fetch the index of a tab matching the passed TabData object. Note that
205
* the tooltip property of the passed TabData object is not used to test
208
* See also <a href="@org-netbeans-core-windows@/org/netbeans/core/windows/ui/TabData.html#equals()">org.netbeans.core.windows.ui.TabData.equals()</a><BR>
210
public int indexOf(TabData td);
213
* Add a data listener
215
* @param listener The listener
217
public void addComplexListDataListener(ComplexListDataListener listener);
220
* Remove a data listener
222
* @param listener The listener
224
public void removeComplexListDataListener(ComplexListDataListener listener);
227
//XXX remove this and handel the ComplexNNN events so nothing is repainted
228
//if not displayed on screen!
230
* The model will fire a change event whenever a modification occurs that
231
* could require a repaint. <strong>This method is only here for the
232
* prototype - eventually the UI delegate should listen for ComplexDataNN
233
* events and optimize repaints based on the actual areas affected.
235
public void addChangeListener(ChangeListener listener);
238
* The model will fire a change event whenever a modification occurs that
239
* could require a repaint. <strong>This method is only here for the
240
* prototype - eventually the UI delegate should listen for ComplexDataNN
241
* events and optimize repaints based on the actual areas affected.
243
public void removeChangeListener(ChangeListener listener);