mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-06 02:52:22 +00:00
The regular SettingsDialog can now optionally create links
This commit is contained in:
1 parent
cf43a62842
commit
e39fc2cee8
4 files changed
+43
-29
No files matched your search
@@ -168,12 +168,12 @@ public abstract class DataEntryDialog<T> {
|
||||
if (errorMessage == null || errorMessage.isEmpty()) {
|
||||
getStatusLabel().setText("");
|
||||
getOkButton().setEnabled(true);
|
||||
onChange(result);
|
||||
} else {
|
||||
getStatusLabel().setText(errorMessage);
|
||||
getStatusLabel().setStyleName("errorLabel");
|
||||
getOkButton().setEnabled(false);
|
||||
}
|
||||
onChange(result);
|
||||
return errorMessage == null;
|
||||
}
|
||||
|
||||
|
||||
+30
-1
@@ -1,5 +1,9 @@
|
||||
package com.sap.sse.gwt.client.shared.components;
|
||||
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.FocusWidget;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
@@ -8,12 +12,37 @@ import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
public abstract class AbstractSettingsDialog<SettingsType extends Settings> extends DataEntryDialog<SettingsType> {
|
||||
private final SettingsDialogComponent<SettingsType> settingsDialogComponent;
|
||||
|
||||
private LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator;
|
||||
private Anchor shareAnchor;
|
||||
|
||||
protected AbstractSettingsDialog(final String shortName, SettingsDialogComponent<SettingsType> dialogComponent,
|
||||
StringMessages stringMessages, boolean animationEnabled, final DialogCallback<SettingsType> callback) {
|
||||
StringMessages stringMessages, boolean animationEnabled, LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator, final DialogCallback<SettingsType> callback) {
|
||||
super(stringMessages.settingsForComponent(shortName), null, stringMessages.ok(), stringMessages.cancel(),
|
||||
dialogComponent.getValidator(), animationEnabled, callback != null ? callback : new NoOpDialogCallback<SettingsType>());
|
||||
this.settingsDialogComponent = dialogComponent;
|
||||
|
||||
this.linkWithSettingsGenerator = linkWithSettingsGenerator;
|
||||
if(linkWithSettingsGenerator != null) {
|
||||
shareAnchor = new Anchor(stringMessages.sharedSettingsLink());
|
||||
shareAnchor.getElement().getStyle().setMargin(3, Unit.PX);
|
||||
shareAnchor.ensureDebugId("ShareAnchor");
|
||||
shareAnchor.setTarget("_blank");
|
||||
getLeftButtonPannel().add(shareAnchor);
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
@Override
|
||||
public void execute() {
|
||||
onChange(getResult());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChange(SettingsType result) {
|
||||
String link = linkWithSettingsGenerator.createUrl(result);
|
||||
shareAnchor.setHref(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-7
@@ -11,17 +11,21 @@ import com.sap.sse.gwt.client.StringMessages;
|
||||
public class SettingsDialog<SettingsType extends Settings> extends AbstractSettingsDialog<SettingsType> {
|
||||
|
||||
public SettingsDialog(final Component<SettingsType> component, StringMessages stringMessages) {
|
||||
this(component, stringMessages, /* animationEnabled */ true);
|
||||
this(component, stringMessages, /* animationEnabled */ true, null);
|
||||
}
|
||||
|
||||
|
||||
public SettingsDialog(final Component<SettingsType> component, StringMessages stringMessages, LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator) {
|
||||
this(component, stringMessages, /* animationEnabled */ true, linkWithSettingsGenerator);
|
||||
}
|
||||
|
||||
public SettingsDialog(final Component<SettingsType> component, StringMessages stringMessages,
|
||||
boolean animationEnabled) {
|
||||
this(component, component.getSettingsDialogComponent(), stringMessages, animationEnabled, null);
|
||||
boolean animationEnabled, LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator) {
|
||||
this(component, component.getSettingsDialogComponent(), stringMessages, animationEnabled, linkWithSettingsGenerator, null);
|
||||
}
|
||||
|
||||
public SettingsDialog(final Component<SettingsType> component, StringMessages stringMessages,
|
||||
DialogCallback<SettingsType> callback) {
|
||||
this(component, component.getSettingsDialogComponent(), stringMessages, /* animationEnabled */ true, callback);
|
||||
this(component, component.getSettingsDialogComponent(), stringMessages, /* animationEnabled */ true, null, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +54,8 @@ public class SettingsDialog<SettingsType extends Settings> extends AbstractSetti
|
||||
*/
|
||||
private SettingsDialog(final Component<SettingsType> component,
|
||||
SettingsDialogComponent<SettingsType> dialogComponent, StringMessages stringMessages,
|
||||
boolean animationEnabled, final DialogCallback<SettingsType> callback) {
|
||||
super(component.getLocalizedShortName(), dialogComponent, stringMessages, animationEnabled,
|
||||
boolean animationEnabled, LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator, final DialogCallback<SettingsType> callback) {
|
||||
super(component.getLocalizedShortName(), dialogComponent, stringMessages, animationEnabled, linkWithSettingsGenerator,
|
||||
new DialogCallback<SettingsType>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
||||
+1
-20
@@ -1,15 +1,10 @@
|
||||
package com.sap.sse.gwt.client.shared.components;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.StringMessages;
|
||||
|
||||
public class SettingsDialogForLinkSharing<SettingsType extends Settings> extends AbstractSettingsDialog<SettingsType> {
|
||||
|
||||
private LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator;
|
||||
private Anchor shareAnchor;
|
||||
|
||||
public SettingsDialogForLinkSharing(LinkWithSettingsGenerator<SettingsType> linkWithSettingsGenerator,
|
||||
ComponentLifecycle<SettingsType, ?> componentLifecycle, StringMessages stringMessages) {
|
||||
this(linkWithSettingsGenerator, componentLifecycle, componentLifecycle.createDefaultSettings(), stringMessages,
|
||||
@@ -20,20 +15,6 @@ public class SettingsDialogForLinkSharing<SettingsType extends Settings> extends
|
||||
ComponentLifecycle<SettingsType, ?> componentLifecycle, SettingsType settings,
|
||||
StringMessages stringMessages, boolean animationEnabled, DialogCallback<SettingsType> callback) {
|
||||
super(componentLifecycle.getLocalizedShortName(), componentLifecycle.getSettingsDialogComponent(settings),
|
||||
stringMessages, animationEnabled, callback);
|
||||
this.linkWithSettingsGenerator = linkWithSettingsGenerator;
|
||||
shareAnchor = new Anchor(stringMessages.sharedSettingsLink());
|
||||
shareAnchor.getElement().getStyle().setMargin(3, Unit.PX);
|
||||
shareAnchor.ensureDebugId("ShareAnchor");
|
||||
shareAnchor.setTarget("_blank");
|
||||
getLeftButtonPannel().add(shareAnchor);
|
||||
// // initial link
|
||||
// onChange(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChange(SettingsType result) {
|
||||
String link = linkWithSettingsGenerator.createUrl(getResult());
|
||||
shareAnchor.setHref(link);
|
||||
stringMessages, animationEnabled, linkWithSettingsGenerator, callback);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user