~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/javahelp/jhMaster/JavaHelp/src/new/javax/help/TreeItem.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * @(#)TreeItem.java    1.28 06/10/30
 
3
 * 
 
4
 * Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
 
5
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
6
 * 
 
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.
 
12
 * 
 
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).
 
18
 * 
 
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.
 
22
 * 
 
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
 
25
 * have any questions.
 
26
 */
 
27
 
 
28
package javax.help;
 
29
 
 
30
import javax.help.Map.ID;
 
31
import java.util.Locale;
 
32
import java.net.URL;
 
33
import java.io.Serializable;
 
34
import java.io.IOException;
 
35
 
 
36
/**
 
37
 * The base items known to TOC, Index and Favorites Navigators.
 
38
 *
 
39
 * @author Roger D. Brinkley
 
40
 * @author Eduardo Pelegri-Llopart
 
41
 * @author Richard Gregor
 
42
 * @version   1.28     10/30/06
 
43
 */
 
44
 
 
45
public class TreeItem implements Serializable
 
46
{
 
47
 
 
48
    /**
 
49
     * A state of expansion determined by the view
 
50
     */
 
51
    public static final int DEFAULT_EXPANSION = -1;
 
52
 
 
53
    /**
 
54
     * Show the children of the node collapsed in the view
 
55
     */
 
56
    public static final int COLLAPSE = 0;
 
57
 
 
58
    /**
 
59
     * Show the children of the node expanded in the view
 
60
     */
 
61
    public static final int EXPAND = 1;
 
62
 
 
63
    private String name;
 
64
    private ID id;
 
65
    protected Locale locale;
 
66
    private String mergeType;
 
67
    private int expand = DEFAULT_EXPANSION;
 
68
    private String presentation;
 
69
    private String presentationName;
 
70
    private HelpSet hs;
 
71
 
 
72
     /**
 
73
     * Create an TreeItem.
 
74
     *
 
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
 
78
     */
 
79
    public TreeItem(ID id, HelpSet hs, Locale locale) {
 
80
        this.id = id;
 
81
        this.hs = hs;
 
82
        this.locale = locale;
 
83
    }
 
84
 
 
85
   /**
 
86
     * Creates a TreeItem.
 
87
     *
 
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
 
90
     * locale.
 
91
     */
 
92
    public TreeItem(ID id, Locale locale){
 
93
        this (id, null, locale);
 
94
    }
 
95
    /**
 
96
     * Creates a TreeItem.
 
97
     *
 
98
     * @param name The name for the item.
 
99
     */
 
100
    public TreeItem(String name){
 
101
        this(null,null, null);
 
102
        setName(name);
 
103
    }
 
104
    
 
105
    /**
 
106
     * Creates an empty TreeItem.
 
107
     */
 
108
    public TreeItem(){
 
109
        this(null,null);        
 
110
    }
 
111
    /**
 
112
     * Sets the name of the item.
 
113
     */
 
114
    public void setName(String name) {
 
115
        this.name = name;
 
116
    }
 
117
 
 
118
    /**
 
119
     * Returns the name of the item.
 
120
     */
 
121
    public String getName() {
 
122
        return name;
 
123
    }
 
124
    
 
125
    /**
 
126
     * Set the ID for the item.
 
127
     */
 
128
    public void setID (ID id) {
 
129
        this.id = id;
 
130
    }
 
131
 
 
132
    /**
 
133
     * Returns the ID for the item.
 
134
     */
 
135
    public ID getID() {
 
136
        return id;
 
137
    }
 
138
 
 
139
    /**
 
140
     * Returns the URL for the item.
 
141
     */
 
142
    public URL getURL() {
 
143
        try {
 
144
            return id.getURL();
 
145
        } catch (Exception e) {
 
146
            return null;
 
147
        }
 
148
    }
 
149
 
 
150
    /**
 
151
     * Set the HelpSet for this TreeItem.
 
152
     */
 
153
    public void setHelpSet(HelpSet hs) {
 
154
        this.hs = hs;
 
155
    }
 
156
 
 
157
    /**
 
158
     * Returns the HelpSet scoping this IndexItem. Will return the ID HelpSet
 
159
     * if one exists. Null otherwise
 
160
     */
 
161
    public HelpSet getHelpSet() {
 
162
        return hs;
 
163
    }
 
164
    
 
165
    /**
 
166
     * Returns the locale for the item.
 
167
     */
 
168
    public Locale getLocale() {
 
169
        return locale;
 
170
    }
 
171
    
 
172
    /**
 
173
     * Sets the merge type
 
174
     */
 
175
    public void setMergeType(String mergeType){
 
176
        this.mergeType = mergeType;
 
177
    }
 
178
    
 
179
    /**
 
180
     * Returns the merge type for the item
 
181
     */
 
182
    public String getMergeType(){
 
183
        return mergeType;
 
184
    }
 
185
 
 
186
    /**
 
187
     * Sets the expansion type
 
188
     * @throws IllegalArgumentException if not a valid type
 
189
     */
 
190
    public void setExpansionType(int type) {
 
191
        if (type < DEFAULT_EXPANSION || type > EXPAND) {
 
192
            throw new IllegalArgumentException("Invalid expansion type");
 
193
        }
 
194
        expand = type;
 
195
    }
 
196
 
 
197
    /**
 
198
     * Returns the exansion type
 
199
     */
 
200
    public int getExpansionType() {
 
201
        return expand;
 
202
    }
 
203
 
 
204
    /**
 
205
     * Sets the presentation
 
206
     * @see Presentation
 
207
     */
 
208
    public void setPresentation(String presentation) {
 
209
        this.presentation = presentation;
 
210
    }
 
211
 
 
212
    /**
 
213
     * Returns the presentation
 
214
     * @see Presentation
 
215
     */
 
216
    public String getPresentation() {
 
217
        return presentation;
 
218
    }
 
219
 
 
220
    /**
 
221
     * Sets the presentation name
 
222
     * @see Presentation
 
223
     */
 
224
    public void setPresentationName(String presentationName) {
 
225
        this.presentationName = presentationName;
 
226
    }
 
227
 
 
228
    /**
 
229
     * Returns the presentation name
 
230
     * @see Presentation
 
231
     */
 
232
    public String getPresentationName() {
 
233
        return presentationName;
 
234
    }
 
235
 
 
236
    /**
 
237
     * Returns a String used when displaying the object.
 
238
     * Used by CellRenderers.
 
239
     *
 
240
     * @see TOCCellRenderer
 
241
     */
 
242
    public String toString() {
 
243
        return (id+"("+name+")");
 
244
    }
 
245
 
 
246
    // for serialization
 
247
     private void writeObject(java.io.ObjectOutputStream out) throws IOException {
 
248
         //ignore so that FavoritesItem will work
 
249
     }
 
250
     
 
251
     private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
 
252
         //ignore so that FavoritesItem will work
 
253
     }
 
254
 
 
255
 
 
256
}
 
257