OSDN Git Service

Add notebook specific sorting and alter some NeverNote labels to say NixNote.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / DateAttributeFilterTable.java
1 /*\r
2  * This file is part of NixNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\r
8  * Software distributed under the License is distributed\r
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
10  * express or implied. See the GPL for the specific language\r
11  * governing rights and limitations.\r
12  *\r
13  * You should have received a copy of the GPL along with this\r
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
15  * or write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
17  *\r
18 */\r
19 \r
20 package cx.fbn.nevernote.gui;\r
21 \r
22 import java.util.ArrayList;\r
23 \r
24 import com.evernote.edam.type.Note;\r
25 \r
26 import cx.fbn.nevernote.filters.DateAttributeFilter;\r
27 import cx.fbn.nevernote.filters.DateAttributeFilterFactory;\r
28 \r
29 public class DateAttributeFilterTable {\r
30         ArrayList<DateAttributeFilter> table;\r
31         public DateAttributeFilterTable(boolean since, boolean created) {\r
32                 table = new ArrayList<DateAttributeFilter>();\r
33                 for (DateAttributeFilterFactory.FilterType type: DateAttributeFilterFactory.FilterType.values()) {\r
34                         table.add(DateAttributeFilterFactory.getFilter(type,since,created));\r
35                 }\r
36         }\r
37         \r
38         public void reset() {\r
39                 for (int i=0; i<table.size(); i++) \r
40                         table.get(i).set(false);\r
41         }\r
42         \r
43         public void select(int i) {\r
44                 table.get(i).set(true);\r
45         }\r
46         \r
47         public boolean hasSelection() {\r
48                 for (int i=0; i<table.size(); i++) {\r
49                         if (table.get(i).isSet())\r
50                                 return true;\r
51                 }\r
52                 return false;\r
53         }\r
54         \r
55         public int size() { \r
56                 return table.size();\r
57         }\r
58         \r
59         public boolean check(Note n) {\r
60                 for (int i=0; i<table.size(); i++) {\r
61                         if (table.get(i).isSet()\r
62                            && !table.get(i).attributeCheck(n))\r
63                                 return false;\r
64                 }\r
65                 return true;\r
66         }\r
67         \r
68         // Get the name of a particular attribute check\r
69         public String getLabel(int i) {\r
70                 return table.get(i).getLabel();\r
71         }\r
72 }\r