KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > suggestions > SuggestionFilter


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.tasklist.suggestions;
21
22 import org.netbeans.modules.tasklist.core.filter.AppliedFilterCondition;
23 import org.netbeans.modules.tasklist.core.filter.Filter;
24 import org.netbeans.modules.tasklist.core.filter.IntegerFilterCondition;
25 import org.netbeans.modules.tasklist.core.filter.PriorityCondition;
26 import org.netbeans.modules.tasklist.core.filter.StringFilterCondition;
27 import org.netbeans.modules.tasklist.core.filter.FilterConvertor;
28 import org.netbeans.modules.tasklist.core.filter.SuggestionProperties;
29 import org.netbeans.modules.tasklist.core.filter.SuggestionProperty;
30
31 /**
32  * Filter for user tasks
33  * @author Tim Lebedkov
34  */

35 public class SuggestionFilter extends Filter {
36     private static final String JavaDoc[] PROP_KEYS = {
37         "SuggestionsRoot", // NOI18N
38
"Details", // NOI18N
39
"Priority", // NOI18N
40
"File", // NOI18N
41
"Line", // NOI18N
42
"Category", // NOI18N
43
};
44     
45   private static final SuggestionProperty[] PROPS = new SuggestionProperty[] {
46     SuggestionImplProperties.PROP_SUMMARY,
47     SuggestionImplProperties.PROP_DETAILS,
48     SuggestionImplProperties.PROP_PRIORITY,
49     SuggestionImplProperties.PROP_FILENAME,
50     SuggestionImplProperties.PROP_LINE_NUMBER,
51     SuggestionImplProperties.PROP_CATEGORY
52   };
53
54   
55     
56     
57     /**
58      * Creates a new instance of UserTaskFilter
59      *
60      * @param name name of the filter
61      */

62     public SuggestionFilter(String JavaDoc name) {
63         super(name);
64     }
65     
66     public SuggestionFilter(SuggestionFilter rhs) { super(rhs); }
67
68     private SuggestionFilter() { // for deconvertization reasons;
69
}
70
71     public Object JavaDoc clone() { return new SuggestionFilter(this);}
72
73     public SuggestionProperty[] getProperties() { return PROPS;}
74     
75
76     public AppliedFilterCondition[] createConditions(SuggestionProperty property) {
77       if (property.equals(SuggestionProperties.PROP_SUMMARY)) {
78     return applyConditions(property, StringFilterCondition.createConditions());
79       }
80       else if (property.equals(SuggestionImplProperties.PROP_DETAILS)) {
81     return applyConditions(property, StringFilterCondition.createConditions());
82       }
83       else if (property.equals(SuggestionImplProperties.PROP_PRIORITY)) {
84     return applyConditions(property, PriorityCondition.createConditions());
85       }
86       else if (property.equals(SuggestionImplProperties.PROP_FILENAME)) {
87     return applyConditions(property, StringFilterCondition.createConditions());
88       }
89       else if (property.equals(SuggestionImplProperties.PROP_LINE_NUMBER)) {
90     return applyConditions(property, IntegerFilterCondition.createConditions());
91       }
92       else if (property.equals(SuggestionImplProperties.PROP_CATEGORY)) {
93     return applyConditions(property, StringFilterCondition.createConditions());
94       }
95       else
96     throw new IllegalArgumentException JavaDoc("wrong property");
97
98     }
99
100   private static class Convertor extends FilterConvertor {
101
102     public Convertor() {
103       super("SuggestionFilter");
104     }
105
106     public static SuggestionFilter.Convertor create() { return new SuggestionFilter.Convertor();}
107
108     protected Filter createFilter() { return new SuggestionFilter();}
109
110     protected SuggestionProperty getProperty(String JavaDoc propid) {
111       SuggestionProperty sp = SuggestionImplProperties.getProperty(propid);
112       if (sp == null)
113     return super.getProperty(propid);
114       else
115     return sp;
116     }
117     
118   }
119
120
121 }
122
Popular Tags