|
@@ -16,68 +16,78 @@ |
16 |
16 |
|
|
17 |
17 |
|
package com.google.gwt.gen2.table.event.client; |
18 |
18 |
|
|
19 |
|
- |
import com.google.gwt.gen2.event.logical.shared.SelectionEvent; |
20 |
|
- |
import com.google.gwt.gen2.table.event.client.TableEvent.Row; |
|
19 |
+ |
import java.util.*; |
21 |
20 |
|
|
22 |
|
- |
import java.util.Set; |
23 |
|
- |
import java.util.TreeSet; |
|
21 |
+ |
import com.google.gwt.gen2.event.logical.shared.*; |
|
22 |
+ |
import com.google.gwt.gen2.table.event.client.TableEvent.*; |
24 |
23 |
|
|
25 |
24 |
|
/** |
26 |
25 |
|
* Logical event fired when a cell is highlighted. |
27 |
26 |
|
*/ |
28 |
|
- |
public class RowSelectionEvent extends SelectionEvent<Set<Row>> { |
29 |
|
- |
/** |
30 |
|
- |
* Event Key for {@link RowSelectionEvent}. |
31 |
|
- |
*/ |
32 |
|
- |
public static final Type<RowSelectionEvent, RowSelectionHandler> TYPE = new Type<RowSelectionEvent, RowSelectionHandler>() { |
33 |
|
- |
@Override |
34 |
|
- |
protected void fire(RowSelectionHandler handler, RowSelectionEvent event) { |
35 |
|
- |
handler.onRowSelection(event); |
|
27 |
+ |
public class RowSelectionEvent extends SelectionEvent<Set<Row>> |
|
28 |
+ |
{ |
|
29 |
+ |
/** |
|
30 |
+ |
* Event Key for {@link RowSelectionEvent}. |
|
31 |
+ |
*/ |
|
32 |
+ |
public static final Type<RowSelectionEvent, RowSelectionHandler> TYPE = new Type<RowSelectionEvent, RowSelectionHandler>() |
|
33 |
+ |
{ |
|
34 |
+ |
@Override |
|
35 |
+ |
protected void fire( RowSelectionHandler handler, RowSelectionEvent event ) |
|
36 |
+ |
{ |
|
37 |
+ |
handler.onRowSelection( event ); |
|
38 |
+ |
} |
|
39 |
+ |
}; |
|
40 |
+ |
|
|
41 |
+ |
/** |
|
42 |
+ |
* Construct a new {@link RowSelectionEvent}. |
|
43 |
+ |
* |
|
44 |
+ |
* @param oldList the set of rows that were previously selected |
|
45 |
+ |
* @param newList the set of rows that are now selected |
|
46 |
+ |
*/ |
|
47 |
+ |
public RowSelectionEvent( Set<Row> oldList, Set<Row> newList ) |
|
48 |
+ |
{ |
|
49 |
+ |
super( oldList, newList ); |
36 |
50 |
|
} |
37 |
|
- |
}; |
38 |
51 |
|
|
39 |
|
- |
/** |
40 |
|
- |
* Construct a new {@link RowSelectionEvent}. |
41 |
|
- |
* |
42 |
|
- |
* @param oldList the set of rows that were previously selected |
43 |
|
- |
* @param newList the set of rows that are now selected |
44 |
|
- |
*/ |
45 |
|
- |
public RowSelectionEvent(Set<Row> oldList, Set<Row> newList) { |
46 |
|
- |
super(oldList, newList); |
47 |
|
- |
} |
48 |
|
- |
|
49 |
|
- |
/** |
50 |
|
- |
* @return the newly deselected rows |
51 |
|
- |
*/ |
52 |
|
- |
public Set<Row> getDeselectedRows() { |
53 |
|
- |
Set<Row> deselected = new TreeSet<Row>(); |
54 |
|
- |
Set<Row> oldList = getOldValue(); |
55 |
|
- |
Set<Row> newList = getNewValue(); |
56 |
|
- |
for (Row row : oldList) { |
57 |
|
- |
if (!newList.contains(row)) { |
58 |
|
- |
deselected.add(row); |
59 |
|
- |
} |
|
52 |
+ |
/** |
|
53 |
+ |
* @return the newly deselected rows |
|
54 |
+ |
*/ |
|
55 |
+ |
public Set<Row> getDeselectedRows() |
|
56 |
+ |
{ |
|
57 |
+ |
Set<Row> deselected = new TreeSet<Row>(); |
|
58 |
+ |
Set<Row> oldList = getOldValue(); |
|
59 |
+ |
Set<Row> newList = getNewValue(); |
|
60 |
+ |
for ( Row row : oldList ) |
|
61 |
+ |
{ |
|
62 |
+ |
if ( !newList.contains( row ) ) |
|
63 |
+ |
{ |
|
64 |
+ |
deselected.add( row ); |
|
65 |
+ |
} |
|
66 |
+ |
} |
|
67 |
+ |
return deselected; |
60 |
68 |
|
} |
61 |
|
- |
return deselected; |
62 |
|
- |
} |
63 |
69 |
|
|
64 |
|
- |
/** |
65 |
|
- |
* @return the newly selected rows |
66 |
|
- |
*/ |
67 |
|
- |
public Set<Row> getSelectedRows() { |
68 |
|
- |
Set<Row> selected = new TreeSet<Row>(); |
69 |
|
- |
Set<Row> oldList = getOldValue(); |
70 |
|
- |
Set<Row> newList = getNewValue(); |
71 |
|
- |
for (Row row : newList) { |
72 |
|
- |
if (!oldList.contains(row)) { |
73 |
|
- |
selected.add(row); |
74 |
|
- |
} |
|
70 |
+ |
/** |
|
71 |
+ |
* @return the newly selected rows |
|
72 |
+ |
*/ |
|
73 |
+ |
public Set<Row> getSelectedRows() |
|
74 |
+ |
{ |
|
75 |
+ |
Set<Row> selected = new TreeSet<Row>(); |
|
76 |
+ |
Set<Row> oldList = getOldValue(); |
|
77 |
+ |
Set<Row> newList = getNewValue(); |
|
78 |
+ |
for ( Row row : newList ) |
|
79 |
+ |
{ |
|
80 |
+ |
if ( !oldList.contains( row ) ) |
|
81 |
+ |
{ |
|
82 |
+ |
selected.add( row ); |
|
83 |
+ |
} |
|
84 |
+ |
} |
|
85 |
+ |
return selected; |
75 |
86 |
|
} |
76 |
|
- |
return selected; |
77 |
|
- |
} |
78 |
87 |
|
|
79 |
|
- |
@Override |
80 |
|
- |
protected Type getType() { |
81 |
|
- |
return TYPE; |
82 |
|
- |
} |
|
88 |
+ |
@Override |
|
89 |
+ |
protected Type getType() |
|
90 |
+ |
{ |
|
91 |
+ |
return TYPE; |
|
92 |
+ |
} |
83 |
93 |
|
} |