OSDN Git Service

Remove some of the popup note edit options from the main menu. For some reason they...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / ContainsAttributeFilterTable.java
1 /*\r
2  * This file is part of NixNote \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.ContainsAttributeFilter;\r
28 import cx.fbn.nevernote.filters.ContainsAttributeFilterFactory;\r
29 import cx.fbn.nevernote.sql.NoteTable;\r
30 \r
31 public class ContainsAttributeFilterTable {\r
32         ArrayList<ContainsAttributeFilter> table;\r
33         \r
34     public ContainsAttributeFilterTable() {\r
35         table = new ArrayList<ContainsAttributeFilter>();\r
36         for (ContainsAttributeFilterFactory.Contains type: ContainsAttributeFilterFactory.Contains.values()) \r
37                 table.add(ContainsAttributeFilterFactory.create(type));\r
38         }\r
39         \r
40         public void reset() {\r
41                 for (int i=0; i<table.size(); i++) \r
42                         table.get(i).set(false);\r
43         }\r
44         \r
45         public void select(int i) {\r
46                 table.get(i).set(true);\r
47         }\r
48         \r
49         public int size() {\r
50                 return table.size();\r
51         }\r
52         \r
53         public boolean hasSelection() {\r
54                 for (int i=0; i<table.size(); i++) {\r
55                         if (table.get(i).isSet())\r
56                                 return true;\r
57                 }\r
58                 return false;\r
59         }\r
60         \r
61         public boolean check(NoteTable sqlTable, Note n) {\r
62                 for (int i=0; i<table.size(); i++) {\r
63                         if (table.get(i).isSet()) {\r
64                                 n = sqlTable.getNote(n.getGuid(), true, true, false, false, false);\r
65                                 if (!table.get(i).attributeCheck(n)) \r
66                                         return false;\r
67                         }\r
68                 }\r
69                 return true;\r
70         }\r
71         \r
72         // Get the label of a particular attribute check\r
73         public String getLabel(int i) {\r
74                 return table.get(i).getLabel();\r
75         }\r
76 }\r