Improved creation of composite default settings for a perpective

This commit is contained in:
fmittag
2016-05-17 17:54:51 +02:00
parent beeaf84403
commit 14f52fd9a4
8 changed files with 29 additions and 42 deletions
@@ -37,11 +37,9 @@ import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sse.common.settings.Settings;
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.CompositeLifecycleSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeLifecycleSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeLifecycleTabbedSettingsDialog;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycle;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycleAndSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycleWithAllSettings;
import com.sap.sse.security.ui.authentication.generic.sapheader.SAPHeaderWithAuthentication;
@@ -117,24 +115,10 @@ public class DesktopStartView extends Composite implements StartView {
private void updatePerspectives(AbstractLeaderboardDTO leaderboard) {
LeaderboardWithHeaderPerspectiveLifecycle leaderboardPerspectiveLifecycle = new LeaderboardWithHeaderPerspectiveLifecycle(leaderboard, StringMessages.INSTANCE);
LeaderboardWithHeaderPerspectiveSettings leaderboardPerspectiveSettings = new LeaderboardWithHeaderPerspectiveSettings();
CompositeLifecycleSettings leaderboardPerspectiveComponentsLifecyclesAndSettings = leaderboardPerspectiveLifecycle.getComponentLifecyclesAndDefaultSettings();
PerspectiveLifecycleAndSettings<LeaderboardWithHeaderPerspectiveLifecycle, LeaderboardWithHeaderPerspectiveSettings> leaderboardPerspectiveLifecycleAndSettings =
new PerspectiveLifecycleAndSettings<>(leaderboardPerspectiveLifecycle, leaderboardPerspectiveSettings);
leaderboardPerspectiveLifecyclesAndSettings = new PerspectiveLifecycleWithAllSettings<>(leaderboardPerspectiveLifecycle,
new PerspectiveCompositeLifecycleSettings<>(leaderboardPerspectiveLifecycleAndSettings,leaderboardPerspectiveComponentsLifecyclesAndSettings));
leaderboardPerspectiveLifecyclesAndSettings = new PerspectiveLifecycleWithAllSettings<>(leaderboardPerspectiveLifecycle,leaderboardPerspectiveLifecycle.createDefaultSettings());
RaceBoardPerspectiveLifecycle raceboardPerspectiveLifecycle = new RaceBoardPerspectiveLifecycle(leaderboard, StringMessages.INSTANCE);
RaceBoardPerspectiveSettings raceboardPerspectiveSettings = new RaceBoardPerspectiveSettings();
CompositeLifecycleSettings raceboardPerspectiveComponentsLifecyclesAndSettings = raceboardPerspectiveLifecycle.getComponentLifecyclesAndDefaultSettings();
PerspectiveLifecycleAndSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> raceboardPerspectiveLifecycleAndSettings =
new PerspectiveLifecycleAndSettings<>(raceboardPerspectiveLifecycle, raceboardPerspectiveSettings);
raceboardPerspectiveLifecyclesAndSettings = new PerspectiveLifecycleWithAllSettings<>(raceboardPerspectiveLifecycle,
new PerspectiveCompositeLifecycleSettings<>(raceboardPerspectiveLifecycleAndSettings,raceboardPerspectiveComponentsLifecyclesAndSettings));
raceboardPerspectiveLifecyclesAndSettings = new PerspectiveLifecycleWithAllSettings<>(raceboardPerspectiveLifecycle,raceboardPerspectiveLifecycle.createDefaultSettings());
}
private <PL extends PerspectiveLifecycle<PS,?,?>, PS extends Settings> void openPerspectiveSettingsDialog(final PerspectiveLifecycleWithAllSettings<PL,PS> perspectiveLifecycleAndSettings) {
@@ -48,15 +48,21 @@ public class LeaderboardWithHeaderPerspectiveLifecycle extends AbstractPerspecti
@Override
public PerspectiveCompositeLifecycleSettings<LeaderboardWithHeaderPerspectiveLifecycle, LeaderboardWithHeaderPerspectiveSettings> createDefaultSettings() {
// TODO Auto-generated method stub
return null;
PerspectiveLifecycleAndSettings<LeaderboardWithHeaderPerspectiveLifecycle, LeaderboardWithHeaderPerspectiveSettings> perspectiveLifecycleAndSettings =
new PerspectiveLifecycleAndSettings<>(this, createPerspectiveDefaultSettings());
return new PerspectiveCompositeLifecycleSettings<>(perspectiveLifecycleAndSettings, getComponentLifecyclesAndDefaultSettings());
}
@Override
public LeaderboardWithHeaderPerspectiveSettings createPerspectiveDefaultSettings() {
return new LeaderboardWithHeaderPerspectiveSettings();
}
@Override
public PerspectiveCompositeLifecycleSettings<LeaderboardWithHeaderPerspectiveLifecycle, LeaderboardWithHeaderPerspectiveSettings> cloneSettings(
PerspectiveCompositeLifecycleSettings<LeaderboardWithHeaderPerspectiveLifecycle, LeaderboardWithHeaderPerspectiveSettings> settings) {
// TODO Auto-generated method stub
return null;
throw new UnsupportedOperationException("Method not implemented yet.");
}
@Override
@@ -25,9 +25,6 @@ import com.sap.sse.gwt.client.EntryPointHelper;
import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeLifecycleSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycleAndSettings;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycleWithAllSettings;
public class RaceBoardEntryPoint extends AbstractSailingEntryPoint {
@@ -131,11 +128,8 @@ public class RaceBoardEntryPoint extends AbstractSailingEntryPoint {
Collections.singletonList(selectedRace.getRaceIdentifier()), 5000l /* requestInterval*/);
RaceBoardPerspectiveLifecycle raceboardPerspectiveLifecycle = new RaceBoardPerspectiveLifecycle(null, StringMessages.INSTANCE);
CompositeLifecycleSettings raceboardPerspectiveComponentsLifecyclesAndSettings = raceboardPerspectiveLifecycle.getComponentLifecyclesAndDefaultSettings();
PerspectiveLifecycleAndSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> raceboardPerspectiveLifecycleAndSettings = new PerspectiveLifecycleAndSettings<>(raceboardPerspectiveLifecycle, perspectiveSettings);
PerspectiveLifecycleWithAllSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> raceboardPerspectiveLifecyclesAndSettings = new PerspectiveLifecycleWithAllSettings<>(raceboardPerspectiveLifecycle,
new PerspectiveCompositeLifecycleSettings<>(raceboardPerspectiveLifecycleAndSettings,raceboardPerspectiveComponentsLifecyclesAndSettings));
raceboardPerspectiveLifecycle.createDefaultSettings());
RaceBoardPanel raceBoardPerspective = new RaceBoardPanel(
raceboardPerspectiveLifecyclesAndSettings, sailingService, mediaService, getUserService(),
@@ -70,16 +70,21 @@ public class RaceBoardPerspectiveLifecycle extends AbstractPerspectiveLifecycle<
@Override
public PerspectiveCompositeLifecycleSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> createDefaultSettings() {
return null;
PerspectiveLifecycleAndSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> perspectiveLifecycleAndSettings =
new PerspectiveLifecycleAndSettings<>(this, createPerspectiveDefaultSettings());
return new PerspectiveCompositeLifecycleSettings<>(perspectiveLifecycleAndSettings, getComponentLifecyclesAndDefaultSettings());
}
@Override
public PerspectiveCompositeLifecycleSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> cloneSettings(
PerspectiveCompositeLifecycleSettings<RaceBoardPerspectiveLifecycle, RaceBoardPerspectiveSettings> settings) {
//// return new RaceBoardPerspectiveSettings(settings.getActiveCompetitorsFilterSetName(), settings.isShowLeaderboard(),
//// settings.isShowWindChart(), settings.isShowCompetitorsChart(), settings.isSimulationEnabled(), settings.isCanReplayDuringLiveRaces(),
//// settings.isChartSupportEnabled());
return null;
throw new UnsupportedOperationException("Method not implemented yet.");
}
@Override
public RaceBoardPerspectiveSettings createPerspectiveDefaultSettings() {
return new RaceBoardPerspectiveSettings();
}
@Override
@@ -26,7 +26,7 @@ public interface ComponentLifecycle<S extends Settings, SDC extends SettingsDial
String getLocalizedShortName();
/**
* @return whether this component has settings that a user may change.
* @return true if the component has settings that a user may change.
*/
boolean hasSettings();
@@ -28,9 +28,8 @@ public abstract class AbstractPerspectiveLifecycle<PS extends Settings, PCS exte
public AbstractPerspectiveLifecycle() {
componentLifecycles = new ArrayList<>();
}
@Override
public CompositeLifecycleSettings getComponentLifecyclesAndDefaultSettings() {
protected CompositeLifecycleSettings getComponentLifecyclesAndDefaultSettings() {
List<ComponentLifecycleAndSettings<?,?>> lifecyclesAndSettings = new ArrayList<>();
for (ComponentLifecycle<?,?> componentLifecycle : componentLifecycles) {
lifecyclesAndSettings.add(createComponentLifecycleAndSettings(componentLifecycle));
@@ -2,7 +2,6 @@ package com.sap.sse.gwt.client.shared.perspective;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.shared.components.ComponentLifecycle;
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
/**
@@ -20,7 +19,7 @@ public interface PerspectiveLifecycle<PS extends Settings, PCS extends Perspecti
Iterable<ComponentLifecycle<?,?>> getComponentLifecycles();
CompositeLifecycleSettings getComponentLifecyclesAndDefaultSettings();
PS createPerspectiveDefaultSettings();
SettingsDialogComponent<PS> getPerspectiveSettingsDialogComponent(PS settings);
}
@@ -4,7 +4,7 @@ import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
/**
* A class keeping together a {@link PerspectiveLifecycle} and all it's component settings together with the corresponding ComponentLifecycle's
* A utility class keeping together a {@link PerspectiveLifecycle} and all it's component settings together with the corresponding ComponentLifecycle's
*
* @param <PL>
* the type of the perspective lifecycle