mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 11:02:25 +00:00
Extracted the selection panel from the DataMiningEntryPoint
This commit is contained in:
1 parent
3d07d3817d
commit
6fb6520117
6 files changed
+280
-266
No files matched your search
+3
@@ -746,4 +746,7 @@ public interface StringMessages extends Messages {
|
||||
String timeSinceLastPositionFix();
|
||||
String timeSinceLastPositionFixTooltip();
|
||||
String trackingQuality();
|
||||
String legType();
|
||||
String sailID();
|
||||
String clearSelection();
|
||||
}
|
||||
+3
@@ -740,3 +740,6 @@ polarDiagramButton=Polar Diagram
|
||||
timeSinceLastPositionFix=Last GPS
|
||||
timeSinceLastPositionFixTooltip=Time since last received GPS position
|
||||
trackingQuality=Tracking quality
|
||||
legType=Leg Type
|
||||
sailID=Sail Number
|
||||
clearSelection=Clear Selection
|
||||
+3
@@ -736,3 +736,6 @@ polarDiagramButton=Polardiagramm
|
||||
timeSinceLastPositionFix=Letztes GPS
|
||||
timeSinceLastPositionFixTooltip=Zeit seit der letzten empfangenen GPS-Position
|
||||
trackingQuality=Tracking-Qualität
|
||||
legType=Art des Schenkels
|
||||
sailID=Segelnummer
|
||||
clearSelection=Auswahl leeren
|
||||
+5
-266
@@ -1,17 +1,9 @@
|
||||
package com.sap.sailing.gwt.ui.datamining;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.cellview.client.CellTable;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
@@ -19,43 +11,19 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.IntegerBox;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.sap.sailing.datamining.shared.Dimension;
|
||||
import com.sap.sailing.domain.common.LegType;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.gwt.ui.client.AbstractEntryPoint;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceWithCompetitorsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
|
||||
public class DataMiningEntryPoint extends AbstractEntryPoint {
|
||||
|
||||
private SelectionPanel selectionPanel;
|
||||
|
||||
private IntegerBox numberOfQueriesBox;
|
||||
private Label benchmarkStatusLabel;
|
||||
|
||||
private FlowPanel resultsPanel;
|
||||
private QueryBenchmarkResultsChart resultsChart;
|
||||
|
||||
private ListDataProvider<RegattaDTO> regattaNameDataProvider;
|
||||
private ListDataProvider<BoatClassDTO> boatClassDataProvider;
|
||||
private ListDataProvider<RaceDTO> raceNameDataProvider;
|
||||
private ListDataProvider<Integer> legNumberDataProvider;
|
||||
private ListDataProvider<LegType> legTypeDataProvider;
|
||||
private ListDataProvider<CompetitorDTO> competitorNameDataProvider;
|
||||
private ListDataProvider<CompetitorDTO> competitorSailIDDataProvider;
|
||||
private ListDataProvider<String> nationalityDataProvider;
|
||||
|
||||
private MultiSelectionModel<RegattaDTO> regattaNameSelectionModel;
|
||||
private MultiSelectionModel<BoatClassDTO> boatClassSelectionModel;
|
||||
private MultiSelectionModel<RaceDTO> raceNameSelectionModel;
|
||||
private MultiSelectionModel<Integer> legNumberSelectionModel;
|
||||
private MultiSelectionModel<LegType> legTypeSelectionModel;
|
||||
private MultiSelectionModel<CompetitorDTO> competitorNameSelectionModel;
|
||||
private MultiSelectionModel<CompetitorDTO> competitorSailIDSelectionModel;
|
||||
private MultiSelectionModel<String> nationalitySelectionModel;
|
||||
|
||||
@Override
|
||||
protected void doOnModuleLoad() {
|
||||
@@ -64,7 +32,8 @@ public class DataMiningEntryPoint extends AbstractEntryPoint {
|
||||
FlowPanel dataMiningElementsPanel = new FlowPanel();
|
||||
rootPanel.add(dataMiningElementsPanel);
|
||||
|
||||
dataMiningElementsPanel.add(createSelectionPanel());
|
||||
selectionPanel = new SelectionPanel(stringMessages, sailingService, this);
|
||||
dataMiningElementsPanel.add(selectionPanel);
|
||||
|
||||
dataMiningElementsPanel.add(createFunctionsPanel());
|
||||
|
||||
@@ -72,8 +41,6 @@ public class DataMiningEntryPoint extends AbstractEntryPoint {
|
||||
dataMiningElementsPanel.add(resultsPanel);
|
||||
resultsChart = new QueryBenchmarkResultsChart();
|
||||
resultsPanel.add(resultsChart);
|
||||
|
||||
fillSelectionPanel();
|
||||
}
|
||||
|
||||
private void runBenchmark() {
|
||||
@@ -87,7 +54,7 @@ public class DataMiningEntryPoint extends AbstractEntryPoint {
|
||||
@Override
|
||||
public void onSuccess(List<RegattaDTO> regattas) {
|
||||
final int times = numberOfQueriesBox.getValue() == null ? 1 : numberOfQueriesBox.getValue();
|
||||
runQuery(new ClientQueryData(getSelection(), times, 1));
|
||||
runQuery(new ClientQueryData(selectionPanel.getSelection(), times, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -139,233 +106,5 @@ public class DataMiningEntryPoint extends AbstractEntryPoint {
|
||||
functionsPanel.add(benchmarkStatusLabel);
|
||||
return functionsPanel;
|
||||
}
|
||||
|
||||
private Map<Dimension, Collection<?>> getSelection() {
|
||||
Map<Dimension, Collection<?>> selection = new HashMap<Dimension, Collection<?>>();
|
||||
|
||||
if (!raceNameSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> regattaNames = new HashSet<String>();
|
||||
for (RegattaDTO regatta : regattaNameSelectionModel.getSelectedSet()) {
|
||||
regattaNames.add(regatta.getName());
|
||||
}
|
||||
selection.put(Dimension.RegattaName, regattaNames);
|
||||
}
|
||||
|
||||
if (!boatClassSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> boatClassNames = new HashSet<String>();
|
||||
for (BoatClassDTO boatClass : boatClassSelectionModel.getSelectedSet()) {
|
||||
boatClassNames.add(boatClass.getName());
|
||||
}
|
||||
selection.put(Dimension.BoatClassName, boatClassNames);
|
||||
}
|
||||
|
||||
if (!raceNameSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> raceNames = new HashSet<String>();
|
||||
for (RaceDTO race : raceNameSelectionModel.getSelectedSet()) {
|
||||
raceNames.add(race.getName());
|
||||
}
|
||||
selection.put(Dimension.RaceName, raceNames);
|
||||
}
|
||||
|
||||
if (!legNumberSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<Integer> raceNames = new HashSet<Integer>(legNumberSelectionModel.getSelectedSet());
|
||||
selection.put(Dimension.LegNumber, raceNames);
|
||||
}
|
||||
|
||||
if (!legTypeSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<LegType> legTypes = new HashSet<LegType>(legTypeSelectionModel.getSelectedSet());
|
||||
selection.put(Dimension.LegType, legTypes);
|
||||
}
|
||||
|
||||
if (!competitorNameSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> competitorNames = new HashSet<String>();
|
||||
for (CompetitorDTO competitor : competitorNameSelectionModel.getSelectedSet()) {
|
||||
competitorNames.add(competitor.getName());
|
||||
}
|
||||
selection.put(Dimension.CompetitorName, competitorNames);
|
||||
}
|
||||
|
||||
if (!competitorSailIDSelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> sailIDs = new HashSet<String>();
|
||||
for (CompetitorDTO competitor : competitorSailIDSelectionModel.getSelectedSet()) {
|
||||
sailIDs.add(competitor.getSailID());
|
||||
}
|
||||
selection.put(Dimension.SailID, sailIDs);
|
||||
}
|
||||
|
||||
if (!nationalitySelectionModel.getSelectedSet().isEmpty()) {
|
||||
Collection<String> nationalities = new HashSet<String>(nationalitySelectionModel.getSelectedSet());
|
||||
selection.put(Dimension.Nationality, nationalities);
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
private void fillSelectionPanel() {
|
||||
sailingService.getRegattas(new AsyncCallback<List<RegattaDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
DataMiningEntryPoint.this.reportError("Error fetching the regattas from the server: " + caught.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(List<RegattaDTO> regattas) {
|
||||
regattaNameDataProvider.getList().clear();
|
||||
regattaNameDataProvider.getList().addAll(regattas);
|
||||
|
||||
Set<BoatClassDTO> boatClasses = new HashSet<BoatClassDTO>();
|
||||
Set<RaceDTO> races = new HashSet<RaceDTO>();
|
||||
Set<CompetitorDTO> competitors = new HashSet<CompetitorDTO>();
|
||||
Set<String> nationalities = new HashSet<String>();
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
if (regatta != null) {
|
||||
boatClasses.add(regatta.boatClass);
|
||||
for (RaceWithCompetitorsDTO race : regatta.races) {
|
||||
if (race != null) {
|
||||
races.add(race);
|
||||
for (CompetitorDTO competitor : race.competitors) {
|
||||
if (competitor != null) {
|
||||
competitors.add(competitor);
|
||||
nationalities.add(competitor.getThreeLetterIocCountryCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boatClassDataProvider.getList().clear();
|
||||
boatClassDataProvider.getList().addAll(boatClasses);
|
||||
|
||||
raceNameDataProvider.getList().clear();
|
||||
raceNameDataProvider.getList().addAll(races);
|
||||
|
||||
competitorNameDataProvider.getList().clear();
|
||||
competitorNameDataProvider.getList().addAll(competitors);
|
||||
|
||||
competitorSailIDDataProvider.getList().clear();
|
||||
competitorSailIDDataProvider.getList().addAll(competitors);
|
||||
|
||||
nationalityDataProvider.getList().clear();
|
||||
nationalityDataProvider.getList().addAll(nationalities);
|
||||
}
|
||||
});
|
||||
|
||||
legNumberDataProvider.getList().clear();
|
||||
legNumberDataProvider.getList().addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
|
||||
legTypeDataProvider.getList().clear();
|
||||
legTypeDataProvider.getList().addAll(Arrays.asList(LegType.values()));
|
||||
}
|
||||
|
||||
private HorizontalPanel createSelectionPanel() {
|
||||
HorizontalPanel selectionPanel = new HorizontalPanel();
|
||||
selectionPanel.setSpacing(5);
|
||||
|
||||
CellTable<RegattaDTO> regattaNameTable = new CellTable<RegattaDTO>();
|
||||
regattaNameTable.addColumn(new TextColumn<RegattaDTO>() {
|
||||
@Override
|
||||
public String getValue(RegattaDTO regatta) {
|
||||
return regatta.getName();
|
||||
}
|
||||
}, "Regatta");
|
||||
regattaNameSelectionModel = new MultiSelectionModel<RegattaDTO>();
|
||||
regattaNameTable.setSelectionModel(regattaNameSelectionModel);
|
||||
regattaNameDataProvider = new ListDataProvider<RegattaDTO>();
|
||||
regattaNameDataProvider.addDataDisplay(regattaNameTable);
|
||||
selectionPanel.add(regattaNameTable);
|
||||
|
||||
CellTable<BoatClassDTO> boatClassTable = new CellTable<BoatClassDTO>();
|
||||
boatClassTable.addColumn(new TextColumn<BoatClassDTO>() {
|
||||
@Override
|
||||
public String getValue(BoatClassDTO boatClass) {
|
||||
return boatClass.getName();
|
||||
}
|
||||
}, "Boat Class");
|
||||
boatClassSelectionModel = new MultiSelectionModel<BoatClassDTO>();
|
||||
boatClassTable.setSelectionModel(boatClassSelectionModel);
|
||||
boatClassDataProvider = new ListDataProvider<BoatClassDTO>();
|
||||
boatClassDataProvider.addDataDisplay(boatClassTable);
|
||||
selectionPanel.add(boatClassTable);
|
||||
|
||||
CellTable<RaceDTO> raceNameTable = new CellTable<RaceDTO>();
|
||||
raceNameTable.addColumn(new TextColumn<RaceDTO>() {
|
||||
@Override
|
||||
public String getValue(RaceDTO race) {
|
||||
return race.getName();
|
||||
}
|
||||
}, "Race Name");
|
||||
raceNameSelectionModel = new MultiSelectionModel<RaceDTO>();
|
||||
raceNameTable.setSelectionModel(raceNameSelectionModel);
|
||||
raceNameDataProvider = new ListDataProvider<RaceDTO>();
|
||||
raceNameDataProvider.addDataDisplay(raceNameTable);
|
||||
selectionPanel.add(raceNameTable);
|
||||
|
||||
CellTable<Integer> legNumberTable = new CellTable<Integer>();
|
||||
legNumberTable.addColumn(new TextColumn<Integer>() {
|
||||
@Override
|
||||
public String getValue(Integer legNumber) {
|
||||
return legNumber + "";
|
||||
}
|
||||
}, "Leg Number");
|
||||
legNumberSelectionModel = new MultiSelectionModel<Integer>();
|
||||
legNumberTable.setSelectionModel(legNumberSelectionModel);
|
||||
legNumberDataProvider = new ListDataProvider<Integer>();
|
||||
legNumberDataProvider.addDataDisplay(legNumberTable);
|
||||
selectionPanel.add(legNumberTable);
|
||||
|
||||
CellTable<LegType> legTypeTable = new CellTable<LegType>();
|
||||
legTypeTable.addColumn(new TextColumn<LegType>() {
|
||||
@Override
|
||||
public String getValue(LegType legType) {
|
||||
return legType.name();
|
||||
}
|
||||
}, "Leg Type");
|
||||
legTypeSelectionModel = new MultiSelectionModel<LegType>();
|
||||
legTypeTable.setSelectionModel(legTypeSelectionModel);
|
||||
legTypeDataProvider = new ListDataProvider<LegType>();
|
||||
legTypeDataProvider.addDataDisplay(legTypeTable);
|
||||
selectionPanel.add(legTypeTable);
|
||||
|
||||
CellTable<CompetitorDTO> competitorNameTable = new CellTable<CompetitorDTO>();
|
||||
competitorNameTable.addColumn(new TextColumn<CompetitorDTO>() {
|
||||
@Override
|
||||
public String getValue(CompetitorDTO competitor) {
|
||||
return competitor.getName();
|
||||
}
|
||||
}, "Competitor Name");
|
||||
competitorNameSelectionModel = new MultiSelectionModel<CompetitorDTO>();
|
||||
competitorNameTable.setSelectionModel(competitorNameSelectionModel);
|
||||
competitorNameDataProvider = new ListDataProvider<CompetitorDTO>();
|
||||
competitorNameDataProvider.addDataDisplay(competitorNameTable);
|
||||
selectionPanel.add(competitorNameTable);
|
||||
|
||||
CellTable<CompetitorDTO> competitorSailIDTable = new CellTable<CompetitorDTO>();
|
||||
competitorSailIDTable.addColumn(new TextColumn<CompetitorDTO>() {
|
||||
@Override
|
||||
public String getValue(CompetitorDTO competitor) {
|
||||
return competitor.getSailID();
|
||||
}
|
||||
}, "Competitor Sail ID");
|
||||
competitorSailIDSelectionModel = new MultiSelectionModel<CompetitorDTO>();
|
||||
competitorSailIDTable.setSelectionModel(competitorSailIDSelectionModel);
|
||||
competitorSailIDDataProvider = new ListDataProvider<CompetitorDTO>();
|
||||
competitorSailIDDataProvider.addDataDisplay(competitorSailIDTable);
|
||||
selectionPanel.add(competitorSailIDTable);
|
||||
|
||||
CellTable<String> nationalityTable = new CellTable<String>();
|
||||
nationalityTable.addColumn(new TextColumn<String>() {
|
||||
@Override
|
||||
public String getValue(String nationality) {
|
||||
return nationality;
|
||||
}
|
||||
}, "Nationality");
|
||||
nationalitySelectionModel = new MultiSelectionModel<String>();
|
||||
nationalityTable.setSelectionModel(nationalitySelectionModel);
|
||||
nationalityDataProvider = new ListDataProvider<String>();
|
||||
nationalityDataProvider.addDataDisplay(nationalityTable);
|
||||
selectionPanel.add(nationalityTable);
|
||||
|
||||
return selectionPanel;
|
||||
}
|
||||
|
||||
}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
package com.sap.sailing.gwt.ui.datamining;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.sap.sailing.datamining.shared.Dimension;
|
||||
import com.sap.sailing.domain.common.LegType;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceWithCompetitorsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
|
||||
public class SelectionPanel extends FlowPanel {
|
||||
|
||||
private StringMessages stringMessages;
|
||||
private SailingServiceAsync sailingService;
|
||||
private ErrorReporter errorReporter;
|
||||
|
||||
private Map<Dimension, SelectionTable<?, ?>> tablesMappedByDimension;
|
||||
private SelectionTable<RegattaDTO, String> regattaNameTable;
|
||||
private SelectionTable<BoatClassDTO, String> boatClassTable;
|
||||
private SelectionTable<RaceDTO, String> raceNameTable;
|
||||
private SelectionTable<Integer, Integer> legNumberTable;
|
||||
private SelectionTable<LegType, LegType> legTypeTable;
|
||||
private SelectionTable<CompetitorDTO, String> competitorNameTable;
|
||||
private SelectionTable<CompetitorDTO, String> competitorSailIDTable;
|
||||
private SelectionTable<String, String> nationalityTable;
|
||||
|
||||
public SelectionPanel(StringMessages stringMessages, SailingServiceAsync sailingService, ErrorReporter errorReporter) {
|
||||
super();
|
||||
|
||||
this.stringMessages = stringMessages;
|
||||
this.sailingService = sailingService;
|
||||
this.errorReporter = errorReporter;
|
||||
|
||||
Button clearSelectionButton = new Button(this.stringMessages.clearSelection());
|
||||
clearSelectionButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
clearSelection();
|
||||
}
|
||||
});
|
||||
add(clearSelectionButton);
|
||||
|
||||
add(createSelectionTables());
|
||||
fillSelectionTables();
|
||||
}
|
||||
|
||||
public Map<Dimension, Collection<?>> getSelection() {
|
||||
Map<Dimension, Collection<?>> selection = new HashMap<Dimension, Collection<?>>();
|
||||
for (SelectionTable<?, ?> table : tablesMappedByDimension.values()) {
|
||||
Collection<?> specificSelection = table.getSelection();
|
||||
if (!specificSelection.isEmpty()) {
|
||||
selection.put(table.getDimension(), specificSelection);
|
||||
}
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
private void clearSelection() {
|
||||
for (SelectionTable<?, ?> table : tablesMappedByDimension.values()) {
|
||||
table.clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void fillSelectionTables() {
|
||||
sailingService.getRegattas(new AsyncCallback<List<RegattaDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error fetching the regattas from the server: " + caught.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(List<RegattaDTO> regattas) {
|
||||
Set<BoatClassDTO> boatClasses = new HashSet<BoatClassDTO>();
|
||||
Set<RaceDTO> races = new HashSet<RaceDTO>();
|
||||
Set<CompetitorDTO> competitors = new HashSet<CompetitorDTO>();
|
||||
Set<String> nationalities = new HashSet<String>();
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
if (regatta != null) {
|
||||
boatClasses.add(regatta.boatClass);
|
||||
for (RaceWithCompetitorsDTO race : regatta.races) {
|
||||
if (race != null) {
|
||||
races.add(race);
|
||||
for (CompetitorDTO competitor : race.competitors) {
|
||||
if (competitor != null) {
|
||||
competitors.add(competitor);
|
||||
nationalities.add(competitor.getThreeLetterIocCountryCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
regattaNameTable.setContent(regattas);
|
||||
boatClassTable.setContent(boatClasses);
|
||||
raceNameTable.setContent(races);
|
||||
legNumberTable.setContent(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
legTypeTable.setContent(Arrays.asList(LegType.values()));
|
||||
competitorNameTable.setContent(competitors);
|
||||
competitorSailIDTable.setContent(competitors);
|
||||
nationalityTable.setContent(nationalities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private HorizontalPanel createSelectionTables() {
|
||||
HorizontalPanel tablesPanel = new HorizontalPanel();
|
||||
tablesPanel.setSpacing(5);
|
||||
tablesMappedByDimension = new HashMap<Dimension, SelectionTable<?,?>>();
|
||||
|
||||
regattaNameTable = new SelectionTable<RegattaDTO, String>(stringMessages.regatta(), Dimension.RegattaName) {
|
||||
@Override
|
||||
public String getValue(RegattaDTO regatta) {
|
||||
return regatta.getName();
|
||||
}
|
||||
};
|
||||
tablesPanel.add(regattaNameTable);
|
||||
tablesMappedByDimension.put(Dimension.RegattaName, regattaNameTable);
|
||||
|
||||
boatClassTable = new SelectionTable<BoatClassDTO, String>(stringMessages.boatClass(), Dimension.BoatClassName) {
|
||||
@Override
|
||||
public String getValue(BoatClassDTO boatClass) {
|
||||
return boatClass.getName();
|
||||
}
|
||||
};
|
||||
tablesPanel.add(boatClassTable);
|
||||
tablesMappedByDimension.put(Dimension.BoatClassName, boatClassTable);
|
||||
|
||||
raceNameTable = new SelectionTable<RaceDTO, String>(stringMessages.race(), Dimension.RaceName) {
|
||||
@Override
|
||||
public String getValue(RaceDTO race) {
|
||||
return race.getName();
|
||||
}
|
||||
};
|
||||
tablesPanel.add(raceNameTable);
|
||||
tablesMappedByDimension.put(Dimension.RaceName, raceNameTable);
|
||||
|
||||
legNumberTable = new SelectionTable<Integer, Integer>(stringMessages.legLabel(), Dimension.LegNumber) {
|
||||
@Override
|
||||
public Integer getValue(Integer legNumber) {
|
||||
return legNumber;
|
||||
}
|
||||
};
|
||||
tablesPanel.add(legNumberTable);
|
||||
tablesMappedByDimension.put(Dimension.LegNumber, legNumberTable);
|
||||
|
||||
legTypeTable = new SelectionTable<LegType, LegType>(stringMessages.legType(), Dimension.LegType) {
|
||||
@Override
|
||||
public LegType getValue(LegType legType) {
|
||||
return legType;
|
||||
}
|
||||
};
|
||||
tablesPanel.add(legTypeTable);
|
||||
tablesMappedByDimension.put(Dimension.LegType, legTypeTable);
|
||||
|
||||
competitorNameTable = new SelectionTable<CompetitorDTO, String>(stringMessages.competitor(), Dimension.CompetitorName) {
|
||||
@Override
|
||||
public String getValue(CompetitorDTO competitor) {
|
||||
return competitor.getName();
|
||||
}
|
||||
};
|
||||
tablesPanel.add(competitorNameTable);
|
||||
tablesMappedByDimension.put(Dimension.CompetitorName, competitorNameTable);
|
||||
|
||||
competitorSailIDTable = new SelectionTable<CompetitorDTO, String>(stringMessages.sailID(), Dimension.SailID) {
|
||||
@Override
|
||||
public String getValue(CompetitorDTO competitor) {
|
||||
return competitor.getSailID();
|
||||
}
|
||||
};
|
||||
tablesPanel.add(competitorSailIDTable);
|
||||
tablesMappedByDimension.put(Dimension.SailID, competitorSailIDTable);
|
||||
|
||||
nationalityTable = new SelectionTable<String, String>(stringMessages.nationality(), Dimension.Nationality) {
|
||||
@Override
|
||||
public String getValue(String nationality) {
|
||||
return nationality;
|
||||
}
|
||||
};
|
||||
tablesPanel.add(nationalityTable);
|
||||
tablesMappedByDimension.put(Dimension.Nationality, nationalityTable);
|
||||
|
||||
return tablesPanel;
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.sap.sailing.gwt.ui.datamining;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.gwt.user.cellview.client.CellTable;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.sap.sailing.datamining.shared.Dimension;
|
||||
|
||||
public abstract class SelectionTable<ContentType, ValueType> extends SimplePanel {
|
||||
|
||||
private Dimension dimension;
|
||||
|
||||
private CellTable<ContentType> table;
|
||||
private MultiSelectionModel<ContentType> selectionModel;
|
||||
private ListDataProvider<ContentType> dataProvider;
|
||||
|
||||
public SelectionTable(String title, Dimension dimension) {
|
||||
this.dimension = dimension;
|
||||
table = new CellTable<ContentType>();
|
||||
table.addColumn(new TextColumn<ContentType>() {
|
||||
@Override
|
||||
public String getValue(ContentType content) {
|
||||
return SelectionTable.this.getValueAsString(content);
|
||||
}
|
||||
}, title);
|
||||
selectionModel = new MultiSelectionModel<ContentType>();
|
||||
table.setSelectionModel(selectionModel);
|
||||
dataProvider = new ListDataProvider<ContentType>();
|
||||
dataProvider.addDataDisplay(table);
|
||||
setWidget(table);
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public void setContent(Collection<ContentType> content) {
|
||||
dataProvider.getList().clear();
|
||||
dataProvider.getList().addAll(content);
|
||||
}
|
||||
|
||||
public Collection<?> getSelection() {
|
||||
Collection<ValueType> selectionAsValues = new HashSet<ValueType>();
|
||||
for (ContentType content : selectionModel.getSelectedSet()) {
|
||||
selectionAsValues.add(getValue(content));
|
||||
}
|
||||
return selectionAsValues;
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
selectionModel.clear();
|
||||
}
|
||||
|
||||
public abstract ValueType getValue(ContentType content);
|
||||
|
||||
public String getValueAsString(ContentType content) {
|
||||
return getValue(content).toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user