KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > riot > list > ui > ListItem


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.riot.list.ui;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.riotfamily.riot.list.command.CommandState;
30
31 /**
32  * @author Felix Gnass [fgnass at neteye dot de]
33  * @since 6.4
34  */

35 public class ListItem {
36
37     private int rowIndex;
38     
39     private String JavaDoc objectId;
40     
41     private String JavaDoc cssClass;
42     
43     private List JavaDoc columns;
44     
45     private List JavaDoc commands;
46
47     private String JavaDoc defaultCommandId;
48         
49     private boolean lastOnPage;
50     
51     public ListItem() {
52     }
53     
54     public ListItem(String JavaDoc objectId) {
55         this.objectId = objectId;
56     }
57
58     public List JavaDoc getColumns() {
59         return this.columns;
60     }
61
62     public void setColumns(List JavaDoc columns) {
63         this.columns = columns;
64     }
65
66     public String JavaDoc getCssClass() {
67         return this.cssClass;
68     }
69
70     public void setCssClass(String JavaDoc cssClass) {
71         this.cssClass = cssClass;
72     }
73
74     public List JavaDoc getCommands() {
75         return this.commands;
76     }
77
78     public void setCommands(List JavaDoc commands) {
79         this.commands = commands;
80     }
81
82     public String JavaDoc getObjectId() {
83         return this.objectId;
84     }
85
86     public void setObjectId(String JavaDoc objectId) {
87         this.objectId = objectId;
88     }
89
90     public int getRowIndex() {
91         return this.rowIndex;
92     }
93
94     public void setRowIndex(int rowIndex) {
95         this.rowIndex = rowIndex;
96     }
97
98     public boolean isLastOnPage() {
99         return this.lastOnPage;
100     }
101
102     public void setLastOnPage(boolean lastOnPage) {
103         this.lastOnPage = lastOnPage;
104     }
105
106     void setDefaultCommandIds(String JavaDoc[] defaultCommandIds) {
107         if (defaultCommandIds != null) {
108             for (int i = 0; i < defaultCommandIds.length; i++) {
109                 CommandState state = getCommandState(defaultCommandIds[i]);
110                 if (state != null && state.isEnabled()) {
111                     defaultCommandId = state.getId();
112                     break;
113                 }
114             }
115         }
116     }
117     
118     private CommandState getCommandState(String JavaDoc id) {
119         Iterator JavaDoc it = commands.iterator();
120         while (it.hasNext()) {
121             CommandState state = (CommandState) it.next();
122             if (state.getId().equals(id)) {
123                 return state;
124             }
125         }
126         return null;
127     }
128     
129     public void setDefaultCommandId(String JavaDoc defaultCommandId) {
130         this.defaultCommandId = defaultCommandId;
131     }
132     
133     public String JavaDoc getDefaultCommandId() {
134         return defaultCommandId;
135     }
136         
137 }
138
Popular Tags