KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > 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.retouche.navigation.base;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import javax.swing.Icon JavaDoc;
25
26 /**
27  * This file is originally from Retouche, the Java Support
28  * infrastructure in NetBeans. I have modified the file as little
29  * as possible to make merging Retouche fixes back as simple as
30  * possible.
31  * <p>
32  *
33  * @author Dafe Simonek
34  */

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