KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > navigation > base > FiltersDescription


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.navigation.base;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import javax.swing.Icon JavaDoc;
25
26 /**
27  * @author Dafe Simonek
28  */

29 public final class FiltersDescription {
30
31     public static FiltersManager createManager (FiltersDescription descr) {
32         return FiltersManager.create(descr);
33     }
34
35     /** List of <FilterItem> describing filters properties */
36     private List JavaDoc<FilterItem> filters;
37
38     /** Creates a new instance of FiltersDescription */
39     public FiltersDescription() {
40         filters = new ArrayList JavaDoc<FilterItem>();
41     }
42     
43     public void addFilter (String JavaDoc name, String JavaDoc displayName, String JavaDoc tooltip,
44             boolean isSelected, Icon JavaDoc selectedIcon, Icon JavaDoc unselectedIcon) {
45         FilterItem newItem = new FilterItem(name, displayName, tooltip,
46                 isSelected, selectedIcon, unselectedIcon);
47         filters.add(newItem);
48     }
49     
50     public int getFilterCount () {
51         return filters.size();
52     }
53     
54     public String JavaDoc getName (int index) {
55         return filters.get(index).name;
56     }
57     
58     public String JavaDoc getDisplayName (int index) {
59         return filters.get(index).displayName;
60     }
61     
62     public String JavaDoc getTooltip (int index) {
63         return filters.get(index).tooltip;
64     }
65     
66     public Icon JavaDoc getSelectedIcon (int index) {
67         return filters.get(index).selectedIcon;
68     }
69     
70     public Icon JavaDoc getUnselectedIcon (int index) {
71         return filters.get(index).unselectedIcon;
72     }
73     
74     public boolean isSelected (int index) {
75         return filters.get(index).isSelected;
76     }
77     
78     static class FilterItem {
79         String JavaDoc name;
80         String JavaDoc displayName;
81         String JavaDoc tooltip;
82         Icon JavaDoc selectedIcon;
83         Icon JavaDoc unselectedIcon;
84         boolean isSelected;
85         
86         FilterItem (String JavaDoc name, String JavaDoc displayName, String JavaDoc tooltip,
87                 boolean isSelected, Icon JavaDoc selectedIcon, Icon JavaDoc unselectedIcon) {
88             this.name = name;
89             this.displayName = displayName;
90             this.tooltip = tooltip;
91             this.selectedIcon = selectedIcon;
92             this.unselectedIcon = unselectedIcon;
93             this.isSelected = isSelected;
94         }
95         
96     }
97     
98 }
99
Popular Tags