KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ui > highlight > HighlightGroup


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xam.ui.highlight;
21
22 import java.util.HashSet JavaDoc;
23 import java.util.Set JavaDoc;
24
25 /**
26  * A collection of Highlight objects, which are shown or hidden as a group.
27  *
28  * @author Nathan Fiedler
29  */

30 public class HighlightGroup {
31     /** Type of highlight group for search results (includes parents). */
32     public static final String JavaDoc SEARCH = "search";
33     /** Set of Highlight instances. */
34     private Set JavaDoc<Highlight> highlights;
35     /** The type of this group. */
36     private String JavaDoc type;
37     /** True if this group is shown, false if hidden. */
38     private boolean showing;
39
40     /**
41      * Creates a new instance of HighlightGroup.
42      *
43      * @param type highlight group type.
44      */

45     public HighlightGroup(String JavaDoc type) {
46         assert type != null;
47         this.type = type;
48         highlights = new HashSet JavaDoc<Highlight>();
49     }
50
51     /**
52      * Add the given Highlight to this group.
53      *
54      * @param hl Highlight to be added.
55      */

56     public void addHighlight(Highlight hl) {
57         highlights.add(hl);
58     }
59
60     /**
61      * Return the group type.
62      *
63      * @return group type.
64      */

65     public String JavaDoc getType() {
66         return type;
67     }
68
69     /**
70      * Return true if group is showing, false otherwise.
71      *
72      * @return true if group is showing, false otherwise.
73      */

74     public boolean isShowing() {
75         return showing;
76     }
77
78     /**
79      * Return the set of highlights in this group.
80      *
81      * @return highlight set.
82      */

83     public Set JavaDoc<Highlight> highlights() {
84         return highlights;
85     }
86
87     /**
88      * Set the showing property for tracking this group's visibility.
89      *
90      * @param showing true if showing, false if hidden.
91      */

92     public void setShowing(boolean showing) {
93         this.showing = showing;
94     }
95 }
96
Popular Tags