1 /*
2 * File: TimeBarSelectionModel.java
3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
4 * A commercial license is available, see http://www.jaret.de.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.jaret.util.ui.timebars.model;
21
22 import java.util.List;
23
24 import de.jaret.util.date.Interval;
25
26 /**
27 * Selection model for the TimeBarModel.
28 *
29 * @author Peter Kliem
30 * @version $Id: TimeBarSelectionModel.java 800 2008-12-27 22:27:33Z kliem $
31 */
32 public interface TimeBarSelectionModel {
33 /**
34 * Check whether the selection is completely empty.
35 *
36 * @return true id the selection is empty
37 */
38 boolean isEmpty();
39
40 /**
41 * Check whether there are selected rows.
42 *
43 * @return true if the selection contains rows
44 */
45 boolean hasRowSelection();
46
47 /**
48 * Check whether there are selected intervals.
49 *
50 * @return true if the selection contains intervals
51 */
52 boolean hasIntervalSelection();
53
54 /**
55 * Check whether there are selected relations.
56 *
57 * @return true if the selection contains relations
58 */
59 boolean hasRelationSelection();
60
61 /**
62 * Retrieves the list of currently selected rows.
63 *
64 * @return List containing the selected <code>TimeBarRows</code>
65 */
66 List<TimeBarRow> getSelectedRows();
67
68 /**
69 * Retrieves the list of currently selected intervals.
70 *
71 * @return List containing the selected <code>Intervals</code>
72 */
73 List<Interval> getSelectedIntervals();
74
75 /**
76 * Retrieves the list of currently selected relations.
77 *
78 * @return List containing the selected <code>IIntervalRelations</code>
79 */
80 List<IIntervalRelation> getSelectedRelations();
81
82 /**
83 * Enable/Disable row selection.
84 *
85 * @param allowed row selection allowed when set to true
86 */
87 void setRowSelectionAllowed(boolean allowed);
88
89 /**
90 * Check allowance of row selections.
91 *
92 * @return <code>true</code> if row selections are allowed
93 */
94 boolean isRowSelectionAllowed();
95
96 /**
97 * Enable/dible row selection toggle mode (click toggles selection without modifier keys).
98 *
99 * @param activated true for activated toggle mode
100 */
101 void setRowSelectionToggleMode(boolean activated);
102
103 /**
104 * Retrieve the row selection toggle mode.
105 *
106 * @return <code>true</code> for activated toggle mode
107 */
108 boolean getRowSelectionToggleMode();
109
110 /**
111 * Enable/disable interval selection.
112 *
113 * @param allowed interval selection allowed when set to true
114 */
115 void setIntervalSelectionAllowed(boolean allowed);
116
117 /**
118 * Check allowance of interval selections.
119 *
120 * @return <code>true</code> if interval selections are allowed
121 */
122 boolean isIntervalSelectionAllowed();
123
124 /**
125 * Enable/Disable relation selection.
126 *
127 * @param allowed relation selection allowed when set to true
128 */
129 void setRelationSelectionAllowed(boolean allowed);
130
131 /**
132 * Check allowance of relation selections.
133 *
134 * @return <code>true</code> if relation selections are allowed
135 */
136 boolean isRelationSelectionAllowed();
137
138 /**
139 * If multiple selction is not allowed only one row and one interval may be selected at one time.
140 *
141 * @param allowed true to signal multiple selections are allowed
142 */
143 void setMultipleSelectionAllowed(boolean allowed);
144
145 /**
146 * Retrieves the multiple selection allowance.
147 *
148 * @return true if multiple selections are allowed
149 */
150 boolean getMultipleSelectionAllowed();
151
152 /**
153 * Clears all selections.
154 *
155 */
156 void clearSelection();
157
158 /**
159 * Clears the selected intervals.
160 *
161 */
162 void clearIntervalSelection();
163
164 /**
165 * Clears the selected rows.
166 *
167 */
168 void clearRowSelection();
169
170 /**
171 * Clears the selected relations.
172 *
173 */
174 void clearRelationSelection();
175
176 /**
177 * Set the row selection to a given row.
178 *
179 * @param row row to be selected
180 */
181 void setSelectedRow(TimeBarRow row);
182
183 /**
184 * Add a row to the collection of selected rows.
185 *
186 * @param row row to be selected
187 */
188 void addSelectedRow(TimeBarRow row);
189
190 /**
191 * Remove a row from the collection of selected rows.
192 *
193 * @param row row to be removed from the selection
194 */
195 void remSelectedRow(TimeBarRow row);
196
197 /**
198 * Check whether a given row is selected.
199 *
200 * @param row row to check
201 * @return true if the given row is selected
202 */
203 boolean isSelected(TimeBarRow row);
204
205 /**
206 * Set the interval as the oly selected interval.
207 *
208 * @param interval interval that will be the only selected interval
209 */
210 void setSelectedInterval(Interval interval);
211
212 /**
213 * Add an interval to the selection.
214 *
215 * @param interval interval to be added to the selection
216 */
217 void addSelectedInterval(Interval interval);
218
219 /**
220 * Remove an interval from the selection.
221 *
222 * @param interval interval to remove from the selection
223 */
224 void remSelectedInterval(Interval interval);
225
226 /**
227 * Remove a list of intervals from the seletion.
228 *
229 * @param intervals list of intervals to remove from the selection
230 */
231 void remSelectedIntervals(List<Interval> intervals);
232
233 /**
234 * Check whether an interval is in the selection.
235 *
236 * @param interval interval to check
237 * @return true if the interval in qustion is in the selection
238 */
239 boolean isSelected(Interval interval);
240
241 /**
242 * Set the relation as the oly selected relation.
243 *
244 * @param relation relation that will be the only selected relation
245 */
246 void setSelectedRelation(IIntervalRelation relation);
247
248 /**
249 * Add an relation to the selection.
250 *
251 * @param relation relation to be added to the selection
252 */
253 void addSelectedRelation(IIntervalRelation relation);
254
255 /**
256 * Remove an relation from the selection.
257 *
258 * @param relation relation to remove from the selection
259 */
260 void remSelectedRelation(IIntervalRelation relation);
261
262 /**
263 * Remove a list of relations from the seletion.
264 *
265 * @param relations list of relations to remove from the selection
266 */
267 void remSelectedRelations(List<IIntervalRelation> relations);
268
269 /**
270 * Check whether an inetrval is in the selection.
271 *
272 * @param relation relation to check
273 * @return true if the relation in question is in the selection
274 */
275 boolean isSelected(IIntervalRelation relation);
276
277 /**
278 * Add a <code>TimeBarSelectionListener</code> to be informed if the selection is altered.
279 *
280 * @param tbsl the Listener to be added
281 */
282 void addTimeBarSelectionListener(TimeBarSelectionListener tbsl);
283
284 /**
285 * Remove a registered Listener.
286 *
287 * @param tbsl the listener to be deregistered
288 */
289 void remTimeBarSelectionListener(TimeBarSelectionListener tbsl);
290 }