mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-26 15:36:40 +00:00
- added new attribute "displayName" to a leaderboard. The display name is used so far for overall leaderboards to make it possible to display a different name if used in MetaLeaderboardColumns. Furthermore the display name is used in the leaderboardgrouppanel which finally kills an old hack to shorten ugly leaderboard names.
- Changed formatting of totalPoints in leaderboards to hide useless zeros (e.g. 2 instead of 2.00)
This commit is contained in:
+2
@@ -207,6 +207,8 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
if (result != null) {
|
||||
final Leaderboard finalResult = result;
|
||||
finalResult.setDisplayName((String) dbLeaderboard.get(FieldNames.LEADERBOARD_DISPLAY_NAME.name()));
|
||||
|
||||
DelayedLeaderboardCorrections loadedLeaderboardCorrections = new DelayedLeaderboardCorrectionsImpl(result);
|
||||
final boolean[] needsMigration = new boolean[1];
|
||||
loadedLeaderboardCorrections.addLeaderboardCorrectionsResolvedListener(new LeaderboardCorrectionsResolvedListener() {
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public enum FieldNames {
|
||||
COMPETITOR_ID, COMPETITOR_DISPLAY_NAME,
|
||||
|
||||
// leaderboard:
|
||||
LEADERBOARD_NAME, LEADERBOARD_SUPPRESSED_COMPETITORS, LEADERBOARD_SUPPRESSED_COMPETITOR_IDS,
|
||||
LEADERBOARD_NAME, LEADERBOARD_DISPLAY_NAME, LEADERBOARD_SUPPRESSED_COMPETITORS, LEADERBOARD_SUPPRESSED_COMPETITOR_IDS,
|
||||
LEADERBOARD_COLUMNS, LEADERBOARD_COLUMN_NAME, LEADERBOARD_COMPETITOR_DISPLAY_NAMES,
|
||||
LEADERBOARD_IS_MEDAL_RACE_COLUMN, LEADERBOARD_CARRIED_POINTS, LEADERBOARD_CARRIED_POINTS_BY_ID,
|
||||
LEADERBOARD_SCORE_CORRECTIONS, LEADERBOARD_DISCARDING_THRESHOLDS,
|
||||
|
||||
+3
@@ -145,6 +145,9 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
BasicDBObject query = new BasicDBObject(FieldNames.LEADERBOARD_NAME.name(), leaderboard.getName());
|
||||
BasicDBObject dbLeaderboard = new BasicDBObject();
|
||||
dbLeaderboard.put(FieldNames.LEADERBOARD_NAME.name(), leaderboard.getName());
|
||||
if(leaderboard.getDisplayName() != null) {
|
||||
dbLeaderboard.put(FieldNames.LEADERBOARD_DISPLAY_NAME.name(), leaderboard.getDisplayName());
|
||||
}
|
||||
BasicDBList dbSuppressedCompetitorIds = new BasicDBList();
|
||||
for (Competitor suppressedCompetitor : leaderboard.getSuppressedCompetitors()) {
|
||||
dbSuppressedCompetitorIds.add(suppressedCompetitor.getId());
|
||||
|
||||
@@ -276,12 +276,20 @@ public interface Leaderboard extends Named {
|
||||
|
||||
void setDisplayName(Competitor competitor, String displayName);
|
||||
|
||||
/**
|
||||
* If a display name for the leaderboard has been defined,
|
||||
* this method returns it; otherwise, <code>null</code> is returned.
|
||||
*/
|
||||
String getDisplayName();
|
||||
|
||||
void setDisplayName(String displayName);
|
||||
|
||||
/**
|
||||
* If a display name different from the competitor's {@link Competitor#getName() name} has been defined,
|
||||
* this method returns it; otherwise, <code>null</code> is returned.
|
||||
*/
|
||||
String getDisplayName(Competitor competitor);
|
||||
|
||||
|
||||
/**
|
||||
* Tells if the column represented by <code>raceColumn</code> shall be considered when counting the number of "races
|
||||
* so far" for discarding. Although medal races are never discarded themselves, they still count in determining the
|
||||
|
||||
+15
-2
@@ -57,7 +57,10 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
* competitor names for display in a leaderboard.
|
||||
*/
|
||||
private final Map<Competitor, String> displayNames;
|
||||
|
||||
|
||||
/** the display name of the leaderboard */
|
||||
private String displayName;
|
||||
|
||||
/**
|
||||
* Backs the {@link #getCarriedPoints(Competitor)} API with data. Can be used to prime this leaderboard
|
||||
* with aggregated results of races not tracked / displayed by this leaderboard in detail. The points
|
||||
@@ -151,7 +154,17 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
public String getDisplayName(Competitor competitor) {
|
||||
return displayNames.get(competitor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThresholdBasedResultDiscardingRule getResultDiscardingRule() {
|
||||
return resultDiscardingRule;
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class MetaLeaderboardColumn extends SimpleAbstractRaceColumn implements R
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return leaderboard.getName();
|
||||
return leaderboard.getDisplayName() != null ? leaderboard.getDisplayName() : leaderboard.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,10 +32,6 @@ h1 {
|
||||
}
|
||||
|
||||
/** Most GWT widgets already have a style name defined */
|
||||
.gwt-DialogBox {
|
||||
width: 400px;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.dialogVPanel {
|
||||
margin: 5px;
|
||||
@@ -96,6 +92,10 @@ h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.gwt-DialogBox {
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .Caption {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
+2
@@ -14,6 +14,7 @@ import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
|
||||
public abstract class AbstractLeaderboardDialog extends DataEntryDialog<LeaderboardDescriptor> {
|
||||
protected final StringMessages stringMessages;
|
||||
protected TextBox nameTextBox;
|
||||
protected TextBox displayNameTextBox;
|
||||
protected LeaderboardDescriptor leaderboard;
|
||||
|
||||
protected LongBox[] discardThresholdBoxes;
|
||||
@@ -30,6 +31,7 @@ public abstract class AbstractLeaderboardDialog extends DataEntryDialog<Leaderbo
|
||||
protected LeaderboardDescriptor getResult() {
|
||||
int[] discardThresholdsBoxContents = getDiscardThresholds(discardThresholdBoxes);
|
||||
leaderboard.setName(nameTextBox.getValue());
|
||||
leaderboard.setDisplayName(displayNameTextBox.getValue());
|
||||
leaderboard.setDiscardThresholds(discardThresholdsBoxContents);
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ public class FlexibleLeaderboardCreateDialog extends FlexibleLeaderboardDialog {
|
||||
ErrorReporter errorReporter, DialogCallback<LeaderboardDescriptor> callback) {
|
||||
super(stringMessages.createFlexibleLeaderboard(), new LeaderboardDescriptor(), stringMessages, errorReporter, new FlexibleLeaderboardDialog.LeaderboardParameterValidator(stringMessages, existingLeaderboards), callback);
|
||||
nameTextBox = createTextBox(null);
|
||||
displayNameTextBox = createTextBox(null);
|
||||
scoringSchemeListBox = createScoringSchemeListBox(this, stringMessages);
|
||||
discardThresholdBoxes = initEmptyDiscardThresholdBoxes(this);
|
||||
}
|
||||
|
||||
+11
-6
@@ -2,11 +2,12 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
@@ -76,13 +77,15 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
VerticalPanel mainPanel = new VerticalPanel();
|
||||
Grid formGrid = new Grid(3,2);
|
||||
FlowPanel mainPanel = new FlowPanel();
|
||||
Grid formGrid = new Grid(3,3);
|
||||
formGrid.setCellSpacing(3);
|
||||
formGrid.setWidget(0, 0, new Label(stringMessages.name() + ":"));
|
||||
formGrid.setWidget(0, 0, createLabel(stringMessages.name()));
|
||||
formGrid.setWidget(0, 1, nameTextBox);
|
||||
formGrid.setWidget(1, 0, new Label(stringMessages.scoringSystem() + ":"));
|
||||
formGrid.setWidget(1, 1, scoringSchemeListBox);
|
||||
formGrid.setWidget(1, 0, createLabel(stringMessages.displayName()));
|
||||
formGrid.setWidget(1, 1, displayNameTextBox);
|
||||
formGrid.setWidget(2, 0, createLabel(stringMessages.scoringSystem()));
|
||||
formGrid.setWidget(2, 1, scoringSchemeListBox);
|
||||
mainPanel.add(formGrid);
|
||||
mainPanel.add(new Label(stringMessages.discardRacesFromHowManyStartedRacesOn()));
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
@@ -91,7 +94,9 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
hp.add(new Label("" + (i + 1) + "."));
|
||||
hp.add(discardThresholdBoxes[i]);
|
||||
}
|
||||
alignAllPanelWidgetsVertically(hp, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
mainPanel.add(hp);
|
||||
|
||||
return mainPanel;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class FlexibleLeaderboardEditDialog extends FlexibleLeaderboardDialog {
|
||||
stringConstants, otherExistingLeaderboards), callback);
|
||||
|
||||
nameTextBox = createTextBox(leaderboard.getName());
|
||||
|
||||
displayNameTextBox = createTextBox(leaderboard.getDisplayName());
|
||||
scoringSchemeListBox = createListBox(false);
|
||||
int j = 0;
|
||||
for (ScoringSchemeType scoringSchemeType: ScoringSchemeType.values()) {
|
||||
|
||||
+11
-1
@@ -198,6 +198,14 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
|
||||
return sortList.size() > 0 & sortList.get(0).isAscending();
|
||||
}
|
||||
});
|
||||
|
||||
TextColumn<StrippedLeaderboardDTO> leaderboardDisplayNameColumn = new TextColumn<StrippedLeaderboardDTO>() {
|
||||
@Override
|
||||
public String getValue(StrippedLeaderboardDTO leaderboard) {
|
||||
return leaderboard.getDisplayName() !=null ? leaderboard.getDisplayName() : "";
|
||||
}
|
||||
};
|
||||
|
||||
TextColumn<StrippedLeaderboardDTO> discardingOptionsColumn = new TextColumn<StrippedLeaderboardDTO>() {
|
||||
@Override
|
||||
public String getValue(StrippedLeaderboardDTO leaderboard) {
|
||||
@@ -291,6 +299,7 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
|
||||
}
|
||||
});
|
||||
leaderboardTable.addColumn(linkColumn, stringMessages.name());
|
||||
leaderboardTable.addColumn(leaderboardDisplayNameColumn, stringMessages.displayName());
|
||||
leaderboardTable.addColumn(discardingOptionsColumn, stringMessages.discarding());
|
||||
leaderboardTable.addColumn(leaderboardTypeColumn, stringMessages.type());
|
||||
leaderboardTable.addColumn(scoringSystemColumn, stringMessages.scoringSystem());
|
||||
@@ -946,7 +955,7 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
|
||||
}
|
||||
|
||||
private void updateLeaderboard(final String oldLeaderboardName, final LeaderboardDescriptor leaderboardToUdate) {
|
||||
sailingService.updateLeaderboard(oldLeaderboardName, leaderboardToUdate.getName(),
|
||||
sailingService.updateLeaderboard(oldLeaderboardName, leaderboardToUdate.getName(), leaderboardToUdate.getDisplayName(),
|
||||
leaderboardToUdate.getDiscardThresholds(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
@@ -960,6 +969,7 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
|
||||
StrippedLeaderboardDTO dao = leaderboardList.getList().get(i);
|
||||
if (dao.name.equals(oldLeaderboardName)) {
|
||||
dao.name = leaderboardToUdate.getName();
|
||||
dao.displayName = leaderboardToUdate.getDisplayName();
|
||||
dao.discardThresholds = leaderboardToUdate.getDiscardThresholds();
|
||||
break;
|
||||
}
|
||||
|
||||
+9
@@ -9,6 +9,15 @@ import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
*/
|
||||
public class LeaderboardDescriptor {
|
||||
private String name;
|
||||
private String displayName;
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
private ScoringSchemeType scoringScheme;
|
||||
private int[] discardThresholds;
|
||||
private String regattaName;
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ public class RegattaLeaderboardCreateDialog extends RegattaLeaderboardDialog {
|
||||
super(stringConstants.createRegattaLeaderboard(), new LeaderboardDescriptor(), existingRegattas, stringConstants, errorReporter, new RegattaLeaderboardDialog.LeaderboardParameterValidator(stringConstants, existingLeaderboards), callback);
|
||||
|
||||
nameTextBox = createTextBox(null);
|
||||
displayNameTextBox = createTextBox(null);
|
||||
|
||||
regattaListBox = createListBox(false);
|
||||
regattaListBox.addItem(stringConstants.pleaseSelectARegatta());
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ public class RegattaLeaderboardEditDialog extends RegattaLeaderboardDialog {
|
||||
stringConstants, otherExistingLeaderboards), callback);
|
||||
|
||||
nameTextBox = createTextBox(leaderboard.getName());
|
||||
displayNameTextBox = createTextBox(leaderboard.getDisplayName());
|
||||
|
||||
regattaListBox = createListBox(false);
|
||||
regattaListBox.addItem(stringConstants.pleaseSelectARegatta());
|
||||
|
||||
+15
-1
@@ -89,6 +89,7 @@ public abstract class DataEntryDialog<T> {
|
||||
okButton = new Button(okButtonName);
|
||||
okButton.getElement().getStyle().setMargin(3, Unit.PX);
|
||||
FlowPanel dialogFPanel = new FlowPanel();
|
||||
dialogFPanel.setWidth("100%");
|
||||
statusLabel = new Label();
|
||||
dialogFPanel.add(statusLabel);
|
||||
if (message != null) {
|
||||
@@ -98,6 +99,7 @@ public abstract class DataEntryDialog<T> {
|
||||
}
|
||||
|
||||
panelForAdditionalWidget = new FlowPanel();
|
||||
panelForAdditionalWidget.setWidth("100%");
|
||||
dialogFPanel.add(panelForAdditionalWidget);
|
||||
FlowPanel buttonPanel = new FlowPanel();
|
||||
dialogFPanel.add(buttonPanel);
|
||||
@@ -139,7 +141,7 @@ public abstract class DataEntryDialog<T> {
|
||||
}
|
||||
|
||||
protected abstract T getResult();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a text box with a key-up listener attached which ensures the value is updated after each
|
||||
* key-up event and the entire dialog is {@link #validate() validated} in this case.
|
||||
@@ -335,6 +337,18 @@ public abstract class DataEntryDialog<T> {
|
||||
AbstractEntryPoint.linkEscapeToButton(getCancelButton(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a standard label for input fields.
|
||||
* The label has some default formatting like "no wrap" and a colon right after the label text
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public Label createLabel(String name) {
|
||||
Label result = new Label(name + ":");
|
||||
result.setWordWrap(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
public ListBox createListBox(boolean isMultipleSelect) {
|
||||
ListBox result = new ListBox(isMultipleSelect);
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
List<StrippedLeaderboardDTO> getLeaderboardsByEvent(RegattaDTO regatta);
|
||||
|
||||
void updateLeaderboard(String leaderboardName, String newLeaderboardName, int[] newDiscardingThreasholds);
|
||||
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThreasholds);
|
||||
|
||||
StrippedLeaderboardDTO createFlexibleLeaderboard(String leaderboardName, int[] discardThresholds, ScoringSchemeType scoringSchemeType);
|
||||
|
||||
|
||||
+2
-2
@@ -204,8 +204,8 @@ public interface SailingServiceAsync {
|
||||
|
||||
void getLeaderboardsByRace(RaceDTO race, AsyncCallback<List<StrippedLeaderboardDTO>> callback);
|
||||
|
||||
void updateLeaderboard(String leaderboardName, String newLeaderboardName, int[] newDiscardingThreasholds,
|
||||
AsyncCallback<Void> callback);
|
||||
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName,
|
||||
int[] newDiscardingThreasholds, AsyncCallback<Void> callback);
|
||||
|
||||
void createFlexibleLeaderboard(String leaderboardName, int[] discardThresholds, ScoringSchemeType scoringSchemeType,
|
||||
AsyncCallback<StrippedLeaderboardDTO> asyncCallback);
|
||||
|
||||
+1
@@ -496,4 +496,5 @@ public interface StringMessages extends Messages {
|
||||
String overallRank();
|
||||
String overallRankTooltip();
|
||||
String noDataFound();
|
||||
String displayName();
|
||||
}
|
||||
|
||||
+2
-1
@@ -496,4 +496,5 @@ totalsColumnTooltip=The total of all points of a competitor in the regatta.
|
||||
windData=Wind data
|
||||
gpsData=GPS data
|
||||
status=Status
|
||||
noDataFound=No data found
|
||||
noDataFound=No data found
|
||||
displayName=Display name
|
||||
+2
-1
@@ -497,4 +497,5 @@ totalsColumnTooltip=Summe aller Punkte eines Teilnehmers in der Regatta
|
||||
windData=Winddaten
|
||||
gpsData=GPS-Daten
|
||||
status=Status
|
||||
noDataFound=Keine Daten gefunden
|
||||
noDataFound=Keine Daten gefunden
|
||||
displayName=Anzeigename
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
|
||||
private static final int CARRY_COLUMN_INDEX = 3;
|
||||
|
||||
protected static final NumberFormat scoreFormat = NumberFormat.getFormat("0.00");
|
||||
protected static final NumberFormat scoreFormat = NumberFormat.getFormat("0.##");
|
||||
|
||||
private final SailingServiceAsync sailingService;
|
||||
|
||||
|
||||
+3
-2
@@ -2055,6 +2055,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
Long delayToLiveInMillisForLatestRace = null;
|
||||
leaderboardDTO.name = leaderboard.getName();
|
||||
leaderboardDTO.displayName = leaderboard.getDisplayName();
|
||||
leaderboardDTO.competitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
leaderboardDTO.isMetaLeaderboard = leaderboard instanceof MetaLeaderboard ? true : false;
|
||||
if (leaderboard instanceof RegattaLeaderboard) {
|
||||
@@ -2189,8 +2190,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLeaderboard(String leaderboardName, String newLeaderboardName, int[] newDiscardingThresholds) {
|
||||
getService().apply(new UpdateLeaderboard(leaderboardName, newLeaderboardName, newDiscardingThresholds));
|
||||
public void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds) {
|
||||
getService().apply(new UpdateLeaderboard(leaderboardName, newLeaderboardName, newLeaderboardDisplayName, newDiscardingThresholds));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -22,6 +22,7 @@ public abstract class AbstractLeaderboardDTO implements IsSerializable {
|
||||
public boolean hasCarriedPoints;
|
||||
public int[] discardThresholds;
|
||||
public String regattaName;
|
||||
public String displayName;
|
||||
public ScoringSchemeType scoringScheme;
|
||||
public boolean isMetaLeaderboard;
|
||||
public boolean isRegattaLeaderboard;
|
||||
@@ -40,6 +41,10 @@ public abstract class AbstractLeaderboardDTO implements IsSerializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName(CompetitorDTO competitor) {
|
||||
if (competitorDisplayNames == null || competitorDisplayNames.get(competitor) == null) {
|
||||
return competitor.name;
|
||||
|
||||
+1
-26
@@ -97,7 +97,6 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
|
||||
|
||||
private VerticalPanel mainPanel;
|
||||
private Widget welcomeWidget = null;
|
||||
private boolean allLeaderboardNamesStartWithGroupName = false;
|
||||
private final boolean isEmbedded;
|
||||
private final boolean showRaceDetails;
|
||||
|
||||
@@ -124,16 +123,6 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
|
||||
public void onSuccess(final LeaderboardGroupDTO leaderboardGroupDTO) {
|
||||
if (leaderboardGroupDTO != null) {
|
||||
LeaderboardGroupPanel.this.leaderboardGroup = leaderboardGroupDTO;
|
||||
if(leaderboardGroupDTO.leaderboards.size() > 1) {
|
||||
allLeaderboardNamesStartWithGroupName = true;
|
||||
String groupName = leaderboardGroupDTO.name;
|
||||
for(StrippedLeaderboardDTO leaderboard: leaderboardGroupDTO.leaderboards) {
|
||||
if(!leaderboard.name.startsWith(groupName)) {
|
||||
allLeaderboardNamesStartWithGroupName = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// in case there is a regatta leaderboard in the leaderboard group
|
||||
// we need to know the corresponding regatta structure
|
||||
if(leaderboardGroup.containsRegattaLeaderboard()) {
|
||||
@@ -207,12 +196,7 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
|
||||
leaderboardNameCell) {
|
||||
@Override
|
||||
public SafeHtml getValue(StrippedLeaderboardDTO strippedLeaderboardDTO) {
|
||||
String text = "";
|
||||
if (allLeaderboardNamesStartWithGroupName) {
|
||||
text = shortenLeaderboardName(leaderboardGroup.name, strippedLeaderboardDTO.name);
|
||||
} else {
|
||||
text = strippedLeaderboardDTO.name;
|
||||
}
|
||||
String text = strippedLeaderboardDTO.displayName != null ? strippedLeaderboardDTO.displayName : strippedLeaderboardDTO.name;
|
||||
SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||
b.append(TEXTTEMPLATE.textWithClass(text, STYLE_BOATCLASS));
|
||||
return b.toSafeHtml();
|
||||
@@ -284,15 +268,6 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
|
||||
return legendPanel;
|
||||
}
|
||||
|
||||
private String shortenLeaderboardName(String prefixToCut, String leaderboardName) {
|
||||
String result = leaderboardName.substring(prefixToCut.length(), leaderboardName.length());
|
||||
result = result.trim();
|
||||
if(result.startsWith("(") && result.endsWith(")")) {
|
||||
result = result.substring(1, result.length()-1);
|
||||
}
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
private SafeHtml leaderboardRacesToHtml(StrippedLeaderboardDTO leaderboard) {
|
||||
SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||
if (leaderboard.isRegattaLeaderboard && leaderboard.regattaName != null) {
|
||||
|
||||
+4
-1
@@ -10,11 +10,13 @@ import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
|
||||
private static final long serialVersionUID = -8040361040050151768L;
|
||||
private final String newLeaderboardName;
|
||||
private final String newLeaderboardDisplayName;
|
||||
private final int[] newDiscardingThresholds;
|
||||
|
||||
public UpdateLeaderboard(String leaderboardName, String newLeaderboardName, int[] newDiscardingThresholds) {
|
||||
public UpdateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds) {
|
||||
super(leaderboardName);
|
||||
this.newLeaderboardName = newLeaderboardName;
|
||||
this.newLeaderboardDisplayName = newLeaderboardDisplayName;
|
||||
this.newDiscardingThresholds = newDiscardingThresholds;
|
||||
}
|
||||
|
||||
@@ -39,6 +41,7 @@ public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
|
||||
if (!Arrays.equals(leaderboard.getResultDiscardingRule().getDiscardIndexResultsStartingWithHowManyRaces(), newDiscardingThresholds)) {
|
||||
leaderboard.setResultDiscardingRule(new ResultDiscardingRuleImpl(newDiscardingThresholds));
|
||||
}
|
||||
leaderboard.setDisplayName(newLeaderboardDisplayName);
|
||||
updateStoredLeaderboard(toState, leaderboard);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user