moved some autoplay settings to LeaderboardPerspectiveSettings

Passed the perspective settings to the PlayerPlace and AutoPlayController
This commit is contained in:
fmittag committed 2015-12-09 17:05:39 +01:00
1 parent e621a04259
commit 95b8ed79e9
13 files changed
+267 -93

No files matched your search

@@ -1,8 +1,13 @@
package com.sap.sailing.gwt.autoplay.client.app;
import com.sap.sailing.gwt.autoplay.client.place.player.AutoPlayerConfiguration;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPerspectiveSettings;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
public interface PlaceNavigator {
void goToStart();
void goToPlayer(AutoPlayerConfiguration playerConfig);
void goToPlayer(AutoPlayerConfiguration playerConfig, Pair<LeaderboardPerspectiveSettings, CompositeSettings> leaderboardPerspectiveSettings,
Pair<RaceBoardPerspectiveSettings, CompositeSettings> raceboardPerspectiveSettings);
}
@@ -4,6 +4,10 @@ import com.google.gwt.place.shared.PlaceController;
import com.sap.sailing.gwt.autoplay.client.place.player.AutoPlayerConfiguration;
import com.sap.sailing.gwt.autoplay.client.place.player.PlayerPlace;
import com.sap.sailing.gwt.autoplay.client.place.start.StartPlace;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPerspectiveSettings;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
public class PlaceNavigatorImpl implements PlaceNavigator {
private final PlaceController placeController;
@@ -19,8 +23,9 @@ public class PlaceNavigatorImpl implements PlaceNavigator {
}
@Override
public void goToPlayer(AutoPlayerConfiguration playerConfig) {
PlayerPlace playerPlace = new PlayerPlace(playerConfig);
public void goToPlayer(AutoPlayerConfiguration playerConfig, Pair<LeaderboardPerspectiveSettings, CompositeSettings> leaderboardPerspectiveSettings,
Pair<RaceBoardPerspectiveSettings, CompositeSettings> raceboardPerspectiveSettings) {
PlayerPlace playerPlace = new PlayerPlace(playerConfig, leaderboardPerspectiveSettings, raceboardPerspectiveSettings);
placeController.goTo(playerPlace);
}
@@ -35,8 +35,8 @@ import com.sap.sailing.gwt.ui.client.RaceTimesInfoProviderListener;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPanel;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPerspectiveSettings;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettings;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettingsFactory;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPanel;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
@@ -76,7 +76,8 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
private RegattaAndRaceIdentifier currentLiveRace;
private boolean showRaceDetails;
private boolean showWindChart;
private final RaceBoardPerspectiveSettings raceboardViewConfig;
private final RaceBoardPerspectiveSettings raceboardPerspectiveSettings;
private final LeaderboardPerspectiveSettings leaderboardPerspectiveSettings;
private final PlayerView playerView;
private final AutoPlayerConfiguration autoPlayerConfiguration;
private Widget currentContentWidget;
@@ -86,8 +87,10 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
public AutoPlayController(SailingServiceAsync sailingService, MediaServiceAsync mediaService,
UserService userService, ErrorReporter errorReporter, AutoPlayerConfiguration autoPlayerConfiguration,
UserAgentDetails userAgent, long delayToLiveInMillis, boolean showRaceDetails,
RaceBoardPerspectiveSettings raceboardViewConfig, PlayerView playerView, LeaderboardSettings leaderboardSettings) {
this.raceboardViewConfig = raceboardViewConfig;
RaceBoardPerspectiveSettings raceboardPerspectiveSettings, PlayerView playerView,
LeaderboardPerspectiveSettings leaderboardPerspectiveSettings) {
this.raceboardPerspectiveSettings = raceboardPerspectiveSettings;
this.leaderboardPerspectiveSettings = leaderboardPerspectiveSettings;
this.sailingService = sailingService;
this.mediaService = mediaService;
this.userService = userService;
@@ -96,12 +99,11 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
this.userAgent = userAgent;
this.showRaceDetails = showRaceDetails;
this.playerView = playerView;
this.leaderboardSettings = leaderboardSettings;
if(this.leaderboardSettings == null) {
leaderboardSettings = LeaderboardSettingsFactory.getInstance().createNewDefaultSettings(null, null, null, /* autoExpandFirstRace */ false, /* showRegattaRank */ true, /* showCompetitorSailIdColumn */ true, /* showCompetitorFullNameColumn */ true);
}
// if(this.leaderboardSettings == null) {
// leaderboardSettings = LeaderboardSettingsFactory.getInstance().createNewDefaultSettings(null, null, null, /* autoExpandFirstRace */ false, /* showRegattaRank */ true, /* showCompetitorSailIdColumn */ true, /* showCompetitorFullNameColumn */ true);
// }
//
asyncActionsExecutor = new AsyncActionsExecutor();
showWindChart = false;
leaderboard = null;
@@ -120,8 +122,7 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
String leaderboardZoom = AutoPlayController.this.autoPlayerConfiguration.getLeaderboardZoom();
if(leaderboardZoom != null && leaderboardZoom.equalsIgnoreCase("auto")) {
if(AutoPlayController.this.leaderboardPerspectiveSettings.isLeaderboardAutoZoom()) {
autoZoomContentWidget(SAP_HEADER_HEIGHT, currentContentWidget);
}
}
@@ -168,7 +169,7 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
List<RegattaAndRaceIdentifier> singletonList = Collections.singletonList(raceToShow);
raceSelectionModel.setSelection(singletonList);
RaceBoardPanel raceBoardPanel = new RaceBoardPanel(sailingService, mediaService, userService, asyncActionsExecutor,
competitorsAndTheirBoats, raceboardTimer, raceSelectionModel, leaderboardName, null, /* event */ null, raceboardViewConfig,
competitorsAndTheirBoats, raceboardTimer, raceSelectionModel, leaderboardName, null, /* event */ null, raceboardPerspectiveSettings,
errorReporter, StringMessages.INSTANCE, userAgent, raceTimesInfoProvider, /* showMapControls */ false,
/* isScreenLargeEnoughToOfferChartSupport */ true);
return raceBoardPanel;
@@ -189,17 +190,11 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
currentContentWidget = oldLeaderboard.getContentWidget();
if(autoPlayerConfiguration.getLeaderboardZoom() != null) {
if(autoPlayerConfiguration.getLeaderboardZoom().equalsIgnoreCase("auto")) {
if(leaderboardPerspectiveSettings.isLeaderboardAutoZoom()) {
autoZoomContentWidget(SAP_HEADER_HEIGHT, currentContentWidget);
} else {
try {
Double zoom = Double.valueOf(autoPlayerConfiguration.getLeaderboardZoom());
Double zoom = leaderboardPerspectiveSettings.getLeaderboardZoomFactor();
zoomContentWidget(SAP_HEADER_HEIGHT, currentContentWidget, zoom);
} catch (NumberFormatException e) {
// do nothing
}
}
}
playerView.getDockPanel().add(oldLeaderboard);
@@ -5,19 +5,15 @@ public class AutoPlayerConfiguration {
public final static String PARAM_EVENTID = "eventId";
public final static String PARAM_FULLSCREEN = "fullscreen";
public final static String PARAM_LEADEROARD_NAME = "leaderboardName";
public final static String PARAM_LEADEROARD_ZOOM = "leaderboardZoom";
private String eventUidAsString;
private String leaderboardName;
private boolean fullscreenMode;
private String leaderboardZoom;
public AutoPlayerConfiguration(String eventUidAsString, String leaderboardName, boolean fullscreenMode,
String leaderboardZoom) {
public AutoPlayerConfiguration(String eventUidAsString, String leaderboardName, boolean fullscreenMode) {
this.eventUidAsString = eventUidAsString;
this.leaderboardName = leaderboardName;
this.fullscreenMode = fullscreenMode;
this.leaderboardZoom = leaderboardZoom;
}
public String getEventUidAsString() {
@@ -31,8 +27,4 @@ public class AutoPlayerConfiguration {
public boolean isFullscreenMode() {
return fullscreenMode;
}
public String getLeaderboardZoom() {
return leaderboardZoom;
}
}
@@ -8,7 +8,6 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sse.gwt.client.mvp.ErrorView;
import com.sap.sse.gwt.client.useragent.UserAgentDetails;
@@ -39,7 +38,7 @@ public class PlayerActivity extends AbstractActivity {
@Override
public void onSuccess(final EventDTO event) {
UserAgentDetails userAgent = new UserAgentDetails(Window.Navigator.getUserAgent());
RaceBoardPerspectiveSettings readRaceboardConfiguration = readRaceboardConfiguration();
//RaceBoardPerspectiveSettings readRaceboardConfiguration = readRaceboardConfiguration();
PlayerView view = clientFactory.createPlayerView();
panel.setWidget(view.asWidget());
@@ -48,7 +47,7 @@ public class PlayerActivity extends AbstractActivity {
autoPlayController = new AutoPlayController(clientFactory.getSailingService(), clientFactory
.getMediaService(), clientFactory.getUserService(), clientFactory.getErrorReporter(),
playerPlace.getConfiguration(), userAgent, delayToLiveMillis, showRaceDetails,
readRaceboardConfiguration, view, /** TODO: pass leaderboardSettings*/ null);
playerPlace.getRaceboardPerspectiveSettings().getA(), view, /** TODO: pass leaderboardSettings*/ null);
autoPlayController.updatePlayMode(AutoPlayModes.Leaderboard);
}
@@ -59,27 +58,27 @@ public class PlayerActivity extends AbstractActivity {
});
}
private RaceBoardPerspectiveSettings readRaceboardConfiguration() {
Boolean autoSelectMedia = true;
final boolean showLeaderboard = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_LEADERBOARD, true /* default */);
final boolean showWindChart = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_WINDCHART, false /* default */);
final boolean showViewStreamlets = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_STREAMLETS, false /* default */);
final boolean showViewStreamletColors = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_STREAMLET_COLORS, false /* default */);
final boolean showViewSimulation = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_SIMULATION, false /* default */);
final boolean showCompetitorsChart = GwtHttpRequestUtils.getBooleanParameter(
RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_COMPETITORSCHART, false /* default */);
String activeCompetitorsFilterSetName = GwtHttpRequestUtils.getStringParameter(RaceBoardPerspectiveSettings.PARAM_VIEW_COMPETITOR_FILTER, null /* default*/);
final String defaultMedia = GwtHttpRequestUtils.getStringParameter(RaceBoardPerspectiveSettings.PARAM_DEFAULT_MEDIA, null /* default */);
return new RaceBoardPerspectiveSettings(activeCompetitorsFilterSetName, showLeaderboard,
showWindChart, showCompetitorsChart, showViewStreamlets, showViewStreamletColors, showViewSimulation, /* canReplayWhileLiveIsPossible */false, autoSelectMedia, defaultMedia);
}
// private RaceBoardPerspectiveSettings readRaceboardConfiguration() {
// Boolean autoSelectMedia = true;
//
// final boolean showLeaderboard = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_LEADERBOARD, true /* default */);
// final boolean showWindChart = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_WINDCHART, false /* default */);
// final boolean showViewStreamlets = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_STREAMLETS, false /* default */);
// final boolean showViewStreamletColors = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_STREAMLET_COLORS, false /* default */);
// final boolean showViewSimulation = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_SIMULATION, false /* default */);
// final boolean showCompetitorsChart = GwtHttpRequestUtils.getBooleanParameter(
// RaceBoardPerspectiveSettings.PARAM_VIEW_SHOW_COMPETITORSCHART, false /* default */);
// String activeCompetitorsFilterSetName = GwtHttpRequestUtils.getStringParameter(RaceBoardPerspectiveSettings.PARAM_VIEW_COMPETITOR_FILTER, null /* default*/);
// final String defaultMedia = GwtHttpRequestUtils.getStringParameter(RaceBoardPerspectiveSettings.PARAM_DEFAULT_MEDIA, null /* default */);
//
// return new RaceBoardPerspectiveSettings(activeCompetitorsFilterSetName, showLeaderboard,
// showWindChart, showCompetitorsChart, showViewStreamlets, showViewStreamletColors, showViewSimulation, /* canReplayWhileLiveIsPossible */false, autoSelectMedia, defaultMedia);
// }
private void createErrorView(String errorMessage, Throwable errorReason, AcceptsOneWidget panel) {
ErrorView view = clientFactory.createErrorView(errorMessage, errorReason);
@@ -2,33 +2,51 @@ package com.sap.sailing.gwt.autoplay.client.place.player;
import com.google.gwt.place.shared.PlaceTokenizer;
import com.sap.sailing.gwt.common.client.AbstractBasePlace;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPerspectiveSettings;
import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
public class PlayerPlace extends AbstractBasePlace {
private final AutoPlayerConfiguration playerConfiguration;
private final Pair<LeaderboardPerspectiveSettings, CompositeSettings> leaderboardPerspectiveSettings;
private final Pair<RaceBoardPerspectiveSettings, CompositeSettings> raceboardPerspectiveSettings;
public PlayerPlace(String url) {
super(url);
String eventUuidAsString = getParameter(AutoPlayerConfiguration.PARAM_EVENTID);
String leaderboardName= getParameter(AutoPlayerConfiguration.PARAM_LEADEROARD_NAME);
Boolean fullscreen = Boolean.valueOf(getParameter(AutoPlayerConfiguration.PARAM_FULLSCREEN));
String leaderboardZoom = getParameter(AutoPlayerConfiguration.PARAM_LEADEROARD_ZOOM);
this.playerConfiguration = new AutoPlayerConfiguration(eventUuidAsString, leaderboardName, fullscreen, leaderboardZoom);
this.playerConfiguration = new AutoPlayerConfiguration(eventUuidAsString, leaderboardName, fullscreen);
this.leaderboardPerspectiveSettings = null;
this.raceboardPerspectiveSettings = null;
}
public PlayerPlace(AutoPlayerConfiguration playerConfiguration) {
public PlayerPlace(AutoPlayerConfiguration playerConfiguration, Pair<LeaderboardPerspectiveSettings, CompositeSettings> leaderboardPerspectiveSettings,
Pair<RaceBoardPerspectiveSettings, CompositeSettings> raceboardPerspectiveSettings) {
super(AutoPlayerConfiguration.PARAM_EVENTID, playerConfiguration.getEventUidAsString(),
AutoPlayerConfiguration.PARAM_FULLSCREEN, String.valueOf(playerConfiguration.isFullscreenMode()),
AutoPlayerConfiguration.PARAM_LEADEROARD_NAME, playerConfiguration.getLeaderboardName(),
AutoPlayerConfiguration.PARAM_LEADEROARD_ZOOM, playerConfiguration.getLeaderboardZoom());
AutoPlayerConfiguration.PARAM_LEADEROARD_NAME, playerConfiguration.getLeaderboardName());
this.playerConfiguration = playerConfiguration;
this.leaderboardPerspectiveSettings = leaderboardPerspectiveSettings;
this.raceboardPerspectiveSettings = raceboardPerspectiveSettings;
}
public AutoPlayerConfiguration getConfiguration() {
return this.playerConfiguration;
}
public Pair<LeaderboardPerspectiveSettings, CompositeSettings> getLeaderboardPerspectiveSettings() {
return leaderboardPerspectiveSettings;
}
public Pair<RaceBoardPerspectiveSettings, CompositeSettings> getRaceboardPerspectiveSettings() {
return raceboardPerspectiveSettings;
}
public static class Tokenizer implements PlaceTokenizer<PlayerPlace> {
@Override
public String getToken(PlayerPlace place) {
@@ -37,6 +37,7 @@ import com.sap.sailing.gwt.ui.client.shared.charts.ChartSettings;
import com.sap.sailing.gwt.ui.client.shared.charts.MultiCompetitorRaceChartSettings;
import com.sap.sailing.gwt.ui.client.shared.perspective.Perspective;
import com.sap.sailing.gwt.ui.client.shared.perspective.TabbedPerspectiveConfigurationDialog;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPerspectiveSettings;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettings;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardSettingsFactory;
import com.sap.sailing.gwt.ui.leaderboard.ProxyLeaderboardPerspective;
@@ -45,6 +46,8 @@ import com.sap.sailing.gwt.ui.raceboard.RaceBoardPerspectiveSettings;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.gwt.client.event.LocaleChangeEvent;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
@@ -60,13 +63,9 @@ public class DesktopStartView extends Composite implements StartView {
@UiField(provided=true) ListBox localeSelectionBox;
@UiField(provided=true) ListBox eventSelectionBox;
@UiField(provided=true) ListBox leaderboardSelectionBox;
@UiField CheckBox leaderboardAutoZoomBox;
@UiField CheckBox startInFullscreenModeBox;
@UiField TextBox leaderboardZoomBox;
@UiField Button startAutoPlayButton;
@UiField DivElement leaderboardSelectionUi;
@UiField DivElement leaderboardZoomDiv;
@UiField DivElement leaderboardAutoZoomDiv;
@UiField DivElement screenConfigurationUi;
@UiField FlowPanel leaderboardPerspectiveSettingsPanel;
@UiField FlowPanel raceboardPerspectiveSettingsPanel;
@@ -116,8 +115,6 @@ public class DesktopStartView extends Composite implements StartView {
initWidget(uiBinder.createAndBindUi(this));
this.ensureDebugId("AutoPlayStartView");
leaderboardAutoZoomBox.setValue(true);
leaderboardZoomBox.setEnabled(false);
startInFullscreenModeBox.setValue(true);
autoSwitchToRaceboard.setValue(true);
timeToRaceStartInSeconds.setValue(String.valueOf(defaultTimeToStartTimeInSeconds));
@@ -130,7 +127,7 @@ public class DesktopStartView extends Composite implements StartView {
}
private void updatePerspectives(AbstractLeaderboardDTO leaderboard) {
leaderboardPerspective = new ProxyLeaderboardPerspective(leaderboard, createDefaultLeaderboardSettings(leaderboard));
leaderboardPerspective = new ProxyLeaderboardPerspective(new LeaderboardPerspectiveSettings(), leaderboard, createDefaultLeaderboardSettings(leaderboard));
raceboardPerspective = new ProxyRaceBoardPerspective(new RaceBoardPerspectiveSettings(), leaderboard,
createDefaultLeaderboardSettings(leaderboard), createDefaultMultiCompetitorRaceChartSettings());
@@ -238,11 +235,15 @@ public class DesktopStartView extends Composite implements StartView {
void startAutoPlayClicked(ClickEvent event) {
EventDTO selectedEvent = getSelectedEvent();
String selectedLeaderboardName = getSelectedLeaderboardName();
String leaderboardZoom = getLeaderboardZoom();
Pair<RaceBoardPerspectiveSettings, CompositeSettings> raceboardPerspectiveSettings = new Util.Pair<>(raceboardPerspective.getSettings(),
raceboardPerspective.getSettingsOfComponents());
Pair<LeaderboardPerspectiveSettings, CompositeSettings> leaderboardPerspectiveSettings = new Util.Pair<>(leaderboardPerspective.getSettings(),
leaderboardPerspective.getSettingsOfComponents());
if(selectedEvent != null && selectedLeaderboardName != null) {
navigator.goToPlayer(new AutoPlayerConfiguration(selectedEvent.id.toString(), selectedLeaderboardName,
startInFullscreenModeBox.getValue(), leaderboardZoom));
startInFullscreenModeBox.getValue()), leaderboardPerspectiveSettings, raceboardPerspectiveSettings);
}
}
@@ -263,10 +264,6 @@ public class DesktopStartView extends Composite implements StartView {
/*showCompetitorFullNameColumn*/ true);
}
private String getLeaderboardZoom() {
return leaderboardAutoZoomBox.getValue() == true ? "auto" : String.valueOf(leaderboardZoomBox.getValue());
}
private String getSelectedLocale() {
String result = null;
int selectedIndex = localeSelectionBox.getSelectedIndex();
@@ -57,22 +57,6 @@
<g:CheckBox ui:field="startInFullscreenModeBox" />
</div>
</div>
<div ui:field="leaderboardAutoZoomDiv" class="{res.mediaCss.grid} {style.row}">
<div class="{res.mediaCss.small12} {res.mediaCss.medium6} {res.mediaCss.large3} {res.mediaCss.columns}">
<span>Auto-Zoom:</span>
</div>
<div class="{res.mediaCss.small12} {res.mediaCss.medium6} {res.mediaCss.large9} {res.mediaCss.columns}">
<g:CheckBox ui:field="leaderboardAutoZoomBox" />
</div>
</div>
<div ui:field="leaderboardZoomDiv" class="{res.mediaCss.grid} {style.row}">
<div class="{res.mediaCss.small12} {res.mediaCss.medium6} {res.mediaCss.large3} {res.mediaCss.columns}">
<span>Zoom-Factor:</span>
</div>
<div class="{res.mediaCss.small12} {res.mediaCss.medium6} {res.mediaCss.large9} {res.mediaCss.columns}">
<g:TextBox ui:field="leaderboardZoomBox" />
</div>
</div>
<div class="{res.mediaCss.grid} {style.row} {style.headline}">
<div class="{res.mediaCss.columns}">Screen switching</div>
</div>
@@ -1,10 +1,14 @@
package com.sap.sailing.gwt.ui.client.shared.perspective;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
import com.sap.sse.gwt.client.shared.components.CompositeSettings.ComponentAndSettingsPair;
/**
* An abstract base class for perspectives.
@@ -19,6 +23,33 @@ public abstract class AbstractPerspective<SettingsType extends Settings> impleme
components = new ArrayList<Component<?>>();
}
@Override
public CompositeSettings getSettingsOfComponents() {
Collection<ComponentAndSettingsPair<?>> settings = new HashSet<>();
for (Component<?> component : components) {
ComponentAndSettingsPair<?> componentAndSettings = getComponentAndSettings(component);
if (componentAndSettings != null) {
settings.add(componentAndSettings);
}
}
return new CompositeSettings(settings);
}
private <ComponentSettingsType extends Settings> ComponentAndSettingsPair<ComponentSettingsType> getComponentAndSettings(Component<ComponentSettingsType> component) {
return component.hasSettings() ? new ComponentAndSettingsPair<ComponentSettingsType>(component, component.getSettings()) : null;
}
@Override
public void updateSettingsOfComponents(CompositeSettings newSettings) {
for (CompositeSettings.ComponentAndSettingsPair<?> componentAndSettings : newSettings.getSettingsPerComponent()) {
updateSettings(componentAndSettings);
}
}
private <ComponentSettingsType extends Settings> void updateSettings(ComponentAndSettingsPair<ComponentSettingsType> componentAndSettings) {
componentAndSettings.getA().updateSettings(componentAndSettings.getB());
}
@Override
public Iterable<Component<?>> getComponents() {
return components;
@@ -2,6 +2,7 @@ package com.sap.sailing.gwt.ui.client.shared.perspective;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.CompositeSettings;
/**
* A perspective is a composition of UI components into a view/page
@@ -12,5 +13,9 @@ import com.sap.sse.gwt.client.shared.components.Component;
public interface Perspective<SettingsType extends Settings> extends Component<SettingsType> {
Iterable<Component<?>> getComponents();
CompositeSettings getSettingsOfComponents();
void updateSettingsOfComponents(CompositeSettings settingsOfComponents);
String getPerspectiveName();
}
@@ -0,0 +1,34 @@
package com.sap.sailing.gwt.ui.leaderboard;
import com.sap.sse.common.settings.AbstractSettings;
/**
* Represents the parameters for configuring the standalone leaderboard view
*
* @author Frank
*
*/
public class LeaderboardPerspectiveSettings extends AbstractSettings {
private final boolean leaderboardAutoZoom;
private final Double leaderboardZoomFactor;
public final static String PARAM_LEADEROARD_AUTO_ZOOM = "leaderboardAutoZoom";
public final static String PARAM_LEADEROARD_ZOOM_FACTOR = "leaderboardZoomFactor";
public LeaderboardPerspectiveSettings() {
this(true, 1.0);
}
public LeaderboardPerspectiveSettings(boolean leaderboardAutoZoom, Double leaderboardZoomFactor) {
this.leaderboardAutoZoom = leaderboardAutoZoom;
this.leaderboardZoomFactor = leaderboardZoomFactor;
}
public boolean isLeaderboardAutoZoom() {
return leaderboardAutoZoom;
}
public Double getLeaderboardZoomFactor() {
return leaderboardZoomFactor;
}
}
@@ -0,0 +1,80 @@
package com.sap.sailing.gwt.ui.leaderboard;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DoubleBox;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.Validator;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
public class LeaderboardPerspectiveSettingsDialogComponent implements SettingsDialogComponent<LeaderboardPerspectiveSettings> {
CheckBox leaderboardAutoZoomBox;
DoubleBox leaderboardZoomFactorBox;
private final StringMessages stringMessages;
private final LeaderboardPerspectiveSettings initialSettings;
public LeaderboardPerspectiveSettingsDialogComponent(LeaderboardPerspectiveSettings settings, StringMessages stringMessages) {
this.initialSettings = settings;
this.stringMessages = stringMessages;
}
@Override
public Widget getAdditionalWidget(DataEntryDialog<?> dialog) {
VerticalPanel vp = new VerticalPanel();
Grid grid = new Grid(2,2);
vp.add(grid);
leaderboardAutoZoomBox = dialog.createCheckbox("");
leaderboardAutoZoomBox.setValue(initialSettings.isLeaderboardAutoZoom());
leaderboardAutoZoomBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
leaderboardZoomFactorBox.setEnabled(!event.getValue());
}
});
grid.setWidget(0, 0, new Label("Auto zoom:"));
grid.setWidget(0, 1, leaderboardAutoZoomBox);
leaderboardZoomFactorBox = dialog.createDoubleBox(5);
leaderboardZoomFactorBox.setValue(initialSettings.getLeaderboardZoomFactor());
leaderboardZoomFactorBox.setEnabled(!initialSettings.isLeaderboardAutoZoom());
grid.setWidget(1, 0, new Label("Zoom factor:"));
grid.setWidget(1, 1, leaderboardZoomFactorBox);
return vp;
}
@Override
public LeaderboardPerspectiveSettings getResult() {
LeaderboardPerspectiveSettings result = new LeaderboardPerspectiveSettings(leaderboardAutoZoomBox.getValue(), leaderboardZoomFactorBox.getValue());
return result;
}
@Override
public Validator<LeaderboardPerspectiveSettings> getValidator() {
return new Validator<LeaderboardPerspectiveSettings>() {
@Override
public String getErrorMessage(LeaderboardPerspectiveSettings valueToValidate) {
String errorMessage = null;
return errorMessage;
}
};
}
@Override
public FocusWidget getFocusWidget() {
return leaderboardAutoZoomBox;
}
}
@@ -4,16 +4,20 @@ import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.domain.common.dto.AbstractLeaderboardDTO;
import com.sap.sailing.gwt.autoplay.client.place.start.ProxyLeaderboardComponent;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.shared.perspective.AbstractPerspectiveWithoutSettings;
import com.sap.sailing.gwt.ui.client.shared.perspective.AbstractPerspective;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
/**
* A proxy perspective containing a proxy component for the LeaderboardPanel
* @author Frank
*
*/
public class ProxyLeaderboardPerspective extends AbstractPerspectiveWithoutSettings {
public ProxyLeaderboardPerspective(AbstractLeaderboardDTO leaderboard, LeaderboardSettings defaultLeaderboardSettings) {
public class ProxyLeaderboardPerspective extends AbstractPerspective<LeaderboardPerspectiveSettings> {
private LeaderboardPerspectiveSettings perspectiveSettings;
public ProxyLeaderboardPerspective(LeaderboardPerspectiveSettings perspectiveSettings, AbstractLeaderboardDTO leaderboard, LeaderboardSettings defaultLeaderboardSettings) {
super();
this.perspectiveSettings = perspectiveSettings;
components.add(new ProxyLeaderboardComponent(defaultLeaderboardSettings, leaderboard, StringMessages.INSTANCE));
}
@@ -40,4 +44,29 @@ public class ProxyLeaderboardPerspective extends AbstractPerspectiveWithoutSetti
@Override
public void setVisible(boolean visibility) {
}
@Override
public boolean hasSettings() {
return true;
}
@Override
public SettingsDialogComponent<LeaderboardPerspectiveSettings> getSettingsDialogComponent() {
return new LeaderboardPerspectiveSettingsDialogComponent(perspectiveSettings, StringMessages.INSTANCE);
}
@Override
public LeaderboardPerspectiveSettings getSettings() {
return perspectiveSettings;
}
@Override
public void updateSettings(LeaderboardPerspectiveSettings newSettings) {
this.perspectiveSettings = newSettings;
}
@Override
public String getDependentCssClassName() {
return "";
}
}