KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > docscan > SourceTasksFilter


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

35 final class SourceTasksFilter extends Filter {
36
37     // these are the properties (columns) the filter filters
38
SuggestionProperty [] PROPS = new SuggestionProperty[] {
39       SourceTaskProperties.PROP_TASK,
40       SourceTaskProperties.PROP_PRIORITY,
41       SourceTaskProperties.PROP_FILENAME};
42
43
44     /**
45      * Creates a new instance of UserTaskFilter
46      *
47      * @param name name of the filter
48      */

49     public SourceTasksFilter(String JavaDoc name) {
50         super(name);
51     }
52     
53     public SourceTasksFilter(final SourceTasksFilter rhs) {
54         super(rhs);
55         
56     }
57     
58     public Object JavaDoc clone() {
59         return new SourceTasksFilter(this);
60     }
61
62     /** for deconvertization **/
63     private SourceTasksFilter() {}
64
65
66     public SuggestionProperty[] getProperties() { return PROPS;}
67
68   // map from properties to conditions
69
public AppliedFilterCondition[] createConditions(SuggestionProperty property) {
70       if (property.equals(SourceTaskProperties.PROP_TASK)) {
71     return applyConditions(property, StringFilterCondition.createConditions());
72       }
73       else if (property.equals(SourceTaskProperties.PROP_PRIORITY)) {
74     return applyConditions(property, PriorityCondition.createConditions());
75       }
76       else if (property.equals(SourceTaskProperties.PROP_FILENAME)) {
77     return applyConditions(property, StringFilterCondition.createConditions());
78       } else
79     throw new IllegalArgumentException JavaDoc("Unknown property for SourceTasksFilter : " + property.getID());
80     }
81     
82
83   private static class Convertor extends FilterConvertor {
84
85     public Convertor() {
86       super("SourceTasksFilter");
87     }
88
89     public static SourceTasksFilter.Convertor create() { return new SourceTasksFilter.Convertor();}
90
91     protected Filter createFilter() { return new SourceTasksFilter();}
92
93     protected SuggestionProperty getProperty(String JavaDoc propid) {
94       SuggestionProperty sp = SourceTaskProperties.getProperty(propid);
95       if (sp == null)
96     return super.getProperty(propid);
97       else
98     return sp;
99     }
100     
101   }
102 }
103
Popular Tags