OSDN Git Service

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