bug3529 fixed WindChartSettings, add recognition of settings with make

default support in SettingsDialog
This commit is contained in:
Vladislav Chumak committed 2016-11-18 18:20:29 +01:00
1 parent 830e9a0cb1
commit bdcac3e49a
11 files changed
+69 -81

No files matched your search

@@ -143,7 +143,7 @@ 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.AbstractCompositeComponent;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.PersistentSettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> implements TimeListener, CompetitorSelectionChangeListener,
@@ -727,7 +727,7 @@ public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> impleme
settingsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
new PersistentSettingsDialog<RaceMapSettings>(component, stringMessages).show();
new SettingsDialog<RaceMapSettings>(component, stringMessages).show();
}
});
map.setControls(ControlPosition.RIGHT_TOP, settingsButton);
@@ -167,20 +167,20 @@ public class RaceMapSettings extends AbstractGenericSerializableSettings {
* copy constructor that produces a new settings object that equals the one passed as argument but takes the zoom settings from the second parameter
*/
public RaceMapSettings(RaceMapSettings settings, RaceMapZoomSettings zoomSettings) {
this.buoyZoneRadius = settings.buoyZoneRadius;
this.buoyZoneRadius.setValue(settings.buoyZoneRadius.getValue());
this.helpLinesSettings = new RaceMapHelpLinesSettings(settings.getHelpLinesSettings().getVisibleHelpLineTypes());
this.transparentHoverlines = settings.transparentHoverlines;
this.hoverlineStrokeWeight = settings.hoverlineStrokeWeight;
this.maneuverTypesToShow = settings.maneuverTypesToShow;
this.showDouglasPeuckerPoints = settings.showDouglasPeuckerPoints;
this.showOnlySelectedCompetitors = settings.showOnlySelectedCompetitors;
this.showSelectedCompetitorsInfo = settings.showSelectedCompetitorsInfo;
this.showSimulationOverlay = settings.showSimulationOverlay;
this.showWindStreamletOverlay = settings.showWindStreamletOverlay;
this.showWindStreamletColors = settings.showWindStreamletColors;
this.showMapControls = settings.showMapControls;
this.tailLengthInMilliseconds = settings.tailLengthInMilliseconds;
this.windUp = settings.windUp;
this.transparentHoverlines.setValue(settings.transparentHoverlines.getValue());
this.hoverlineStrokeWeight.setValue(settings.hoverlineStrokeWeight.getValue());
this.maneuverTypesToShow.setValues(settings.maneuverTypesToShow.getValues());
this.showDouglasPeuckerPoints.setValue(settings.showDouglasPeuckerPoints.getValue());
this.showOnlySelectedCompetitors.setValue(settings.showOnlySelectedCompetitors.getValue());
this.showSelectedCompetitorsInfo.setValue(settings.showSelectedCompetitorsInfo.getValue());
this.showSimulationOverlay.setValue(settings.showSimulationOverlay.getValue());
this.showWindStreamletOverlay.setValue(settings.showWindStreamletOverlay.getValue());
this.showWindStreamletColors.setValue(settings.showWindStreamletColors.getValue());
this.showMapControls.setValue(settings.showMapControls.getValue());
this.tailLengthInMilliseconds.setValue(settings.tailLengthInMilliseconds.getValue());
this.windUp.setValue(settings.windUp.getValue());
this.zoomSettings = zoomSettings;
}
@@ -120,7 +120,7 @@ import com.sap.sse.gwt.client.player.Timer.PlayStates;
import com.sap.sse.gwt.client.shared.components.AbstractCompositeComponent;
import com.sap.sse.gwt.client.shared.components.ComponentResources;
import com.sap.sse.gwt.client.shared.components.IsEmbeddableComponent;
import com.sap.sse.gwt.client.shared.components.PersistentSettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
import com.sap.sse.gwt.client.useragent.UserAgentDetails;
@@ -1883,7 +1883,7 @@ public class LeaderboardPanel extends AbstractCompositeComponent<LeaderboardSett
competitorSearchTextBox.getSettingsButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
new PersistentSettingsDialog<LeaderboardSettings>(LeaderboardPanel.this, stringMessages).show();
new SettingsDialog<LeaderboardSettings>(LeaderboardPanel.this, stringMessages).show();
}
});
this.competitorFilterPanel = competitorSearchTextBox;
@@ -134,7 +134,7 @@ public class LeaderboardSettings extends AbstractGenericSerializableSettings {
autoExpandPreSelectedRace = new BooleanSetting("autoExpandPreSelectedRace", this, false);
updateUponPlayStateChange = new BooleanSetting("updateUponPlayStateChange", this, true);
sortAscending = new BooleanSetting("sortAscending", this);
sortAscending = new BooleanSetting("sortAscending", this, true);
showAddedScores = new BooleanSetting("showAddedScores", this, false);
showCompetitorSailIdColumn = new BooleanSetting("showCompetitorSailIdColumn", this, true);
showCompetitorFullNameColumn = new BooleanSetting("showCompetitorFullNameColumn", this, true);
@@ -88,7 +88,7 @@ import com.sap.sse.gwt.client.panels.ResizableFlowPanel;
import com.sap.sse.gwt.client.player.TimeRangeWithZoomModel;
import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.PersistentSettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
import com.sap.sse.gwt.client.shared.perspective.AbstractRootPerspectiveComposite;
import com.sap.sse.gwt.client.shared.perspective.PerspectiveLifecycleWithAllSettings;
@@ -439,7 +439,7 @@ public class RaceBoardPanel extends AbstractRootPerspectiveComposite<RaceBoardPe
if (component.hasSettings()) {
settingsMenu.addItem(component.getLocalizedShortName(), new Command() {
public void execute() {
new PersistentSettingsDialog<SettingsType>(component, stringMessages).show();
new SettingsDialog<SettingsType>(component, stringMessages).show();
}
});
}
@@ -31,7 +31,7 @@ import com.sap.sailing.gwt.ui.raceboard.TouchSplitLayoutPanel.Splitter;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.settings.AbstractSettings;
import com.sap.sse.gwt.client.shared.components.Component;
import com.sap.sse.gwt.client.shared.components.PersistentSettingsDialog;
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
import com.sap.sse.security.ui.client.UserService;
import com.sap.sse.security.ui.client.UserStatusEventHandler;
import com.sap.sse.security.ui.shared.UserDTO;
@@ -244,7 +244,7 @@ public class SideBySideComponentViewer implements UserStatusEventHandler {
public <SettingsType extends AbstractSettings> void showSettingsDialog(Component<SettingsType> component) {
if (component.hasSettings()) {
new PersistentSettingsDialog<SettingsType>(component, stringMessages).show();
new SettingsDialog<SettingsType>(component, stringMessages).show();
}
}
@@ -1,13 +1,13 @@
package com.sap.sse.gwt.client.shared.components;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.shared.perspective.AbstractComponentContextWithSettingsStorage;
import com.sap.sse.gwt.client.shared.perspective.AbstractComponentContext;
import com.sap.sse.gwt.client.shared.perspective.Perspective;
public class ComponentTreeNodeInfo<SettingsType extends Settings> {
private Perspective<? extends Settings> parentPerspective = null;
private AbstractComponentContextWithSettingsStorage<?, ?> componentContext = null;
private AbstractComponentContext<?, ?> componentContext = null;
public void setParentPerspective(Perspective<? extends Settings> parentPerspective) {
this.parentPerspective = parentPerspective;
@@ -17,11 +17,11 @@ public class ComponentTreeNodeInfo<SettingsType extends Settings> {
return parentPerspective;
}
public void setComponentContext(AbstractComponentContextWithSettingsStorage<?, ?> componentContext) {
public void setComponentContext(AbstractComponentContext<?, ?> componentContext) {
this.componentContext = componentContext;
}
public AbstractComponentContextWithSettingsStorage<?, ?> getComponentContext() {
public AbstractComponentContext<?, ?> getComponentContext() {
return componentContext;
}
@@ -1,52 +0,0 @@
package com.sap.sse.gwt.client.shared.components;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.gwt.client.StringMessages;
public class PersistentSettingsDialog<SettingsType extends Settings> extends SettingsDialog<SettingsType> {
public PersistentSettingsDialog(final Component<SettingsType> component, StringMessages stringMessages) {
this(component, stringMessages, /* animationEnabled */ true);
}
public PersistentSettingsDialog(final Component<SettingsType> component, StringMessages stringMessages, boolean animationEnabled) {
super(component, stringMessages, animationEnabled);
initAdditionalButtons(component, stringMessages);
}
public PersistentSettingsDialog(final Component<SettingsType> component, StringMessages stringMessages, DialogCallback<SettingsType> callback) {
super(component, stringMessages, callback);
initAdditionalButtons(component, stringMessages);
}
private void initAdditionalButtons(final Component<SettingsType> component, StringMessages stringMessages) {
Button makeDefaultButton = new Button(stringMessages.makeDefault());
makeDefaultButton.getElement().getStyle().setMargin(3, Unit.PX);
makeDefaultButton.ensureDebugId("MakeDefaultButton");
getLeftButtonPannel().add(makeDefaultButton);
makeDefaultButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
component.getComponentTreeNodeInfo().getComponentContext().makeSettingsDefault(component, getResult());
//TODO i18n + use nice styled dialog
Window.alert("Current settings have been set to default");
}
});
Button restoreDefaultButton = new Button(stringMessages.restoreDefault());
restoreDefaultButton.getElement().getStyle().setMargin(3, Unit.PX);
restoreDefaultButton.ensureDebugId("RestoreDefaultButton");
getLeftButtonPannel().add(restoreDefaultButton);
restoreDefaultButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//TODO apply settings - add update method?
// SettingsType defaultSettings = component.getComponentTreeNodeInfo().getComponentContext().getDefaultSettingsForComponent(component);
}
});
}
}
@@ -1,7 +1,9 @@
package com.sap.sse.gwt.client.shared.components;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Widget;
@@ -70,6 +72,10 @@ public class SettingsDialog<SettingsType extends Settings> extends DataEntryDial
}
});
this.settingsDialogComponent = dialogComponent;
if(component.getComponentTreeNodeInfo().getComponentContext().hasMakeCustomDefaultSettingsSupport(component)) {
initMakeDefaultButtons(component, stringMessages);
}
}
@Override
@@ -86,4 +92,29 @@ public class SettingsDialog<SettingsType extends Settings> extends DataEntryDial
protected FocusWidget getInitialFocusWidget() {
return settingsDialogComponent.getFocusWidget();
}
private void initMakeDefaultButtons(final Component<SettingsType> component, StringMessages stringMessages) {
Button makeDefaultButton = new Button(stringMessages.makeDefault());
makeDefaultButton.getElement().getStyle().setMargin(3, Unit.PX);
makeDefaultButton.ensureDebugId("MakeDefaultButton");
getLeftButtonPannel().add(makeDefaultButton);
makeDefaultButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
component.getComponentTreeNodeInfo().getComponentContext().makeSettingsDefault(component, getResult());
//TODO i18n + use nice styled dialog
Window.alert("Current settings have been set to default");
}
});
Button restoreDefaultButton = new Button(stringMessages.restoreDefault());
restoreDefaultButton.getElement().getStyle().setMargin(3, Unit.PX);
restoreDefaultButton.ensureDebugId("RestoreDefaultButton");
getLeftButtonPannel().add(restoreDefaultButton);
restoreDefaultButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//TODO apply settings - add update method?
// SettingsType defaultSettings = component.getComponentTreeNodeInfo().getComponentContext().getDefaultSettingsForComponent(component);
}
});
}
}
@@ -23,7 +23,7 @@ public abstract class AbstractComponentContext<PL extends PerspectiveLifecycle<P
return rootPerspectiveLifecycle.createDefaultSettings();
}
public boolean hasMakeCustomDefaultSettingsSupport() {
public boolean hasMakeCustomDefaultSettingsSupport(Component<?> component) {
return false;
}
}
@@ -6,6 +6,8 @@ import java.util.Map.Entry;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sap.sse.common.settings.Settings;
import com.sap.sse.common.settings.generic.GenericSerializableSettings;
import com.sap.sse.common.settings.generic.SettingsMap;
import com.sap.sse.gwt.client.shared.components.Component;
public abstract class AbstractComponentContextWithSettingsStorage<PL extends PerspectiveLifecycle<PS>, PS extends Settings> extends AbstractComponentContext<PL, PS> {
@@ -137,8 +139,15 @@ public abstract class AbstractComponentContextWithSettingsStorage<PL extends Per
}
@Override
public boolean hasMakeCustomDefaultSettingsSupport() {
return true;
public boolean hasMakeCustomDefaultSettingsSupport(Component<?> component) {
if(!component.hasSettings()) {
return false;
}
Settings settings = component.getSettings();
if(settings instanceof SettingsMap || settings instanceof GenericSerializableSettings) {
return true;
}
return false;
}
}