mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
RegattaOverview: Implemented "Deselect all"/"Select all" button for settings. Note that deselecting all checkboxes and clicking on OK means to show all courseareas or regattas
This commit is contained in:
1 parent
47572a98f1
commit
ecf739b8dd
4 files changed
+77
-4
No files matched your search
+2
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
|
||||
public interface StringMessages extends Messages {
|
||||
String helloWorld();
|
||||
@@ -741,4 +742,5 @@ public interface StringMessages extends Messages {
|
||||
String importOverrideSwitchLabel();
|
||||
String importSelectedLeaderboardGroups();
|
||||
String importSelectAtLeastOne();
|
||||
String deselectAll();
|
||||
}
|
||||
+2
-1
@@ -734,4 +734,5 @@ importServerError=GET leaderboardgroups request failed with Server error. Please
|
||||
importLeaderboardGroups=Leaderboard Groups:
|
||||
importOverrideSwitchLabel=Override existing data if names and ids match
|
||||
importSelectedLeaderboardGroups=Import selected leaderboard groups
|
||||
importSelectAtLeastOne=You have to select at least one leaderboard group to import
|
||||
importSelectAtLeastOne=You have to select at least one leaderboard group to import
|
||||
deselectAll=Deselect all
|
||||
+2
-1
@@ -730,4 +730,5 @@ importServerError=Der GET leaderboardgroups Request scheiterte an einem Server E
|
||||
importLeaderboardGroups=Leaderboard Groups:
|
||||
importOverrideSwitchLabel=Bei übereinstimmenden IDs und Namen die Daten überschreiben
|
||||
importSelectedLeaderboardGroups=Ausgewählte Leaderboard Groups selektieren
|
||||
importSelectAtLeastOne=Es muss mindestens eine Leaderboard Group ausgewählt werden
|
||||
importSelectAtLeastOne=Es muss mindestens eine Leaderboard Group ausgewählt werden
|
||||
deselectAll=Alle deselektieren
|
||||
+71
-2
@@ -6,7 +6,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.FocusWidget;
|
||||
@@ -34,6 +37,8 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
private final Map<String, CheckBox> courseAreaCheckBoxMap;
|
||||
private final Map<String, CheckBox> regattaCheckBoxMap;
|
||||
private final Anchor resultingLink;
|
||||
private Button courseAreaDeselectButton;
|
||||
private Button regattaDeselectButton;
|
||||
|
||||
private final static String SETTINGS_DIALOG_COMPONENT = "SettingsDialogComponent";
|
||||
|
||||
@@ -68,9 +73,12 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
Grid courseAreaGrid = new Grid(numberOfRequiredRows, maxCourseAreasPerRow);
|
||||
courseAreaPanel.add(courseAreaGrid);
|
||||
|
||||
boolean allCheckboxesSelected = true;
|
||||
for (CourseAreaDTO courseAreaDTO : courseAreas) {
|
||||
CheckBox checkBox = dialog.createCheckbox(courseAreaDTO.getName());
|
||||
checkBox.setValue(Util.contains(initialSettings.getVisibleCourseAreas(), courseAreaDTO.id));
|
||||
boolean isCourseAreaVisible = Util.contains(initialSettings.getVisibleCourseAreas(), courseAreaDTO.id);
|
||||
allCheckboxesSelected &= isCourseAreaVisible;
|
||||
checkBox.setValue(isCourseAreaVisible);
|
||||
courseAreaCheckBoxMap.put(courseAreaDTO.id, checkBox);
|
||||
|
||||
courseAreaGrid.setWidget(rowIndex, columnIndex++, checkBox);
|
||||
@@ -79,6 +87,29 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
columnIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
courseAreaDeselectButton = new Button();
|
||||
setTextOfDeselectButton(courseAreaDeselectButton, allCheckboxesSelected);
|
||||
courseAreaDeselectButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (courseAreaDeselectButton.getText().equals(stringMessages.deselectAll())) {
|
||||
for (CheckBox checkBox : courseAreaCheckBoxMap.values()) {
|
||||
checkBox.setValue(false);
|
||||
}
|
||||
courseAreaDeselectButton.setText(stringMessages.selectAll());
|
||||
} else {
|
||||
for (CheckBox checkBox : courseAreaCheckBoxMap.values()) {
|
||||
checkBox.setValue(true);
|
||||
}
|
||||
courseAreaDeselectButton.setText(stringMessages.deselectAll());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
flowPanel.add(courseAreaDeselectButton);
|
||||
|
||||
return flowPanel;
|
||||
}
|
||||
|
||||
@@ -101,9 +132,12 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
Grid regattaGrid = new Grid(numberOfRequiredRows, maxRegattasPerRow);
|
||||
regattaNamesPanel.add(regattaGrid);
|
||||
|
||||
boolean allCheckboxesSelected = true;
|
||||
for (RaceGroupDTO raceGroup : raceGroups) {
|
||||
CheckBox checkBox = dialog.createCheckbox(raceGroup.displayName);
|
||||
checkBox.setValue(Util.contains(initialSettings.getVisibleRegattas(), raceGroup.getName()));
|
||||
boolean isRaceGroupVisible = Util.contains(initialSettings.getVisibleRegattas(), raceGroup.getName());
|
||||
allCheckboxesSelected &= isRaceGroupVisible;
|
||||
checkBox.setValue(isRaceGroupVisible);
|
||||
regattaCheckBoxMap.put(raceGroup.getName(), checkBox);
|
||||
|
||||
regattaGrid.setWidget(rowIndex, columnIndex++, checkBox);
|
||||
@@ -112,9 +146,40 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
columnIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
regattaDeselectButton = new Button();
|
||||
setTextOfDeselectButton(regattaDeselectButton, allCheckboxesSelected);
|
||||
regattaDeselectButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (regattaDeselectButton.getText().equals(stringMessages.deselectAll())) {
|
||||
for (CheckBox checkBox : regattaCheckBoxMap.values()) {
|
||||
checkBox.setValue(false);
|
||||
}
|
||||
regattaDeselectButton.setText(stringMessages.selectAll());
|
||||
} else {
|
||||
for (CheckBox checkBox : regattaCheckBoxMap.values()) {
|
||||
checkBox.setValue(true);
|
||||
}
|
||||
regattaDeselectButton.setText(stringMessages.deselectAll());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
flowPanel.add(regattaDeselectButton);
|
||||
|
||||
return flowPanel;
|
||||
}
|
||||
|
||||
private void setTextOfDeselectButton(Button deselectButton, boolean allCheckboxesSelected) {
|
||||
if (allCheckboxesSelected) {
|
||||
deselectButton.setText(stringMessages.deselectAll());
|
||||
} else {
|
||||
deselectButton.setText(stringMessages.selectAll());
|
||||
}
|
||||
}
|
||||
|
||||
private CheckBox getShowOnlyRacesOfSameDayWidget(DataEntryDialog<?> dialog) {
|
||||
showOnlyRacesOfSameDayCheckBox = dialog.createCheckbox(stringMessages.showOnlyRacesOfSameDay());
|
||||
showOnlyRacesOfSameDayCheckBox.setValue(initialSettings.isShowOnlyRacesOfSameDay());
|
||||
@@ -160,6 +225,8 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
selectedCourseAreas.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
boolean allCourseAreasSelected = selectedCourseAreas.size() == courseAreas.size();
|
||||
setTextOfDeselectButton(courseAreaDeselectButton, allCourseAreasSelected);
|
||||
|
||||
List<String> selectedRegattas = new ArrayList<String>();
|
||||
for (Entry<String, CheckBox> entry : regattaCheckBoxMap.entrySet()) {
|
||||
@@ -167,6 +234,8 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
|
||||
selectedRegattas.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
boolean allRegattasSelected = selectedRegattas.size() == raceGroups.size();
|
||||
setTextOfDeselectButton(regattaDeselectButton, allRegattasSelected);
|
||||
|
||||
boolean isShowOnlyRacesOfSameDay = showOnlyRacesOfSameDayCheckBox.getValue();
|
||||
boolean isShowOnlyCurrentlyRunningRaces = showOnlyCurrentlyRunningRacesCheckBox.getValue();
|
||||
|
||||
Reference in new issue
Block a user