|
@@ -1,119 +1,119 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets.datatables; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.event.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
6 |
|
- |
import org.litesoft.core.util.*; |
7 |
|
- |
|
8 |
|
- |
import com.google.gwt.event.logical.shared.*; |
9 |
|
- |
import com.google.gwt.event.shared.*; |
10 |
|
- |
import com.google.gwt.gen2.table.client.*; |
11 |
|
- |
import com.google.gwt.user.client.*; |
12 |
|
- |
import com.google.gwt.user.client.ui.*; |
13 |
|
- |
|
14 |
|
- |
import java.util.*; |
15 |
|
- |
|
16 |
|
- |
/** |
17 |
|
- |
* TODO: size |
18 |
|
- |
* TODO: min height? |
19 |
|
- |
*/ |
20 |
|
- |
public class RegularTable<T> extends SizeableSimplePanel implements HasSelectionHandlers<T>, |
21 |
|
- |
TableDataReloadable { |
22 |
|
- |
protected final Table<T> mTable; |
23 |
|
- |
|
24 |
|
- |
/** |
25 |
|
- |
* @param pModel the data source |
26 |
|
- |
* @param pDefinition the column definition |
27 |
|
- |
*/ |
28 |
|
- |
public RegularTable( ListTableModel<T> pModel, TableDefinitionPlus<T> pDefinition ) { |
29 |
|
- |
this( pModel, pDefinition, null ); |
30 |
|
- |
} |
31 |
|
- |
|
32 |
|
- |
/** |
33 |
|
- |
* @param pModel the data source |
34 |
|
- |
* @param pDefinition the column definition |
35 |
|
- |
* @param pRowClickCommand {@link Command} to execute upon clicking a row, or <code>null</code> |
36 |
|
- |
*/ |
37 |
|
- |
public RegularTable( ListTableModel<T> pModel, TableDefinitionPlus<T> pDefinition, TableClickCommand<T> pRowClickCommand ) { |
38 |
|
- |
mTable = new Table<T>( pModel, pDefinition, pRowClickCommand ); |
39 |
|
- |
mTable.setWidth( "100%" ); |
40 |
|
- |
mTable.setHeight( "100%" ); |
41 |
|
- |
setWidget( mTable ); |
42 |
|
- |
stretchable(); |
43 |
|
- |
mTable.addSelectionHandler( new SelectionDelegator<T>( this ) ); |
44 |
|
- |
} |
45 |
|
- |
|
46 |
|
- |
protected TableModel<T> getModel() { |
47 |
|
- |
return mTable.getModel(); |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
public ImmutableArrayList<T> getAllRows() { |
51 |
|
- |
return mTable.getAllRows(); |
52 |
|
- |
} |
53 |
|
- |
|
54 |
|
- |
public RowSelectionPolicy getSelectionPolicy() { |
55 |
|
- |
return mTable.getSelectionPolicy(); |
56 |
|
- |
} |
57 |
|
- |
|
58 |
|
- |
public void setSelectionPolicy( RowSelectionPolicy pSelectionPolicy ) { |
59 |
|
- |
mTable.setSelectionPolicy( pSelectionPolicy ); |
60 |
|
- |
} |
61 |
|
- |
|
62 |
|
- |
public void deselectAll() { |
63 |
|
- |
mTable.deselectAll(); |
64 |
|
- |
} |
65 |
|
- |
|
66 |
|
- |
public void selectAll() { |
67 |
|
- |
mTable.selectAll(); |
68 |
|
- |
} |
69 |
|
- |
|
70 |
|
- |
public boolean selectRow( T pPossibleRowValue ) { |
71 |
|
- |
return mTable.selectRow( pPossibleRowValue ); |
72 |
|
- |
} |
73 |
|
- |
|
74 |
|
- |
public Set<T> getSelectedValues() { |
75 |
|
- |
return mTable.getSelectedValues(); |
76 |
|
- |
} |
77 |
|
- |
|
78 |
|
- |
@Override |
79 |
|
- |
public HandlerRegistration addSelectionHandler( SelectionHandler<T> pHandler ) { |
80 |
|
- |
return addHandler( pHandler, SelectionEvent.getType() ); |
81 |
|
- |
} |
82 |
|
- |
|
83 |
|
- |
public boolean isScrollVertically() { |
84 |
|
- |
return mTable.isScrollVertically(); |
85 |
|
- |
} |
86 |
|
- |
|
87 |
|
- |
public void setScrollVertically( boolean pScrollVertically ) { |
88 |
|
- |
mTable.setScrollVertically( pScrollVertically ); |
89 |
|
- |
} |
90 |
|
- |
|
91 |
|
- |
public TableRowCountCallback getRowCountCallback() { |
92 |
|
- |
return mTable.getRowCountCallback(); |
93 |
|
- |
} |
94 |
|
- |
|
95 |
|
- |
public void setRowCountCallback( TableRowCountCallback pRowCountCallback ) { |
96 |
|
- |
mTable.setRowCountCallback( pRowCountCallback ); |
97 |
|
- |
} |
98 |
|
- |
|
99 |
|
- |
public boolean isHeaderVisible() { |
100 |
|
- |
return mTable.isHeaderVisible(); |
101 |
|
- |
} |
102 |
|
- |
|
103 |
|
- |
public void setHeaderVisible( boolean pVisible ) { |
104 |
|
- |
mTable.setHeaderVisible( pVisible ); |
105 |
|
- |
} |
106 |
|
- |
|
107 |
|
- |
public Widget getEmptyTableWidget() { |
108 |
|
- |
return mTable.getEmptyTableWidget(); |
109 |
|
- |
} |
110 |
|
- |
|
111 |
|
- |
public void setEmptyTableWidget( Widget pEmptyTableWidget ) { |
112 |
|
- |
mTable.setEmptyTableWidget( pEmptyTableWidget ); |
113 |
|
- |
} |
114 |
|
- |
|
115 |
|
- |
@Override |
116 |
|
- |
public void loadData() { |
117 |
|
- |
mTable.loadData(); |
118 |
|
- |
} |
119 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.datatables; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.event.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
6 |
+ |
import org.litesoft.core.util.*; |
|
7 |
+ |
|
|
8 |
+ |
import com.google.gwt.event.logical.shared.*; |
|
9 |
+ |
import com.google.gwt.event.shared.*; |
|
10 |
+ |
import com.google.gwt.gen2.table.client.*; |
|
11 |
+ |
import com.google.gwt.user.client.*; |
|
12 |
+ |
import com.google.gwt.user.client.ui.*; |
|
13 |
+ |
|
|
14 |
+ |
import java.util.*; |
|
15 |
+ |
|
|
16 |
+ |
/** |
|
17 |
+ |
* TODO: size |
|
18 |
+ |
* TODO: min height? |
|
19 |
+ |
*/ |
|
20 |
+ |
public class RegularTable<T> extends SizeableSimplePanel implements HasSelectionHandlers<T>, |
|
21 |
+ |
TableDataReloadable { |
|
22 |
+ |
protected final Table<T> mTable; |
|
23 |
+ |
|
|
24 |
+ |
/** |
|
25 |
+ |
* @param pModel the data source |
|
26 |
+ |
* @param pDefinition the column definition |
|
27 |
+ |
*/ |
|
28 |
+ |
public RegularTable( ListTableModel<T> pModel, TableDefinitionPlus<T> pDefinition ) { |
|
29 |
+ |
this( pModel, pDefinition, null ); |
|
30 |
+ |
} |
|
31 |
+ |
|
|
32 |
+ |
/** |
|
33 |
+ |
* @param pModel the data source |
|
34 |
+ |
* @param pDefinition the column definition |
|
35 |
+ |
* @param pRowClickCommand {@link Command} to execute upon clicking a row, or <code>null</code> |
|
36 |
+ |
*/ |
|
37 |
+ |
public RegularTable( ListTableModel<T> pModel, TableDefinitionPlus<T> pDefinition, TableClickCommand<T> pRowClickCommand ) { |
|
38 |
+ |
mTable = new Table<T>( pModel, pDefinition, pRowClickCommand ); |
|
39 |
+ |
mTable.setWidth( "100%" ); |
|
40 |
+ |
mTable.setHeight( "100%" ); |
|
41 |
+ |
setWidget( mTable ); |
|
42 |
+ |
stretchable(); |
|
43 |
+ |
mTable.addSelectionHandler( new SelectionDelegator<T>( this ) ); |
|
44 |
+ |
} |
|
45 |
+ |
|
|
46 |
+ |
protected TableModel<T> getModel() { |
|
47 |
+ |
return mTable.getModel(); |
|
48 |
+ |
} |
|
49 |
+ |
|
|
50 |
+ |
public ImmutableArrayList<T> getAllRows() { |
|
51 |
+ |
return mTable.getAllRows(); |
|
52 |
+ |
} |
|
53 |
+ |
|
|
54 |
+ |
public RowSelectionPolicy getSelectionPolicy() { |
|
55 |
+ |
return mTable.getSelectionPolicy(); |
|
56 |
+ |
} |
|
57 |
+ |
|
|
58 |
+ |
public void setSelectionPolicy( RowSelectionPolicy pSelectionPolicy ) { |
|
59 |
+ |
mTable.setSelectionPolicy( pSelectionPolicy ); |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
public void deselectAll() { |
|
63 |
+ |
mTable.deselectAll(); |
|
64 |
+ |
} |
|
65 |
+ |
|
|
66 |
+ |
public void selectAll() { |
|
67 |
+ |
mTable.selectAll(); |
|
68 |
+ |
} |
|
69 |
+ |
|
|
70 |
+ |
public boolean selectRow( T pPossibleRowValue ) { |
|
71 |
+ |
return mTable.selectRow( pPossibleRowValue ); |
|
72 |
+ |
} |
|
73 |
+ |
|
|
74 |
+ |
public Set<T> getSelectedValues() { |
|
75 |
+ |
return mTable.getSelectedValues(); |
|
76 |
+ |
} |
|
77 |
+ |
|
|
78 |
+ |
@Override |
|
79 |
+ |
public HandlerRegistration addSelectionHandler( SelectionHandler<T> pHandler ) { |
|
80 |
+ |
return addHandler( pHandler, SelectionEvent.getType() ); |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
public boolean isScrollVertically() { |
|
84 |
+ |
return mTable.isScrollVertically(); |
|
85 |
+ |
} |
|
86 |
+ |
|
|
87 |
+ |
public void setScrollVertically( boolean pScrollVertically ) { |
|
88 |
+ |
mTable.setScrollVertically( pScrollVertically ); |
|
89 |
+ |
} |
|
90 |
+ |
|
|
91 |
+ |
public TableRowCountCallback getRowCountCallback() { |
|
92 |
+ |
return mTable.getRowCountCallback(); |
|
93 |
+ |
} |
|
94 |
+ |
|
|
95 |
+ |
public void setRowCountCallback( TableRowCountCallback pRowCountCallback ) { |
|
96 |
+ |
mTable.setRowCountCallback( pRowCountCallback ); |
|
97 |
+ |
} |
|
98 |
+ |
|
|
99 |
+ |
public boolean isHeaderVisible() { |
|
100 |
+ |
return mTable.isHeaderVisible(); |
|
101 |
+ |
} |
|
102 |
+ |
|
|
103 |
+ |
public void setHeaderVisible( boolean pVisible ) { |
|
104 |
+ |
mTable.setHeaderVisible( pVisible ); |
|
105 |
+ |
} |
|
106 |
+ |
|
|
107 |
+ |
public Widget getEmptyTableWidget() { |
|
108 |
+ |
return mTable.getEmptyTableWidget(); |
|
109 |
+ |
} |
|
110 |
+ |
|
|
111 |
+ |
public void setEmptyTableWidget( Widget pEmptyTableWidget ) { |
|
112 |
+ |
mTable.setEmptyTableWidget( pEmptyTableWidget ); |
|
113 |
+ |
} |
|
114 |
+ |
|
|
115 |
+ |
@Override |
|
116 |
+ |
public void loadData() { |
|
117 |
+ |
mTable.loadData(); |
|
118 |
+ |
} |
|
119 |
+ |
} |