diff --git a/java/com.sap.sailing.gwt.ui/GWT Sailing SDM.launch b/java/com.sap.sailing.gwt.ui/GWT Sailing SDM.launch index 9f7dfef387f..8166321d280 100644 --- a/java/com.sap.sailing.gwt.ui/GWT Sailing SDM.launch +++ b/java/com.sap.sailing.gwt.ui/GWT Sailing SDM.launch @@ -113,7 +113,7 @@ - + diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractLeaderboardConfigPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractLeaderboardConfigPanel.java index 1258335f9b7..8a1047d9d48 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractLeaderboardConfigPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractLeaderboardConfigPanel.java @@ -262,7 +262,7 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement private boolean hasLink(RaceColumnDTOAndFleetDTOWithNameBasedEquality selectedRaceColumnAndFleetName) { return selectedRaceColumnAndFleetName.getA() - .getRaceIdentifier(selectedRaceColumnAndFleetName.getB()) != null; + .getRaceIdentifier(selectedRaceColumnAndFleetName.getB()) != null; } private boolean isLinkedToRace(RaceColumnDTOAndFleetDTOWithNameBasedEquality selectedRaceColumnAndFleetName, RaceDTO selectedRace){ diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractTrackedRacesListComposite.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractTrackedRacesListComposite.java index aeea053980d..acf6c433c15 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractTrackedRacesListComposite.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/AbstractTrackedRacesListComposite.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Set; import com.google.gwt.cell.client.AbstractCell; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.Unit; @@ -18,6 +17,7 @@ import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import com.google.gwt.user.cellview.client.CellTable; import com.google.gwt.user.cellview.client.Column; import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; import com.google.gwt.user.cellview.client.TextColumn; @@ -40,8 +40,6 @@ import com.sap.sailing.gwt.ui.client.RegattaRefresher; import com.sap.sailing.gwt.ui.client.RegattasDisplayer; import com.sap.sailing.gwt.ui.client.SailingServiceAsync; import com.sap.sailing.gwt.ui.client.StringMessages; -import com.sap.sailing.gwt.ui.client.shared.controls.FlushableCellTable; -import com.sap.sailing.gwt.ui.client.shared.controls.SelectionCheckboxColumn; import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil; import com.sap.sailing.gwt.ui.shared.RegattaDTO; import com.sap.sse.common.Util; @@ -49,9 +47,7 @@ import com.sap.sse.common.filter.Filter; import com.sap.sse.common.util.NaturalComparator; import com.sap.sse.gwt.client.ErrorReporter; import com.sap.sse.gwt.client.async.MarkedAsyncCallback; -import com.sap.sse.gwt.client.celltable.EntityIdentityComparator; import com.sap.sse.gwt.client.celltable.RefreshableSelectionModel; -import com.sap.sse.gwt.client.celltable.RefreshableSingleSelectionModel; import com.sap.sse.gwt.client.panels.CustomizableFilterablePanel; import com.sap.sse.gwt.client.shared.components.AbstractCompositeComponent; import com.sap.sse.gwt.client.shared.components.Component; @@ -67,9 +63,7 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit protected RefreshableSelectionModel refreshableSelectionModel; - private SelectionCheckboxColumn selectionCheckboxColumn; - - protected FlushableCellTable raceTable; + protected CellTable raceTable; private ListDataProvider raceList; @@ -127,8 +121,6 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit } protected void createUI() { - AdminConsoleTableResources tableResources = GWT.create(AdminConsoleTableResources.class); - raceList = new ListDataProvider<>(); settings = new TrackedRacesSettings(); settings.setDelayToLiveInSeconds(DEFAULT_LIVE_DELAY_IN_MILLISECONDS / 1000l); VerticalPanel panel = new VerticalPanel(); @@ -139,8 +131,9 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit noTrackedRacesLabel = new Label(stringMessages.noRacesYet()); noTrackedRacesLabel.setWordWrap(false); panel.add(noTrackedRacesLabel); - AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class); - raceTable = new FlushableCellTable(/* pageSize */10000, tableRes); + TableWrapper> raceTableWrapper = new TrackedRacesTableWrapper(sailingService, stringMessages, errorReporter, multiSelection, /* enablePager */ true); + raceTable = raceTableWrapper.getTable(); + raceTable.setPageSize(1000); raceTable.ensureDebugId("TrackedRacesCellTable"); Label lblFilterRaces = new Label(stringMessages.filterRaces()+":"); @@ -149,7 +142,7 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit lblFilterRaces.getElement().getStyle().setMarginRight(10, Unit.PX); filterPanel.add(lblFilterRaces); filterPanel.setCellVerticalAlignment(lblFilterRaces, HasVerticalAlignment.ALIGN_MIDDLE); - + raceList = raceTableWrapper.getDataProvider(); filterablePanelRaces = new CustomizableFilterablePanel(allRaces, raceTable, raceList) { @Override public List getSearchableStrings(RaceDTO t) { @@ -160,6 +153,7 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit return strings; } }; + raceTableWrapper.registerSelectionModelOnNewDataProvider(filterablePanelRaces.getAllListDataProvider()); Label lblFilterByRegatta = new Label(stringMessages.filterByRegatta()); lblFilterByRegatta.setWordWrap(false); listBoxRegattas = new ListBox(); @@ -189,38 +183,13 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit filterPanel.add(filterablePanelRaces); filterPanel.setCellVerticalAlignment(filterablePanelRaces, HasVerticalAlignment.ALIGN_MIDDLE); - final EntityIdentityComparator entityIdentityComparator = new EntityIdentityComparator() { - @Override - public boolean representSameEntity(RaceDTO dto1, RaceDTO dto2) { - return dto1.getRaceIdentifier().equals(dto2.getRaceIdentifier()); - } - @Override - public int hashCode(RaceDTO t) { - return t.getRaceIdentifier().hashCode(); - } - }; - if (multiSelection) { - this.selectionCheckboxColumn = new SelectionCheckboxColumn( - tableResources.cellTableStyle().cellTableCheckboxSelected(), - tableResources.cellTableStyle().cellTableCheckboxDeselected(), - tableResources.cellTableStyle().cellTableCheckboxColumnCell(), entityIdentityComparator, - filterablePanelRaces.getAllListDataProvider(), raceTable); - refreshableSelectionModel = selectionCheckboxColumn.getSelectionModel(); - raceTable.setSelectionModel(refreshableSelectionModel, this.selectionCheckboxColumn.getSelectionManager()); - } else { - refreshableSelectionModel = new RefreshableSingleSelectionModel(entityIdentityComparator, - filterablePanelRaces.getAllListDataProvider()); - raceTable.setSelectionModel(refreshableSelectionModel); - } - - ListHandler columnSortHandler = setupTableColumns(stringMessages); + refreshableSelectionModel = raceTableWrapper.getSelectionModel(); + setupTableColumns(stringMessages, raceTableWrapper.getColumnSortHandler()); raceTable.setWidth("300px"); raceTable.setVisible(false); - panel.add(raceTable); - raceList.addDataDisplay(raceTable); - raceTable.addColumnSortHandler(columnSortHandler); - raceTable.getSelectionModel().addSelectionChangeHandler(new Handler() { + panel.add(raceTableWrapper); + refreshableSelectionModel.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { Set selectedRaces = refreshableSelectionModel.getSelectedSet(); @@ -250,8 +219,7 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit abstract protected void addControlButtons(HorizontalPanel trackedRacesButtonPanel); - private ListHandler setupTableColumns(final StringMessages stringMessages) { - ListHandler columnSortHandler = new ListHandler(raceList.getList()); + private void setupTableColumns(final StringMessages stringMessages, ListHandler columnSortHandler) { TextColumn regattaNameColumn = new TextColumn() { @Override public String getValue(RaceDTO raceDTO) { @@ -413,10 +381,6 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit return race.isTracked && race.trackedRace != null ? race.trackedRace.delayToLiveInMs : null; } }); - if (multiSelection) { - columnSortHandler.setComparator(selectionCheckboxColumn, selectionCheckboxColumn.getComparator()); - raceTable.addColumn(selectionCheckboxColumn, selectionCheckboxColumn.getHeader()); - } raceTable.addColumn(regattaNameColumn, stringMessages.regatta()); raceTable.addColumn(boatClassNameColumn, stringMessages.boatClass()); raceTable.addColumn(raceNameColumn, stringMessages.race()); @@ -425,8 +389,6 @@ public abstract class AbstractTrackedRacesListComposite extends AbstractComposit raceTable.addColumn(hasGPSDataColumn, stringMessages.gpsData()); raceTable.addColumn(raceStatusColumn, stringMessages.status()); raceTable.addColumn(raceLiveDelayColumn, stringMessages.delayInSeconds()); - - return columnSortHandler; } @Override diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesListComposite.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesListComposite.java index 998b6ef1333..70fd97b0bd2 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesListComposite.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesListComposite.java @@ -53,7 +53,6 @@ public class TrackedRacesListComposite extends AbstractTrackedRacesListComposite private void showSetDelayToLiveDialog() { TrackedRacesSettings settings = new TrackedRacesSettings(); settings.setDelayToLiveInSeconds(DEFAULT_LIVE_DELAY_IN_MILLISECONDS); - SettingsDialog settingsDialog = new SettingsDialog(this, stringMessages); settingsDialog.show(); } @@ -111,8 +110,6 @@ public class TrackedRacesListComposite extends AbstractTrackedRacesListComposite @Override protected void addControlButtons(HorizontalPanel trackedRacesButtonPanel) { if(actionButtonsEnabled) { - - btnUntrack = new Button(stringMessages.stopTracking()); btnUntrack.ensureDebugId("StopTrackingButton"); btnUntrack.addClickHandler(new ClickHandler() { diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesTableWrapper.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesTableWrapper.java new file mode 100755 index 00000000000..915c95b3076 --- /dev/null +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/adminconsole/TrackedRacesTableWrapper.java @@ -0,0 +1,25 @@ +package com.sap.sailing.gwt.ui.adminconsole; + +import com.sap.sailing.domain.common.dto.RaceDTO; +import com.sap.sailing.gwt.ui.client.SailingServiceAsync; +import com.sap.sailing.gwt.ui.client.StringMessages; +import com.sap.sse.gwt.client.ErrorReporter; +import com.sap.sse.gwt.client.celltable.EntityIdentityComparator; +import com.sap.sse.gwt.client.celltable.RefreshableSelectionModel; + +public class TrackedRacesTableWrapper extends TableWrapper> { + public TrackedRacesTableWrapper(SailingServiceAsync sailingService, StringMessages stringMessages, + ErrorReporter errorReporter, boolean multiSelection, boolean enablePager) { + super(sailingService, stringMessages, errorReporter, multiSelection, enablePager, new EntityIdentityComparator() { + @Override + public boolean representSameEntity(RaceDTO dto1, RaceDTO dto2) { + return dto1.getRaceIdentifier().equals(dto2.getRaceIdentifier()); + } + + @Override + public int hashCode(RaceDTO t) { + return t.getRaceIdentifier().hashCode(); + } + }); + } +} diff --git a/java/com.sap.sailing.selenium.test/com.sap.sailing.selenium.test (No Proxy).launch b/java/com.sap.sailing.selenium.test/com.sap.sailing.selenium.test (No Proxy).launch index 6281d67c66f..66a15e1ff1d 100644 --- a/java/com.sap.sailing.selenium.test/com.sap.sailing.selenium.test (No Proxy).launch +++ b/java/com.sap.sailing.selenium.test/com.sap.sailing.selenium.test (No Proxy).launch @@ -14,6 +14,13 @@ + + + + + + + diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java index 3724642ae5c..a92ff1e6eaa 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java @@ -369,12 +369,10 @@ public class SettingsTest extends AbstractSeleniumTest { } private void initTrackingForBmwCupRace(AdminConsolePage adminConsole) { - TrackableRaceDescriptor trackableRace = new TrackableRaceDescriptor(BMW_CUP_EVENT, String.format(BMW_RACE, 1), BMW_CUP_BOAT_CLASS); TrackedRaceDescriptor trackedRace = new TrackedRaceDescriptor(BMW_CUP_REGATTA, BMW_CUP_BOAT_CLASS, String.format(BMW_RACE, 1)); - TracTracEventManagementPanelPO tracTracEvents = adminConsole.goToTracTracEvents(); tracTracEvents.listTrackableRaces(BMW_CUP_JSON_URL); RegattaDescriptor bmwCupDescriptor = new RegattaDescriptor(BMW_CUP_EVENT, BMW_CUP_BOAT_CLASS); @@ -384,7 +382,6 @@ public class SettingsTest extends AbstractSeleniumTest { TrackedRacesListPO trackedRacesList = tracTracEvents.getTrackedRacesList(); trackedRacesList.waitForTrackedRace(trackedRace, Status.FINISHED, 600); // with the TracAPI, REPLAY races // status FINISHED when done loading - LeaderboardConfigurationPanelPO leaderboard = adminConsole.goToLeaderboardConfiguration(); LeaderboardDetailsPanelPO details = leaderboard.getLeaderboardDetails(BMW_CUP_REGATTA); Assert.assertTrue(details != null); @@ -499,7 +496,7 @@ public class SettingsTest extends AbstractSeleniumTest { } /** - * Verifies that the leaderboard displays the configurated details in the leaderboard table as columns. Furthermore, + * Verifies that the leaderboard displays the configured details in the leaderboard table as columns. Furthermore, * the chart presence is verified when the corresponding settings in admin console has been checked. In order to get * the race details displayed, a tracked race is used. */ diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/celltable/RefreshableSingleSelectionModel.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/celltable/RefreshableSingleSelectionModel.java index 5ff184ec44d..e8e856d6db4 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/celltable/RefreshableSingleSelectionModel.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/celltable/RefreshableSingleSelectionModel.java @@ -86,12 +86,13 @@ public class RefreshableSingleSelectionModel extends SingleSelectionModel } /** - * Refreshes the {@link RefreshableSingleSelectionModel} with the newObjects. If the current selected - * object {@link EntityIdentityComparator#representSameEntity(Object, Object) represent the same entity} as an - * object from newObjects it will be reselected. All others are de-selected. That means a selected - * object is not contained in newObjects the object wouldn't be selected anymore. If this selection - * model has no {@link EntityIdentityComparator} set, this method will use the {@link #equals(Object)} method to - * compare. If an object is reselected it will be replaced with the new version of it. + * Refreshes the {@link RefreshableSingleSelectionModel} with the newObjects. If the currently selected + * object {@link EntityIdentityComparator#representSameEntity(Object, Object) represents the same entity} as an + * object from newObjects it will be reselected. All others are de-selected. That means if a selected + * object is not contained (based on {@link EntityIdentityComparator#representSameEntity(Object, Object)}) in + * newObjects the object wouldn't be selected anymore. If this selection model has no + * {@link EntityIdentityComparator} set, this method will use the {@link #equals(Object)} method to compare. If an + * object is reselected it will be replaced with the new version of it. *

* * When the selection is refreshed this method triggers a diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/panels/AbstractFilterablePanel.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/panels/AbstractFilterablePanel.java index e2865578afa..b4e22c98d2f 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/panels/AbstractFilterablePanel.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/panels/AbstractFilterablePanel.java @@ -19,10 +19,7 @@ import com.sap.sse.common.Util; import com.sap.sse.common.filter.AbstractKeywordFilter; import com.sap.sse.common.filter.AbstractListFilter; import com.sap.sse.common.filter.Filter; -import com.sap.sse.gwt.client.celltable.EntityIdentityComparator; -import com.sap.sse.gwt.client.celltable.RefreshableMultiSelectionModel; import com.sap.sse.gwt.client.celltable.RefreshableSelectionModel; -import com.sap.sse.gwt.client.celltable.RefreshableSingleSelectionModel; /** * This Panel contains a text box. Text entered into the text box filters the {@link CellTable} passed to the @@ -37,7 +34,11 @@ import com.sap.sse.gwt.client.celltable.RefreshableSingleSelectionModel; * * Note that this panel does not contain the table that it filters. With this, this class's clients are free to * position the table wherever they want, not necessarily related to the text box provided by this panel in any specific - * way. + * way.

+ * + * It is recommended to use the {@link #getAllListDataProvider()} as the data provider for the table's selection model. + * This way, when the filter reduces the elements displayed in the table the selection will still refer to all elements + * and will not be modified solely by the act of filtering. * * @param * @author Nicolas Klose, Axel Uhl @@ -225,28 +226,6 @@ public abstract class AbstractFilterablePanel extends HorizontalPanel { return all.getList(); } - /** - * Registers a {@link RefreshableSelectionModel} on the all data structure. So the selection can be maintained when - * the {@link CellTable} is filtered. You can use the {@link RefreshableSelectionModel} returned by this method e.g. - * for a {@link CellTable} using {@link CellTable#setSelectionModel(com.google.gwt.view.client.SelectionModel)} - * - * @param comp - * {@link EntityIdentityComparator Comperator} to create the {@link RefreshableSelectionModel selection - * model} - * @param multiselection - * set true when the {@link RefreshableSelectionModel selection model} should be a - * {@link RefreshableMultiSelectionModel}. When it's set false the - * {@link RefreshableSelectionModel selection model} will be a {@link RefreshableSingleSelectionModel}. - */ - public RefreshableSelectionModel registerSelectionModelOnAllElements(EntityIdentityComparator comp, - boolean multiselection) { - if (multiselection) { - return new RefreshableMultiSelectionModel<>(comp, all); - } else { - return new RefreshableSingleSelectionModel<>(comp, all); - } - } - /** * You can use this method to get the {@link ListDataProvider} that represents the all data structure. On this * {@link ListDataProvider} a {@link RefreshableSelectionModel} can be registered. So the selection can also be