Merge remote-tracking branch 'server/master'

This commit is contained in:
Axel Uhl
2015-12-07 17:49:04 +01:00
26 changed files with 279 additions and 87 deletions
@@ -1,5 +1,6 @@
package com.sap.sailing.gwt.home.desktop.partials.old;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.FlowPanel;
@@ -8,6 +9,9 @@ import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.home.shared.partials.fullscreen.FullscreenContainer;
import com.sap.sse.common.Color;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicatorResources;
import com.sap.sse.gwt.client.controls.busyindicator.SimpleBusyIndicator;
public abstract class AbstractLeaderboardFullscreenViewer<T extends Widget> extends FullscreenContainer<T> implements
LeaderboardDelegate<T> {
@@ -15,14 +19,18 @@ public abstract class AbstractLeaderboardFullscreenViewer<T extends Widget> exte
private final Image autoRefreshControl = new Image("images/home/reload.svg");
private final Image settingsControl = new Image("images/home/settings.svg");
private final static BusyIndicatorResources RESOURCES = GWT.create(BusyIndicatorResources.class);
private final Label lastScoringUpdateTime = new Label();
private final Label lastScoringUpdateText = new Label();
protected final Label lastScoringComment = new Label();
protected final Label scoringScheme = new Label();
protected final BusyIndicator busyIndicator = new SimpleBusyIndicator(false, 0.9f, RESOURCES.busyIndicatorCircleInverted());
public AbstractLeaderboardFullscreenViewer() {
showLogo();
showBorder();
addToolbarBusyIndicator(busyIndicator);
addToolbarInfo(createPanel(lastScoringUpdateText, lastScoringUpdateTime));
addToolbarAction(autoRefreshControl);
addToolbarAction(settingsControl);
@@ -88,4 +96,13 @@ public abstract class AbstractLeaderboardFullscreenViewer<T extends Widget> exte
return scoringScheme.getElement();
}
@Override
public Element getBusyIndicatorElement() {
return busyIndicator.getElement();
}
@Override
public void setBusyState(boolean isBusy) {
busyIndicator.setBusy(isBusy);
}
}
@@ -106,6 +106,11 @@
background-color: #f0ab00;
}
.regattaleaderboard_meta_busyindicator {
display: inline-block;
margin: 0 0.666666666666667em;
}
.regattaleaderboard_meta_liverace {
color: red;
font-weight: 600;
@@ -30,6 +30,7 @@ public interface EventRegattaLeaderboardResources extends ClientBundle {
String regattaleaderboard_meta_update_type();
String regattaleaderboard_meta_scoring_timestamp();
String regattaleaderboard_meta_update_timestamp();
String regattaleaderboard_meta_busyindicator();
String regattaleaderboard_meta_scoring_text();
String regattaleaderboard_meta_update_text();
String regattaleaderboard_meta_reload();
@@ -10,6 +10,8 @@ public interface LeaderboardDelegate<T extends Widget> {
void setLeaderboardPanel(T leaderboardPanel);
void setBusyState(boolean isBusy);
Widget getAutoRefreshControl();
Widget getSettingsControl();
@@ -24,4 +26,5 @@ public interface LeaderboardDelegate<T extends Widget> {
Element getScoringSchemeElement();
Element getBusyIndicatorElement();
}
@@ -31,12 +31,14 @@ import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPanel;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettings;
import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
import com.sap.sse.gwt.client.controls.busyindicator.BusyStateChangeListener;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
public class OldLeaderboard extends Composite {
public class OldLeaderboard extends Composite implements BusyStateChangeListener {
private static OldLeaderboardUiBinder uiBinder = GWT.create(OldLeaderboardUiBinder.class);
interface OldLeaderboardUiBinder extends UiBinder<Widget, OldLeaderboard> {
@@ -52,6 +54,7 @@ public class OldLeaderboard extends Composite {
@UiField DivElement lastScoringCommentDiv;
@UiField DivElement scoringSchemeDiv;
@UiField DivElement hasLiveRaceDiv;
@UiField BusyIndicator busyIndicator;
@UiField EventRegattaLeaderboardResources local_res;
private LeaderboardPanel leaderboardPanel;
@@ -166,6 +169,7 @@ public class OldLeaderboard extends Composite {
this.autoRefreshTimer = timer;
this.leaderboardPanel = leaderboardPanel;
oldLeaderboardPanel.add(leaderboardPanel);
leaderboardPanel.addBusyStateChangeListener(this);
}
public void updatedLeaderboard(LeaderboardDTO leaderboard) {
@@ -217,8 +221,17 @@ public class OldLeaderboard extends Composite {
}
lastScoringUpdateTimeDiv.getStyle().setVisibility(Visibility.HIDDEN);
}
@Override
public void onBusyStateChange(boolean busyState) {
busyIndicator.setBusy(busyState);
if(delegate != null) {
delegate.setBusyState(busyState);
}
}
public interface OldLeaderboardDelegate extends LeaderboardDelegate<LeaderboardPanel> {
Element getHasLiveRaceElement();
}
}
@@ -1,16 +1,18 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:c="urn:import:com.sap.sse.gwt.client.controls.busyindicator">
<ui:with field="i18n" type="com.sap.sailing.gwt.common.client.i18n.TextMessages"/>
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
<ui:with field="local_res" type="com.sap.sailing.gwt.home.desktop.partials.old.EventRegattaLeaderboardResources" />
<g:HTMLPanel styleName=" {local_res.css.marginFix}">
<div class="{res.mediaCss.grid}">
<div class="{res.mediaCss.small7} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_scoring}">
<div class="{res.mediaCss.small6} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_scoring}">
<div ui:field="lastScoringCommentDiv" class="{local_res.css.regattaleaderboard_meta_scoring_comment}"></div>
<div ui:field="hasLiveRaceDiv" class="{local_res.css.regattaleaderboard_meta_liverace}"></div>
<div ui:field="scoringSchemeDiv" class="{local_res.css.regattaleaderboard_meta_scoring_type}"></div>
</div>
<div class="{res.mediaCss.small5} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_settings}">
<div class="{res.mediaCss.small6} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_settings}">
<c:SimpleBusyIndicator addStyleNames="{local_res.css.regattaleaderboard_meta_busyindicator}" ui:field="busyIndicator" />
<div class="{local_res.css.regattaleaderboard_meta_update}">
<div ui:field="lastScoringUpdateTextDiv" class="{local_res.css.regattaleaderboard_meta_update_text}"></div>
<div ui:field="lastScoringUpdateTimeDiv" class="{local_res.css.regattaleaderboard_meta_update_timestamp}"></div>
@@ -3,7 +3,7 @@ package com.sap.sailing.gwt.home.desktop.partials.old.multileaderboard;
import java.util.Date;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.ParagraphElement;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
@@ -27,15 +27,19 @@ import com.sap.sailing.gwt.home.desktop.partials.old.LeaderboardDelegate;
import com.sap.sailing.gwt.ui.client.DebugIdHelper;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPanel;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettings;
import com.sap.sailing.gwt.ui.leaderboard.MultiLeaderboardPanel;
import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
import com.sap.sailing.gwt.ui.leaderboard.SelectedLeaderboardChangeListener;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
import com.sap.sse.gwt.client.controls.busyindicator.BusyStateChangeListener;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
public class OldMultiLeaderboard extends Composite {
public class OldMultiLeaderboard extends Composite implements SelectedLeaderboardChangeListener, BusyStateChangeListener {
private static OldMultiLeaderboardUiBinder uiBinder = GWT.create(OldMultiLeaderboardUiBinder.class);
interface OldMultiLeaderboardUiBinder extends UiBinder<Widget, OldMultiLeaderboard> {
@@ -46,16 +50,18 @@ public class OldMultiLeaderboard extends Composite {
@UiField Anchor settingsAnchor;
@UiField Anchor autoRefreshAnchor;
@UiField Anchor fullscreenAnchor;
@UiField ParagraphElement lastScoringUpdateTimeDiv;
@UiField ParagraphElement lastScoringUpdateTextDiv;
@UiField ParagraphElement lastScoringCommentDiv;
@UiField ParagraphElement scoringSchemeDiv;
@UiField DivElement lastScoringUpdateTimeDiv;
@UiField DivElement lastScoringUpdateTextDiv;
@UiField DivElement lastScoringCommentDiv;
@UiField DivElement scoringSchemeDiv;
@UiField BusyIndicator busyIndicator;
@UiField EventRegattaLeaderboardResources local_res;
private MultiLeaderboardPanel multiLeaderboardPanel;
private Timer autoRefreshTimer;
private final OldMultiLeaderboardDelegate delegate;
private LeaderboardPanel lastSelectedLeaderboardPanel;
public OldMultiLeaderboard() {
this(null);
}
@@ -69,6 +75,7 @@ public class OldMultiLeaderboard extends Composite {
fullscreenAnchor.setTitle(StringMessages.INSTANCE.openFullscreenView());
this.delegate = delegate;
this.setupFullscreenDelegate();
lastSelectedLeaderboardPanel = null;
}
private void setupFullscreenDelegate() {
@@ -163,6 +170,7 @@ public class OldMultiLeaderboard extends Composite {
public void setMultiLeaderboard(MultiLeaderboardPanel multiLeaderboardPanel, final Timer timer) {
this.autoRefreshTimer = timer;
this.multiLeaderboardPanel = multiLeaderboardPanel;
this.multiLeaderboardPanel.addSelectedLeaderboardChangeListener(this);
oldMultiLeaderboardPanel.add(multiLeaderboardPanel);
}
@@ -198,6 +206,23 @@ public class OldMultiLeaderboard extends Composite {
}
}
}
@Override
public void onBusyStateChange(boolean busyState) {
busyIndicator.setBusy(busyState);
if(delegate != null) {
delegate.setBusyState(busyState);
}
}
@Override
public void onSelectedLeaderboardChanged(LeaderboardPanel selectedLeaderboard) {
if(lastSelectedLeaderboardPanel != null) {
lastSelectedLeaderboardPanel.removeBusyStateChangeListener(this);
}
selectedLeaderboard.addBusyStateChangeListener(this);
lastSelectedLeaderboardPanel = selectedLeaderboard;
}
public interface OldMultiLeaderboardDelegate extends LeaderboardDelegate<MultiLeaderboardPanel>{
}
@@ -1,23 +1,25 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:c="urn:import:com.sap.sse.gwt.client.controls.busyindicator">
<ui:with field="i18n" type="com.sap.sailing.gwt.common.client.i18n.TextMessages"/>
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
<ui:with field="local_res" type="com.sap.sailing.gwt.home.desktop.partials.old.EventRegattaLeaderboardResources" />
<g:HTMLPanel styleName=" {local_res.css.marginFix}">
<div class="{res.mediaCss.grid}">
<div class="{res.mediaCss.small6} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_scoring}">
<p ui:field="lastScoringCommentDiv" class="{local_res.css.regattaleaderboard_meta_scoring_comment}"></p>
<p ui:field="scoringSchemeDiv" class="{local_res.css.regattaleaderboard_meta_scoring_type}"></p>
<div ui:field="lastScoringCommentDiv" class="{local_res.css.regattaleaderboard_meta_scoring_comment}"></div>
<div ui:field="scoringSchemeDiv" class="{local_res.css.regattaleaderboard_meta_scoring_type}"></div>
</div>
<div class="{res.mediaCss.small6} {res.mediaCss.column} {local_res.css.regattaleaderboard_meta_settings}">
<c:SimpleBusyIndicator addStyleNames="{local_res.css.regattaleaderboard_meta_busyindicator}" ui:field="busyIndicator"/>
<div class="{local_res.css.regattaleaderboard_meta_update}">
<p ui:field="lastScoringUpdateTextDiv" class="{local_res.css.regattaleaderboard_meta_update_text}"></p>
<p ui:field="lastScoringUpdateTimeDiv" class="{local_res.css.regattaleaderboard_meta_update_timestamp}"></p>
<div ui:field="lastScoringUpdateTextDiv" class="{local_res.css.regattaleaderboard_meta_update_text}"></div>
<div ui:field="lastScoringUpdateTimeDiv" class="{local_res.css.regattaleaderboard_meta_update_timestamp}"></div>
</div>
<g:Anchor ui:field="autoRefreshAnchor" href="javascript:;" styleName="{res.mainCss.button} {local_res.css.regattaleaderboard_meta_reload}"></g:Anchor>
<g:Anchor ui:field="settingsAnchor" href="javascript:;" styleName="{res.mainCss.button} {local_res.css.regattaleaderboard_meta_settings_button}"></g:Anchor>
<g:Anchor ui:field="fullscreenAnchor" href="javascript:;" styleName="{res.mainCss.button} {local_res.css.regattaleaderboard_meta_fullscreen_button}"></g:Anchor>
</div>
</div>
</div>
<div class="{res.mediaCss.grid}">
@@ -8,7 +8,8 @@ public class BusyViewImpl extends Composite implements BusyView {
public BusyViewImpl() {
BusyViewResources.INSTANCE.css().ensureInjected();
initWidget(new SimpleBusyIndicator(true, 1.0f, "", BusyViewResources.INSTANCE.css().busy()));
SimpleBusyIndicator busyIndicator = new SimpleBusyIndicator(true, 1.0f);
busyIndicator.setImageStyleClass(BusyViewResources.INSTANCE.css().busy());
initWidget(busyIndicator);
}
}
@@ -37,6 +37,7 @@ public class FullscreenContainer<T extends Widget> {
String popup();
String toolbarInfo();
String toolbarAction();
String toolbarBusyIndicator();
String content();
String contentBorder();
}
@@ -88,7 +89,12 @@ public class FullscreenContainer<T extends Widget> {
widget.addStyleName(style.toolbarAction());
toolbarUi.add(widget);
}
public void addToolbarBusyIndicator(Widget widget) {
widget.addStyleName(style.toolbarBusyIndicator());
toolbarUi.add(widget);
}
public void addToolbarInfo(Widget widget) {
widget.addStyleName(style.toolbarInfo());
toolbarUi.add(widget);
@@ -50,6 +50,13 @@
cursor: pointer;
padding: 10px;
}
.toolbarBusyIndicator {
display: inline-block;
height: 50px;
width: auto;
padding: 10px;
vertical-align: top;
}
.toolbarAction:hover {
background-color: #d79900;
}
@@ -83,7 +83,9 @@ public abstract class AbstractRaceChart extends AbsolutePanel implements RaceSel
timeRangeWithZoomProvider.addTimeZoomChangeListener(this);
timeRangeWithZoomProvider.addTimeRangeChangeListener(this);
chartsCss.ensureInjected();
busyIndicator = new SimpleBusyIndicator(/* busy */ true, 2.0f, chartsCss.busyIndicatorStyle(), chartsCss.busyIndicatorImageStyle());
busyIndicator = new SimpleBusyIndicator(/* busy */ true, 2.0f);
busyIndicator.setPanelStyleClass(chartsCss.busyIndicatorStyle());
busyIndicator.setImageStyleClass(chartsCss.busyIndicatorImageStyle());
settingsButton = createSettingsButton();
settingsButton.setStyleName(chartsCss.settingsButtonStyle());
settingsButton.addStyleName(chartsCss.settingsButtonBackgroundImage());
@@ -149,15 +149,15 @@ public abstract class ExpandableSortableColumn<C> extends LeaderboardSortableCol
*/
public void toggleExpansion() {
if (isExpansionEnabled()) {
final boolean oldBusyState = getLeaderboardPanel().getBusyIndicator().isBusy();
getLeaderboardPanel().getBusyIndicator().setBusy(true);
final boolean oldBusyState = getLeaderboardPanel().isBusy();
getLeaderboardPanel().setBusyState(true);
setTogglingInProcess(true);
final CellTable<LeaderboardRowDTO> table = getLeaderboardPanel().getLeaderboardTable();
if (isExpanded()) {
for (AbstractSortableColumnWithMinMax<LeaderboardRowDTO, ?> column : getAllVisibleChildren()) {
getLeaderboardPanel().removeColumn(column); // removes only the children currently displayed
}
getLeaderboardPanel().getBusyIndicator().setBusy(false);
getLeaderboardPanel().setBusyState(false);
setTogglingInProcess(false);
// important: toggle expanded state after asking for all visible children
setExpanded(!isExpanded());
@@ -177,7 +177,7 @@ public abstract class ExpandableSortableColumn<C> extends LeaderboardSortableCol
}
getLeaderboardPanel().getLeaderboardTable().redraw();
}
getLeaderboardPanel().getBusyIndicator().setBusy(oldBusyState);
getLeaderboardPanel().setBusyState(oldBusyState);
setTogglingInProcess(false);
}
});
@@ -102,6 +102,8 @@ import com.sap.sse.gwt.client.ErrorReporter;
import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
import com.sap.sse.gwt.client.async.MarkedAsyncCallback;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
import com.sap.sse.gwt.client.controls.busyindicator.BusyStateChangeListener;
import com.sap.sse.gwt.client.controls.busyindicator.BusyStateProvider;
import com.sap.sse.gwt.client.controls.busyindicator.SimpleBusyIndicator;
import com.sap.sse.gwt.client.player.PlayStateListener;
import com.sap.sse.gwt.client.player.TimeListener;
@@ -122,7 +124,8 @@ import com.sap.sse.gwt.client.useragent.UserAgentDetails;
*
*/
public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayStateListener, DisplayedLeaderboardRowsProvider,
Component<LeaderboardSettings>, IsEmbeddableComponent, CompetitorSelectionChangeListener, LeaderboardFetcher {
Component<LeaderboardSettings>, IsEmbeddableComponent, CompetitorSelectionChangeListener, LeaderboardFetcher,
BusyStateProvider {
public static final String LOAD_LEADERBOARD_DATA_CATEGORY = "loadLeaderboardData";
protected static final NumberFormat scoreFormat = NumberFormat.getFormat("0.##");
@@ -296,6 +299,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
private ImageResource playIcon;
private final BusyIndicator busyIndicator;
private final Set<BusyStateChangeListener> busyStateChangeListeners;
/**
* Tells whether the leaderboard settings were explicitly changed by an external call to
@@ -477,8 +481,8 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
break;
}
final boolean oldBusyState = getBusyIndicator().isBusy();
getBusyIndicator().setBusy(true);
final boolean oldBusyState = isBusy();
setBusyState(true);
Runnable doWhenNecessaryDetailHasBeenLoaded = new Runnable() {
@Override
public void run() {
@@ -501,7 +505,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
getLeaderboardTable().sortColumn(raceColumnByRaceName, /* ascending */true);
}
}
getBusyIndicator().setBusy(oldBusyState);
setBusyState(oldBusyState);
}
};
if (oldShallAddOverallDetails == shallAddOverallDetails() || oldShallAddOverallDetails || getLeaderboard().hasOverallDetails()) {
@@ -668,7 +672,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
CompetitorDTO competitor = competitorFetcher.getCompetitor(object);
final String twoLetterIsoCountryCode = competitor.getTwoLetterIsoCountryCode();
final String flagImageURL = competitor.getFlagImageURL();
boolean showBoatColor = !isShowCompetitorFullName() && LeaderboardPanel.this.isEmbedded && preSelectedRace != null;
if (showBoatColor) {
String competitorColor = LeaderboardPanel.this.competitorSelectionProvider.getColor(
@@ -1834,7 +1838,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
contentPanel.setStyleName(STYLE_LEADERBOARD_CONTENT);
busyIndicator = new SimpleBusyIndicator(false, 0.8f);
busyIndicator.ensureDebugId("BusyIndicator");
busyStateChangeListeners = new HashSet<>();
// the information panel
if (!isEmbedded) {
@@ -1930,7 +1934,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
filterClearButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
getBusyIndicator().setBusy(true);
setBusyState(true);
competitorFilterPanel.clearAllActiveFilters();
timeChanged(new Date(), null);
}
@@ -2247,19 +2251,19 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
@Override
public void onSuccess(LeaderboardDTO result) {
updateLeaderboard(result);
getBusyIndicator().setBusy(false);
setBusyState(false);
}
@Override
public void onFailure(Throwable caught) {
getBusyIndicator().setBusy(false);
setBusyState(false);
getErrorReporter()
.reportError("Error trying to obtain leaderboard contents: " + caught.getMessage(),
true /* silentMode */);
}
});
} else {
getBusyIndicator().setBusy(false);
setBusyState(false);
}
}
@@ -2415,7 +2419,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
liveRaceLabel.setVisible(hasLiveRace);
}
informLeaderboardUpdateListenersAboutLeaderboardUpdated(leaderboard);
getBusyIndicator().setBusy(false);
setBusyState(false);
}
}
@@ -3137,16 +3141,6 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
leaderboardSelectionModel.setSelected(row, false);
}
}
@Override
public BusyIndicator getBusyIndicator() {
return busyIndicator;
}
@Override
public boolean hasBusyIndicator() {
return true;
}
private Iterable<LeaderboardRowDTO> getSelectedRows() {
return leaderboardSelectionModel.getSelectedSet();
@@ -3270,4 +3264,29 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
public String getDependentCssClassName() {
return "leaderboard";
}
@Override
public void addBusyStateChangeListener(BusyStateChangeListener listener) {
busyStateChangeListeners.add(listener);
}
@Override
public void removeBusyStateChangeListener(BusyStateChangeListener listener) {
busyStateChangeListeners.remove(listener);
}
@Override
public boolean isBusy() {
return busyIndicator.isBusy();
}
@Override
public void setBusyState(boolean isBusy) {
if (busyIndicator.isBusy() != isBusy) {
busyIndicator.setBusy(isBusy);
for (BusyStateChangeListener listener : busyStateChangeListeners) {
listener.onBusyStateChange(isBusy);
}
}
}
}
@@ -3,8 +3,10 @@ package com.sap.sailing.gwt.ui.leaderboard;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style.FontWeight;
@@ -35,7 +37,7 @@ import com.sap.sse.gwt.client.useragent.UserAgentDetails;
* A panel managing multiple {@link LeaderboardPanel}s (e.g. from a meta leaderboard) so that the user can switch between them.
* @author Frank
*/
public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSettings> implements TimeListener {
public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSettings> implements TimeListener, SelectedLeaderboardChangeProvider {
private LeaderboardPanel selectedLeaderboardPanel;
private FlowPanel selectedLeaderboardFlowPanel;
@@ -60,7 +62,8 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
private final String metaLeaderboardName;
private final boolean isEmbedded;
private List<LeaderboardUpdateListener> leaderboardUpdateListener;
private final Set<LeaderboardUpdateListener> leaderboardUpdateListeners;
private final Set<SelectedLeaderboardChangeListener> selectedLeaderboardChangeListeners;
public MultiLeaderboardPanel(SailingServiceAsync sailingService, String metaLeaderboardName, AsyncActionsExecutor asyncActionsExecutor,
Timer timer, boolean isEmbedded, String preselectedLeaderboardName, RaceIdentifier preselectedRace,
@@ -81,7 +84,8 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
selectedLeaderboardPanel = null;
leaderboardNamesAndDisplayNames = new ArrayList<Util.Pair<String, String>>();
leaderboardNamesAndSettings = new HashMap<String, LeaderboardSettings>();
leaderboardUpdateListener = new ArrayList<LeaderboardUpdateListener>();
leaderboardUpdateListeners = new HashSet<LeaderboardUpdateListener>();
selectedLeaderboardChangeListeners = new HashSet<SelectedLeaderboardChangeListener>();
}
private LeaderboardSettings getOrCreateLeaderboardSettings(String leaderboardName, LeaderboardSettings currentLeaderboardSettings) {
@@ -152,7 +156,7 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
}
public void addLeaderboardUpdateListener(LeaderboardUpdateListener listener) {
this.leaderboardUpdateListener.add(listener);
this.leaderboardUpdateListeners.add(listener);
}
public void setLeaderboardNames(List<Util.Pair<String, String>> newLeaderboardNamesAndDisplayNames) {
@@ -177,6 +181,10 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
});
}
// public LeaderboardPanel getSelectedLeaderboardPanel() {
// return selectedLeaderboardPanel;
// }
//
private void updateLeaderboardSelection() {
if(leaderboardsTabPanel != null) {
leaderboardsTabPanel.clear();
@@ -215,16 +223,16 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
selectedLeaderboardFlowPanel = (FlowPanel) leaderboardsTabPanel.getWidget(newTabIndex);
LeaderboardSettings newLeaderboardSettings = getOrCreateLeaderboardSettings(newSelectedLeaderboardName, leaderboardNamesAndSettings.get(selectedLeaderboardName));
selectedLeaderboardPanel = new LeaderboardPanel(sailingService, asyncActionsExecutor, newLeaderboardSettings, isEmbedded,
LeaderboardPanel newSelectedLeaderboardPanel = new LeaderboardPanel(sailingService, asyncActionsExecutor, newLeaderboardSettings, isEmbedded,
/* preselectedRace*/ null, new CompetitorSelectionModel(true), timer,
null, newSelectedLeaderboardName, errorReporter, stringMessages, userAgent,
showRaceDetails, /* competitorSearchTextBox */ null, /* showSelectionCheckbox */ true, /* raceTimesInfoProvider */null,
false, /* adjustTimerDelay */ true, /*autoApplyTopNFilter*/ false, false);
selectedLeaderboardFlowPanel.add(selectedLeaderboardPanel);
for(LeaderboardUpdateListener listener: leaderboardUpdateListener) {
selectedLeaderboardPanel.addLeaderboardUpdateListener(listener);
selectedLeaderboardFlowPanel.add(newSelectedLeaderboardPanel);
for(LeaderboardUpdateListener listener: leaderboardUpdateListeners) {
newSelectedLeaderboardPanel.addLeaderboardUpdateListener(listener);
}
setSelectedLeaderboard(newSelectedLeaderboardPanel);
} else {
if(selectedLeaderboardPanel != null && selectedLeaderboardFlowPanel != null) {
selectedLeaderboardPanel.removeAllListeners();
@@ -254,4 +262,23 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
}
}
@Override
public void addSelectedLeaderboardChangeListener(SelectedLeaderboardChangeListener listener) {
selectedLeaderboardChangeListeners.add(listener);
}
@Override
public void removeSelectedLeaderboardChangeListener(SelectedLeaderboardChangeListener listener) {
selectedLeaderboardChangeListeners.remove(listener);
}
@Override
public void setSelectedLeaderboard(LeaderboardPanel selectedLeaderboard) {
if(this.selectedLeaderboardPanel != selectedLeaderboard) {
this.selectedLeaderboardPanel = selectedLeaderboard;
for (SelectedLeaderboardChangeListener listener : selectedLeaderboardChangeListeners) {
listener.onSelectedLeaderboardChanged(selectedLeaderboardPanel);
}
}
}
}
@@ -0,0 +1,14 @@
package com.sap.sailing.gwt.ui.leaderboard;
/**
* Allows UI components to observe a change of the selected leaderboard in a Multi-Leaderboard scenario.
*/
public interface SelectedLeaderboardChangeListener {
/**
* @param selectedLeaderboard the selected non-<code>null</code> LeaderboardPanel
*/
void onSelectedLeaderboardChanged(LeaderboardPanel selectedLeaderboard);
}
@@ -0,0 +1,11 @@
package com.sap.sailing.gwt.ui.leaderboard;
public interface SelectedLeaderboardChangeProvider {
void addSelectedLeaderboardChangeListener(SelectedLeaderboardChangeListener listener);
void removeSelectedLeaderboardChangeListener(SelectedLeaderboardChangeListener listener);
void setSelectedLeaderboard(LeaderboardPanel selectedLeaderboard);
}
@@ -319,13 +319,13 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
final RowUpdateWhiteboard<LeaderboardRowDTO> whiteboard = new RowUpdateWhiteboard<LeaderboardRowDTO>(
EditableLeaderboardPanel.this.getData());
getWhiteboardOwner().whiteboardProduced(whiteboard);
getBusyIndicator().setBusy(true);
setBusyState(true);
getSailingService().updateLeaderboardMaxPointsReason(getLeaderboardName(), row.competitor.getIdAsString(),
raceColumnName, value == null || value.trim().length() == 0 ? null : MaxPointsReason.valueOf(value.trim()),
getLeaderboardDisplayDate(), new AsyncCallback<Util.Triple<Double, Double, Boolean>>() {
@Override
public void onFailure(Throwable t) {
getBusyIndicator().setBusy(false);
setBusyState(false);
getErrorReporter().reportError(
"Error trying to update max points reason for competitor "
+ row.competitor.getName() + " in leaderboard " + getLeaderboardName()
@@ -334,7 +334,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
@Override
public void onSuccess(Util.Triple<Double, Double, Boolean> newNetAndTotalPointsAndIsCorrected) {
getBusyIndicator().setBusy(false);
setBusyState(false);
row.fieldsByRaceColumnName.get(raceColumnName).reasonForMaxPoints = value == null
|| value.length() == 0 ? null : MaxPointsReason.valueOf(value.trim());
row.fieldsByRaceColumnName.get(raceColumnName).netPoints = newNetAndTotalPointsAndIsCorrected.getA();
@@ -444,14 +444,14 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
final RowUpdateWhiteboard<LeaderboardRowDTO> whiteboard = new RowUpdateWhiteboard<LeaderboardRowDTO>(
EditableLeaderboardPanel.this.getData());
getWhiteboardOwner().whiteboardProduced(whiteboard);
getBusyIndicator().setBusy(true);
setBusyState(true);
getSailingService().updateLeaderboardScoreCorrection(getLeaderboardName(), row.competitor.getIdAsString(), raceColumnName,
value == null || value.trim().length() == 0 ? null : value.trim().equals("n/a") ? null
: Double.valueOf(value.trim()), getLeaderboardDisplayDate(),
new AsyncCallback<Util.Triple<Double, Double, Boolean>>() {
@Override
public void onFailure(Throwable t) {
getBusyIndicator().setBusy(false);
setBusyState(false);
getErrorReporter().reportError("Error trying to update score correction for competitor "+
row.competitor.getName()+" in leaderboard "+getLeaderboardName()+
" for race "+raceColumnName+": "+t.getMessage()+
@@ -460,7 +460,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
@Override
public void onSuccess(Util.Triple<Double, Double, Boolean> newNetAndTotalPointsAndIsCorrected) {
getBusyIndicator().setBusy(false);
setBusyState(false);
final LeaderboardEntryDTO leaderboardEntryDTO = row.fieldsByRaceColumnName.get(raceColumnName);
leaderboardEntryDTO.netPoints = value == null || value.length() == 0 ? newNetAndTotalPointsAndIsCorrected
.getA() : Double.valueOf(value.trim());
@@ -523,13 +523,13 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
row.fieldsByRaceColumnName.get(raceColumnName).netPoints, new DialogCallback<Util.Pair<MaxPointsReason, Double>>() {
@Override
public void ok(final Util.Pair<MaxPointsReason, Double> editedObject) {
getBusyIndicator().setBusy(true);
setBusyState(true);
getSailingService().updateLeaderboardScoreCorrection(getLeaderboardName(), row.competitor.getIdAsString(), raceColumnName,
editedObject.getB(), getLeaderboardDisplayDate(),
new AsyncCallback<Util.Triple<Double, Double, Boolean>>() {
@Override
public void onFailure(Throwable t) {
getBusyIndicator().setBusy(false);
setBusyState(false);
getErrorReporter().reportError("Error trying to update score correction for competitor "+
row.competitor.getName()+" in leaderboard "+getLeaderboardName()+
" for race "+raceColumnName+": "+t.getMessage()+
@@ -543,7 +543,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
new AsyncCallback<Util.Triple<Double, Double, Boolean>>() {
@Override
public void onFailure(Throwable t) {
getBusyIndicator().setBusy(false);
setBusyState(false);
getErrorReporter().reportError("Error trying to update score correction for competitor "+
row.competitor.getName()+" in leaderboard "+getLeaderboardName()+
" for race "+raceColumnName+": "+t.getMessage()+
@@ -552,7 +552,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
@Override
public void onSuccess(Util.Triple<Double, Double, Boolean> newNetAndTotalPointsAndIsCorrected) {
getBusyIndicator().setBusy(false);
setBusyState(false);
final LeaderboardEntryDTO leaderboardEntryDTO = row.fieldsByRaceColumnName.get(raceColumnName);
leaderboardEntryDTO.reasonForMaxPoints = editedObject.getA();
leaderboardEntryDTO.netPoints = newNetAndTotalPointsAndIsCorrected.getA();
@@ -409,11 +409,11 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<BulkSco
@Override
public void ok(final BulkScoreCorrectionDTO result) {
leaderboardPanel.getBusyIndicator().setBusy(true);
leaderboardPanel.setBusyState(true);
sailingService.updateLeaderboardScoreCorrectionsAndMaxPointsReasons(result, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
leaderboardPanel.getBusyIndicator().setBusy(false);
leaderboardPanel.setBusyState(false);
errorReporter.reportError(stringMessages.errorUpdatingScoresForLeaderboard(result.getLeaderboardName(),
caught.getMessage()));
}
@@ -214,19 +214,19 @@ public class ResultSelectionAndApplyDialog extends DataEntryDialog<Util.Triple<S
final String eventName = providerNameAndEventNameBoatClassNameCapturedWhen.getB();
final String boatClassName = providerNameAndEventNameBoatClassNameCapturedWhen.getC().getA();
final Date timePointWhenResultPublished = providerNameAndEventNameBoatClassNameCapturedWhen.getC().getB();
leaderboardPanel.getBusyIndicator().setBusy(true);
leaderboardPanel.setBusyState(true);
sailingService.getScoreCorrections(scoreCorrectionProviderName, eventName, boatClassName, timePointWhenResultPublished,
new AsyncCallback<RegattaScoreCorrectionDTO>() {
@Override
public void onFailure(Throwable caught) {
leaderboardPanel.getBusyIndicator().setBusy(false);
leaderboardPanel.setBusyState(false);
errorReporter.reportError(stringMessages.errorObtainingScoreCorrections(scoreCorrectionProviderName,
eventName, boatClassName, timePointWhenResultPublished.toString(), caught.getMessage()));
}
@Override
public void onSuccess(RegattaScoreCorrectionDTO result) {
leaderboardPanel.getBusyIndicator().setBusy(false);
leaderboardPanel.setBusyState(false);
new MatchAndApplyScoreCorrectionsDialog(leaderboardPanel, stringMessages, sailingService,
errorReporter, result).show();
}
@@ -7,4 +7,7 @@ public interface BusyIndicatorResources extends ClientBundle {
@Source("busy_indicator_circle.gif")
ImageResource busyIndicatorCircle();
@Source("busy_indicator_circle_inverted.gif")
ImageResource busyIndicatorCircleInverted();
}
@@ -0,0 +1,14 @@
package com.sap.sse.gwt.client.controls.busyindicator;
/**
* Allows UI components to observe the busy state of an operation.
*/
public interface BusyStateChangeListener {
/**
* @param busyState the new busy state
*/
void onBusyStateChange(boolean busyState);
}
@@ -0,0 +1,13 @@
package com.sap.sse.gwt.client.controls.busyindicator;
public interface BusyStateProvider {
void addBusyStateChangeListener(BusyStateChangeListener listener);
void removeBusyStateChangeListener(BusyStateChangeListener listener);
void setBusyState(boolean isBusy);
boolean isBusy();
}
@@ -1,5 +1,6 @@
package com.sap.sse.gwt.client.controls.busyindicator;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Image;
@@ -12,9 +13,13 @@ public class SimpleBusyIndicator extends BusyIndicator {
* The busy indicator component is a circling GIF.
*/
public SimpleBusyIndicator() {
this(false, 1.0f);
this(false, 1.0f, RESOURCES.busyIndicatorCircle());
}
public SimpleBusyIndicator(ImageResource imageResource) {
this(false, 1.0f, imageResource);
}
/**
* Creates a new SimpleBusyIndicator with a custom <code>busy</code> state.<br />
* The busy indicator component is a circling GIF.
@@ -23,22 +28,29 @@ public class SimpleBusyIndicator extends BusyIndicator {
* @param scale Scales the displayed image. 1.0 is 100%, 0.50 is 50%, ...
*/
public SimpleBusyIndicator(boolean busy, float scale) {
this(busy, scale, STYLE_NAME_PREFIX + "Simple", STYLE_NAME_PREFIX + "Circle");
this(busy, scale, RESOURCES.busyIndicatorCircle());
}
public SimpleBusyIndicator(boolean busy, float scale, String panelCssClass, String imageCssClass) {
this.setStyleName(panelCssClass);
ImageResource resource = RESOURCES.busyIndicatorCircle();
busyIndicator = new Image(resource.getSafeUri());
busyIndicator.setStyleName(imageCssClass);
busyIndicator.setPixelSize((int) (resource.getWidth() * scale), (int) (resource.getHeight() * scale));
public SimpleBusyIndicator(boolean busy, float scale, ImageResource imageResource) {
this.setStyleName(STYLE_NAME_PREFIX + "Simple");
busyIndicator = new Image(imageResource.getSafeUri());
busyIndicator.setStyleName(STYLE_NAME_PREFIX + "Circle");
busyIndicator.setPixelSize((int) (imageResource.getWidth() * scale), (int) (imageResource.getHeight() * scale));
add(busyIndicator);
setBusy(busy);
}
public void setPanelStyleClass(String panelCssClass) {
this.setStyleName(panelCssClass);
}
public void setImageStyleClass(String imageCssClass) {
busyIndicator.setStyleName(imageCssClass);
}
@Override
public void setBusy(boolean busy) {
super.setBusy(busy);
busyIndicator.setVisible(busy);
busyIndicator.getElement().getStyle().setVisibility(busy ? Visibility.VISIBLE : Visibility.HIDDEN);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

@@ -1,7 +1,6 @@
package com.sap.sse.gwt.client.shared.components;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
public interface IsEmbeddableComponent {
@@ -13,11 +12,7 @@ public interface IsEmbeddableComponent {
Widget getLegendWidget();
BusyIndicator getBusyIndicator();
boolean isEmbedded();
boolean hasToolbar();
boolean hasBusyIndicator();
}