2525import com .sap .sse .gwt .adminconsole .AdminConsoleTableResources ;
2626import com .sap .sse .gwt .client .ErrorReporter ;
2727import com .sap .sse .gwt .client .celltable .AbstractSortableTextColumn ;
28- import com .sap .sse .gwt .client .celltable .BaseCelltable ;
2928import com .sap .sse .gwt .client .celltable .EntityIdentityComparator ;
29+ import com .sap .sse .gwt .client .celltable .FlushableCellTable ;
3030import com .sap .sse .gwt .client .celltable .RefreshableMultiSelectionModel ;
31+ import com .sap .sse .gwt .client .celltable .SelectionCheckboxColumn ;
3132import com .sap .sse .security .shared .HasPermissions ;
3233import com .sap .sse .security .shared .HasPermissions .DefaultActions ;
3334import com .sap .sse .security .shared .impl .SecuredSecurityTypes ;
3738import com .sap .sse .security .ui .client .component .EditOwnershipDialog ;
3839import com .sap .sse .security .ui .client .component .SecuredDTOOwnerColumn ;
3940import com .sap .sse .security .ui .client .component .editacl .EditACLDialog ;
40- import com .google .gwt .cell .client .CheckboxCell ;
41- import com .google .gwt .user .cellview .client .Column ;
4241import com .google .gwt .user .cellview .client .Header ;
4342
4443public class DeviceConfigurationListComposite extends Composite {
4544 protected static AdminConsoleTableResources tableResource = GWT .create (AdminConsoleTableResources .class );
4645
47- private final RefreshableMultiSelectionModel <DeviceConfigurationWithSecurityDTO > refreshableConfigurationSelectionModel ;
46+ private RefreshableMultiSelectionModel <DeviceConfigurationWithSecurityDTO > refreshableConfigurationSelectionModel ;
4847 private final CellTable <DeviceConfigurationWithSecurityDTO > configurationTable ;
4948 protected ListDataProvider <DeviceConfigurationWithSecurityDTO > configurationsDataProvider ;
5049
@@ -69,25 +68,11 @@ public DeviceConfigurationListComposite(SailingServiceWriteAsync sailingServiceW
6968 noConfigurationsLabel .setWordWrap (false );
7069 panel .add (noConfigurationsLabel );
7170 configurationsDataProvider = new ListDataProvider <DeviceConfigurationWithSecurityDTO >();
72- refreshableConfigurationSelectionModel = new RefreshableMultiSelectionModel <>(
73- new EntityIdentityComparator <DeviceConfigurationWithSecurityDTO >() {
74- @ Override
75- public boolean representSameEntity (DeviceConfigurationWithSecurityDTO dto1 ,
76- DeviceConfigurationWithSecurityDTO dto2 ) {
77- return Util .equalsWithNull (dto1 .id , dto2 .id );
78- }
79-
80- @ Override
81- public int hashCode (DeviceConfigurationWithSecurityDTO t ) {
82- return t .id == null ? 0 : t .id .hashCode ();
83- }
84- }, configurationsDataProvider );
8571 configurationTable = createConfigurationTable (userService );
8672 configurationTable .setVisible (true );
87- configurationTable . setSelectionModel ( refreshableConfigurationSelectionModel );
73+ refreshTable ( );
8874 panel .add (configurationTable );
8975 initWidget (mainPanel );
90- refreshTable ();
9176 }
9277
9378 public void refreshTable () {
@@ -120,40 +105,31 @@ public RefreshableMultiSelectionModel<DeviceConfigurationWithSecurityDTO> getSel
120105 }
121106
122107 private CellTable <DeviceConfigurationWithSecurityDTO > createConfigurationTable (final UserService userService ) {
123- CellTable <DeviceConfigurationWithSecurityDTO > table = new BaseCelltable <DeviceConfigurationWithSecurityDTO >(
124- /* pageSize */ 10000 , tableResource );
108+ final FlushableCellTable <DeviceConfigurationWithSecurityDTO > table = new FlushableCellTable <>(10000 , tableResource );
125109 configurationsDataProvider .addDataDisplay (table );
126110 table .ensureDebugId ("DeviceConfigurationList" );
127111 table .setWidth ("100%" );
128112 ListHandler <DeviceConfigurationWithSecurityDTO > columnSortHandler = new ListHandler <DeviceConfigurationWithSecurityDTO >(
129113 configurationsDataProvider .getList ());
130114 table .addColumnSortHandler (columnSortHandler );
131- CheckboxCell headerCheckboxCell = new CheckboxCell ();
132- Header <Boolean > selectAllHeader = new Header <Boolean >(headerCheckboxCell ) {
133- private boolean checked = false ;
134- @ Override
135- public Boolean getValue () {
136- return checked ;
137- }
138- };
139- selectAllHeader .setUpdater (value -> {
140- List <DeviceConfigurationWithSecurityDTO > visible = configurationsDataProvider .getList ();
141- for (DeviceConfigurationWithSecurityDTO cfg : visible ) {
142- refreshableConfigurationSelectionModel .setSelected (cfg , value );
143- }
144- value = !value ;
145- });
146- Column <DeviceConfigurationWithSecurityDTO , Boolean > selectionColumn =
147- new Column <DeviceConfigurationWithSecurityDTO , Boolean >(new CheckboxCell (true , false )) {
148- @ Override
149- public Boolean getValue (DeviceConfigurationWithSecurityDTO object ) {
150- return refreshableConfigurationSelectionModel .isSelected (object );
151- }
152- };
153- selectionColumn .setFieldUpdater ((index , object , value ) ->
154- refreshableConfigurationSelectionModel .setSelected (object , value ));
155- selectionColumn .setSortable (false );
156- table .addColumn (selectionColumn , selectAllHeader );
115+ final SelectionCheckboxColumn <DeviceConfigurationWithSecurityDTO > checkColumn = new SelectionCheckboxColumn <DeviceConfigurationWithSecurityDTO >(
116+ tableResource .cellTableStyle ().cellTableCheckboxSelected (),
117+ tableResource .cellTableStyle ().cellTableCheckboxDeselected (),
118+ tableResource .cellTableStyle ().cellTableCheckboxColumnCell (),
119+ new EntityIdentityComparator <DeviceConfigurationWithSecurityDTO >() {
120+ @ Override
121+ public boolean representSameEntity (DeviceConfigurationWithSecurityDTO a , DeviceConfigurationWithSecurityDTO b ) {
122+ return Util .equalsWithNull (a .id , b .id );
123+ }
124+ @ Override
125+ public int hashCode (DeviceConfigurationWithSecurityDTO t ) {
126+ return t .id == null ? 0 : t .id .hashCode ();
127+ }
128+ }, configurationsDataProvider , table );
129+ final Header <Boolean > selectAllHeader = checkColumn .createHeader ();
130+ table .addColumn (checkColumn , selectAllHeader );
131+ refreshableConfigurationSelectionModel = checkColumn .getSelectionModel ();
132+ table .setSelectionModel (refreshableConfigurationSelectionModel , checkColumn .getSelectionManager ());
157133 TextColumn <DeviceConfigurationWithSecurityDTO > identifierNameColumn = new TextColumn <DeviceConfigurationWithSecurityDTO >() {
158134 @ Override
159135 public String getValue (DeviceConfigurationWithSecurityDTO config ) {
0 commit comments