2
* @(#)TreeItem.java 1.28 06/10/30
4
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7
* This code is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 2 only, as
9
* published by the Free Software Foundation. Sun designates this
10
* particular file as subject to the "Classpath" exception as provided
11
* by Sun in the LICENSE file that accompanied this code.
13
* This code is distributed in the hope that it will be useful, but WITHOUT
14
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
* version 2 for more details (a copy is included in the LICENSE file that
17
* accompanied this code).
19
* You should have received a copy of the GNU General Public License version
20
* 2 along with this work; if not, write to the Free Software Foundation,
21
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24
* CA 95054 USA or visit www.sun.com if you need additional information or
30
import javax.help.Map.ID;
31
import java.util.Locale;
33
import java.io.Serializable;
34
import java.io.IOException;
37
* The base items known to TOC, Index and Favorites Navigators.
39
* @author Roger D. Brinkley
40
* @author Eduardo Pelegri-Llopart
41
* @author Richard Gregor
42
* @version 1.28 10/30/06
45
public class TreeItem implements Serializable
49
* A state of expansion determined by the view
51
public static final int DEFAULT_EXPANSION = -1;
54
* Show the children of the node collapsed in the view
56
public static final int COLLAPSE = 0;
59
* Show the children of the node expanded in the view
61
public static final int EXPAND = 1;
65
protected Locale locale;
66
private String mergeType;
67
private int expand = DEFAULT_EXPANSION;
68
private String presentation;
69
private String presentationName;
75
* @param id ID for the item. The ID can be null.
76
* @param hs A HelpSet scoping this item.
77
* @param locale The locale for this item
79
public TreeItem(ID id, HelpSet hs, Locale locale) {
88
* @param id ID for the item. Null is a valid ID.
89
* @param The lang for this item. A null is valid and indicates the default
92
public TreeItem(ID id, Locale locale){
93
this (id, null, locale);
98
* @param name The name for the item.
100
public TreeItem(String name){
101
this(null,null, null);
106
* Creates an empty TreeItem.
112
* Sets the name of the item.
114
public void setName(String name) {
119
* Returns the name of the item.
121
public String getName() {
126
* Set the ID for the item.
128
public void setID (ID id) {
133
* Returns the ID for the item.
140
* Returns the URL for the item.
142
public URL getURL() {
145
} catch (Exception e) {
151
* Set the HelpSet for this TreeItem.
153
public void setHelpSet(HelpSet hs) {
158
* Returns the HelpSet scoping this IndexItem. Will return the ID HelpSet
159
* if one exists. Null otherwise
161
public HelpSet getHelpSet() {
166
* Returns the locale for the item.
168
public Locale getLocale() {
173
* Sets the merge type
175
public void setMergeType(String mergeType){
176
this.mergeType = mergeType;
180
* Returns the merge type for the item
182
public String getMergeType(){
187
* Sets the expansion type
188
* @throws IllegalArgumentException if not a valid type
190
public void setExpansionType(int type) {
191
if (type < DEFAULT_EXPANSION || type > EXPAND) {
192
throw new IllegalArgumentException("Invalid expansion type");
198
* Returns the exansion type
200
public int getExpansionType() {
205
* Sets the presentation
208
public void setPresentation(String presentation) {
209
this.presentation = presentation;
213
* Returns the presentation
216
public String getPresentation() {
221
* Sets the presentation name
224
public void setPresentationName(String presentationName) {
225
this.presentationName = presentationName;
229
* Returns the presentation name
232
public String getPresentationName() {
233
return presentationName;
237
* Returns a String used when displaying the object.
238
* Used by CellRenderers.
240
* @see TOCCellRenderer
242
public String toString() {
243
return (id+"("+name+")");
247
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
248
//ignore so that FavoritesItem will work
251
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
252
//ignore so that FavoritesItem will work