mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
implemented a tabbed perspective settings dialog for the perspective and component lifecycle classes
This commit is contained in:
1 parent
63ac1879aa
commit
b62fdf7da3
20 files changed
+1743
-1470
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import com.sap.sse.common.settings.AbstractSettings;
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
|
||||
|
||||
/**
|
||||
* A composite setting for a perspective and it's components.
|
||||
* @author Frank
|
||||
*
|
||||
*/
|
||||
public class PerspectiveCompositeLifecycleSettings<P extends PerspectiveLifecycle<?,S,?>, S extends Settings> extends AbstractSettings {
|
||||
private final CompositeLifecycleSettings componentLifeycycleSettings;
|
||||
private final PerspectiveLifecycleAndSettings<P,S> perspectiveLifecycleAndSettings;
|
||||
|
||||
public PerspectiveCompositeLifecycleSettings(PerspectiveLifecycleAndSettings<P,S> perspectiveLifecycleAndSettings,
|
||||
CompositeLifecycleSettings componentLifeycycleSettings) {
|
||||
this.perspectiveLifecycleAndSettings = perspectiveLifecycleAndSettings;
|
||||
this.componentLifeycycleSettings = componentLifeycycleSettings;
|
||||
}
|
||||
|
||||
public CompositeLifecycleSettings getComponentLifecyclesAndSettings() {
|
||||
return componentLifeycycleSettings;
|
||||
}
|
||||
|
||||
public PerspectiveLifecycleAndSettings<P, S> getPerspectiveLifecycleAndSettings() {
|
||||
return perspectiveLifecycleAndSettings;
|
||||
}
|
||||
|
||||
public boolean hasSettings() {
|
||||
return ((perspectiveLifecycleAndSettings != null && perspectiveLifecycleAndSettings.getPerspectiveLifecycle().hasSettings()) ||
|
||||
(componentLifeycycleSettings != null && componentLifeycycleSettings.hasSettings()));
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.shared.components.Component;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentLifecycleAndSettings;
|
||||
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
|
||||
|
||||
/**
|
||||
* A component, that contains a collection of settings components in a tabbed panel.
|
||||
*
|
||||
* @author Frank (c5163874)
|
||||
*/
|
||||
public class PerspectiveCompositeLifecycleTabbedSettingsComponent<P extends PerspectiveLifecycle<?,S,?>, S extends Settings> implements Component<PerspectiveCompositeLifecycleSettings<P,S>> {
|
||||
|
||||
private PerspectiveCompositeLifecycleSettings<P,S> compositeLifecycleSettings;
|
||||
private final String title;
|
||||
|
||||
public PerspectiveCompositeLifecycleTabbedSettingsComponent(PerspectiveCompositeLifecycleSettings<P,S> compositeLifecycleSettings) {
|
||||
this(compositeLifecycleSettings, null);
|
||||
}
|
||||
|
||||
public PerspectiveCompositeLifecycleTabbedSettingsComponent(PerspectiveCompositeLifecycleSettings<P,S> compositeLifecycleSettings, String title) {
|
||||
this.compositeLifecycleSettings = compositeLifecycleSettings;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSettings() {
|
||||
return compositeLifecycleSettings.hasSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsDialogComponent<PerspectiveCompositeLifecycleSettings<P,S>> getSettingsDialogComponent() {
|
||||
return new PerspectiveCompositeLifecycleTabbedSettingsDialogComponent<P,S>(compositeLifecycleSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PerspectiveCompositeLifecycleSettings<P,S> getSettings() {
|
||||
return compositeLifecycleSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSettings(PerspectiveCompositeLifecycleSettings<P,S> newSettings) {
|
||||
this.compositeLifecycleSettings = newSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedShortName() {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
return title;
|
||||
} else {
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (ComponentLifecycleAndSettings<?,?> component : compositeLifecycleSettings.getComponentLifecyclesAndSettings().getSettingsPerComponentLifecycle()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
result.append(" / ");
|
||||
}
|
||||
result.append(component.getComponentLifecycle().getLocalizedShortName());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getEntryWidget() {
|
||||
throw new RuntimeException("Virtual composite component doesn't have a widget of its own");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visibility) {
|
||||
throw new RuntimeException("Virtual composite component doesn't know how to make itself visible");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDependentCssClassName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentLifecycle;
|
||||
import com.sap.sse.gwt.client.shared.components.SettingsDialog;
|
||||
|
||||
/**
|
||||
* A composite settings dialog that combines the settings of several {@link ComponentLifecycle}s, providing a tab
|
||||
* for each setting.
|
||||
*
|
||||
* @author Frank Mittag (c5163874)
|
||||
*
|
||||
*/
|
||||
public class PerspectiveCompositeLifecycleTabbedSettingsDialog<P extends PerspectiveLifecycle<?,S,?>, S extends Settings> extends SettingsDialog<PerspectiveCompositeLifecycleSettings<P,S>> {
|
||||
|
||||
public PerspectiveCompositeLifecycleTabbedSettingsDialog(StringMessages stringConstants, PerspectiveCompositeLifecycleSettings<P,S> compositeLifecycleSettings, String title) {
|
||||
super(new PerspectiveCompositeLifecycleTabbedSettingsComponent<P,S>(compositeLifecycleSettings, title), stringConstants);
|
||||
}
|
||||
|
||||
public PerspectiveCompositeLifecycleTabbedSettingsDialog(StringMessages stringConstants, PerspectiveCompositeLifecycleSettings<P,S> compositeLifecycleSettings, String title, DialogCallback<PerspectiveCompositeLifecycleSettings<P,S>> callback) {
|
||||
super(new PerspectiveCompositeLifecycleTabbedSettingsComponent<P,S>(compositeLifecycleSettings, title), stringConstants, callback);
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.gwt.user.client.ui.FocusWidget;
|
||||
import com.google.gwt.user.client.ui.TabPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
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.ComponentLifecycle;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentLifecycleAndSettings;
|
||||
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
|
||||
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class PerspectiveCompositeLifecycleTabbedSettingsDialogComponent<P extends PerspectiveLifecycle<?,PS,?>, PS extends Settings>
|
||||
implements SettingsDialogComponent<PerspectiveCompositeLifecycleSettings<P,PS>> {
|
||||
|
||||
public static class ComponentLifecycleWithSettingsAndDialogComponent<ComponentLifecycleType extends ComponentLifecycle<?,SettingsType,?>, SettingsType extends Settings> {
|
||||
private ComponentLifecycleAndSettings<ComponentLifecycleType, SettingsType> componentLifecycleAndSettings;
|
||||
private SettingsDialogComponent<SettingsType> dialogComponent;
|
||||
|
||||
public ComponentLifecycleWithSettingsAndDialogComponent(ComponentLifecycleAndSettings<ComponentLifecycleType, SettingsType> componentLifecycleAndSettings, SettingsDialogComponent<SettingsType> dialogComponent) {
|
||||
this.componentLifecycleAndSettings = componentLifecycleAndSettings;
|
||||
this.dialogComponent = dialogComponent;
|
||||
}
|
||||
|
||||
public ComponentLifecycleAndSettings<ComponentLifecycleType,SettingsType> getComponentLifecycleAndSettings() {
|
||||
return componentLifecycleAndSettings;
|
||||
}
|
||||
|
||||
public SettingsDialogComponent<SettingsType> getDialogComponent() {
|
||||
return dialogComponent;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PerspectiveLifecycleWithSettingsAndDialogComponent<PerspectiveLifecycleType extends PerspectiveLifecycle<?,SettingsType,?>, SettingsType extends Settings> {
|
||||
private PerspectiveLifecycleAndSettings<PerspectiveLifecycleType, SettingsType> perspectiveLifecycleAndSettings;
|
||||
private SettingsDialogComponent<SettingsType> dialogComponent;
|
||||
|
||||
public PerspectiveLifecycleWithSettingsAndDialogComponent(PerspectiveLifecycleAndSettings<PerspectiveLifecycleType, SettingsType> perspectiveLifecycleAndSettings, SettingsDialogComponent<SettingsType> dialogComponent) {
|
||||
this.perspectiveLifecycleAndSettings = perspectiveLifecycleAndSettings;
|
||||
this.dialogComponent = dialogComponent;
|
||||
}
|
||||
|
||||
public PerspectiveLifecycleAndSettings<PerspectiveLifecycleType,SettingsType> getPerspectiveLifecycleAndSettings() {
|
||||
return perspectiveLifecycleAndSettings;
|
||||
}
|
||||
|
||||
public SettingsDialogComponent<SettingsType> getDialogComponent() {
|
||||
return dialogComponent;
|
||||
}
|
||||
}
|
||||
|
||||
private final Collection<ComponentLifecycleWithSettingsAndDialogComponent<?,?>> componentLifecycleAndDialogComponents;
|
||||
private final PerspectiveLifecycleWithSettingsAndDialogComponent<P,PS> perspectiveLifecycleAndSettingsDialog;
|
||||
|
||||
public PerspectiveCompositeLifecycleTabbedSettingsDialogComponent(PerspectiveCompositeLifecycleSettings<P,PS> componentLifecyclesSettings) {
|
||||
this.componentLifecycleAndDialogComponents = new ArrayList<>();
|
||||
for (ComponentLifecycleAndSettings<?,?> componentLifecycleAndSettings : componentLifecyclesSettings.getComponentLifecyclesAndSettings().getSettingsPerComponentLifecycle()) {
|
||||
if (componentLifecycleAndSettings.getComponentLifecycle().hasSettings()) {
|
||||
this.componentLifecycleAndDialogComponents.add(createComponentLifecycleAndDialogComponent(componentLifecycleAndSettings));
|
||||
}
|
||||
}
|
||||
perspectiveLifecycleAndSettingsDialog = createPerspectiveLifecycleAndDialogComponent(componentLifecyclesSettings.getPerspectiveLifecycleAndSettings());
|
||||
}
|
||||
|
||||
private <C extends ComponentLifecycle<?,S,?>, S extends Settings> ComponentLifecycleWithSettingsAndDialogComponent<C,S> createComponentLifecycleAndDialogComponent(ComponentLifecycleAndSettings<C,S> componentLifecycleAndSettings) {
|
||||
S settings = componentLifecycleAndSettings.getSettings();
|
||||
return new ComponentLifecycleWithSettingsAndDialogComponent<C,S>(componentLifecycleAndSettings, componentLifecycleAndSettings.getComponentLifecycle().getSettingsDialogComponent(settings));
|
||||
}
|
||||
|
||||
private PerspectiveLifecycleWithSettingsAndDialogComponent<P,PS> createPerspectiveLifecycleAndDialogComponent(PerspectiveLifecycleAndSettings<P,PS> perspectiveLifecycleAndSettings) {
|
||||
PS settings = perspectiveLifecycleAndSettings.getSettings();
|
||||
return new PerspectiveLifecycleWithSettingsAndDialogComponent<P,PS>(perspectiveLifecycleAndSettings, perspectiveLifecycleAndSettings.getPerspectiveLifecycle().getSettingsDialogComponent(settings));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget getAdditionalWidget(DataEntryDialog<?> dialog) {
|
||||
TabPanel result = new TabPanel();
|
||||
if(perspectiveLifecycleAndSettingsDialog != null) {
|
||||
Widget w = perspectiveLifecycleAndSettingsDialog.getDialogComponent().getAdditionalWidget((DataEntryDialog<?>) dialog);
|
||||
result.add(w, perspectiveLifecycleAndSettingsDialog.getPerspectiveLifecycleAndSettings().getPerspectiveLifecycle().getLocalizedShortName());
|
||||
}
|
||||
for (ComponentLifecycleWithSettingsAndDialogComponent<?,?> component : componentLifecycleAndDialogComponents) {
|
||||
Widget w = component.getDialogComponent().getAdditionalWidget((DataEntryDialog<?>) dialog);
|
||||
result.add(w, component.getComponentLifecycleAndSettings().getComponentLifecycle().getLocalizedShortName());
|
||||
}
|
||||
result.selectTab(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PerspectiveCompositeLifecycleSettings<P,PS> getResult() {
|
||||
PerspectiveLifecycleAndSettings<P,PS> perspectiveLifeycycleAndSettings = perspectiveLifecycleAndSettingsDialog != null ? getPerspectiveAndSettings(perspectiveLifecycleAndSettingsDialog) : null;
|
||||
Collection<ComponentLifecycleAndSettings<?,?>> settings = new HashSet<>();
|
||||
for (ComponentLifecycleWithSettingsAndDialogComponent<?,?> component : componentLifecycleAndDialogComponents) {
|
||||
settings.add(getComponentAndSettings(component));
|
||||
}
|
||||
return new PerspectiveCompositeLifecycleSettings<P,PS>(perspectiveLifeycycleAndSettings, new CompositeLifecycleSettings(settings));
|
||||
}
|
||||
|
||||
private <C extends ComponentLifecycle<?,S,?>, S extends Settings> ComponentLifecycleAndSettings<C,S> getComponentAndSettings(ComponentLifecycleWithSettingsAndDialogComponent<C,S> component) {
|
||||
return new ComponentLifecycleAndSettings<C,S>(component.getComponentLifecycleAndSettings().getComponentLifecycle(), component.getDialogComponent().getResult());
|
||||
}
|
||||
|
||||
private PerspectiveLifecycleAndSettings<P,PS> getPerspectiveAndSettings(PerspectiveLifecycleWithSettingsAndDialogComponent<P,PS> perspective) {
|
||||
return new PerspectiveLifecycleAndSettings<P,PS>(perspective.getPerspectiveLifecycleAndSettings().getPerspectiveLifecycle(), perspective.getDialogComponent().getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Validator<PerspectiveCompositeLifecycleSettings<P,PS>> getValidator() {
|
||||
return new PerspectiveCompositeLifecycleValidator<P,PS>(perspectiveLifecycleAndSettingsDialog, componentLifecycleAndDialogComponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FocusWidget getFocusWidget() {
|
||||
for (ComponentLifecycleWithSettingsAndDialogComponent<?,?> component : componentLifecycleAndDialogComponents) {
|
||||
FocusWidget fw = component.getDialogComponent().getFocusWidget();
|
||||
if (fw != null) {
|
||||
return fw;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.Validator;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentLifecycle;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentLifecycleAndSettings;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeLifecycleTabbedSettingsDialogComponent.ComponentLifecycleWithSettingsAndDialogComponent;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeLifecycleTabbedSettingsDialogComponent.PerspectiveLifecycleWithSettingsAndDialogComponent;
|
||||
|
||||
public class PerspectiveCompositeLifecycleValidator<P extends PerspectiveLifecycle<?,PS,?>, PS extends Settings> implements Validator<PerspectiveCompositeLifecycleSettings<P,PS>> {
|
||||
|
||||
private final Map<ComponentLifecycleAndSettings<?,?>, Validator<?>> validatorsMappedByComponentLifecycle;
|
||||
private final Validator<?> perspectiveValidator;
|
||||
|
||||
public PerspectiveCompositeLifecycleValidator(PerspectiveLifecycleWithSettingsAndDialogComponent<P,PS> perspectiveLifecycleAndDialogComponent,
|
||||
Iterable<ComponentLifecycleWithSettingsAndDialogComponent<?,?>> componentLifecycleAndDialogComponents) {
|
||||
perspectiveValidator = perspectiveLifecycleAndDialogComponent.getDialogComponent().getValidator();
|
||||
validatorsMappedByComponentLifecycle = new HashMap<>();
|
||||
for (ComponentLifecycleWithSettingsAndDialogComponent<?,?> component : componentLifecycleAndDialogComponents) {
|
||||
validatorsMappedByComponentLifecycle.put(component.getComponentLifecycleAndSettings(), component.getDialogComponent().getValidator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(PerspectiveCompositeLifecycleSettings<P,PS> valueToValidate) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (ComponentLifecycleAndSettings<?,?> componentAndSettings : valueToValidate.getComponentLifecyclesAndSettings().getSettingsPerComponentLifecycle()) {
|
||||
final String errorMessage = getComponentErrorMessage(componentAndSettings);
|
||||
if (errorMessage != null && !errorMessage.isEmpty()) {
|
||||
result.append(errorMessage);
|
||||
}
|
||||
}
|
||||
String perspectiveErrorMessage = getPerspectiveErrorMessage(valueToValidate.getPerspectiveLifecycleAndSettings());
|
||||
if (perspectiveErrorMessage != null && !perspectiveErrorMessage.isEmpty()) {
|
||||
result.append(perspectiveErrorMessage);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private <SettingsType extends Settings> String getPerspectiveErrorMessage(PerspectiveLifecycleAndSettings<?,SettingsType> perspectiveAndSettings) {
|
||||
String errorMessage = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<SettingsType> validator = (Validator<SettingsType>) perspectiveValidator;
|
||||
if (validator != null) {
|
||||
errorMessage = validator.getErrorMessage(perspectiveAndSettings.getSettings());
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
private <C extends ComponentLifecycle<?,S,?>, S extends Settings> String getComponentErrorMessage(ComponentLifecycleAndSettings<C,S> componentLifecycleAndSettings) {
|
||||
String errorMessage = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<S> validator = (Validator<S>) validatorsMappedByComponentLifecycle.get(componentLifecycleAndSettings.getComponentLifecycle());
|
||||
if (validator != null) {
|
||||
errorMessage = validator.getErrorMessage(componentLifecycleAndSettings.getSettings());
|
||||
if (errorMessage != null && !errorMessage.isEmpty() && !getClass().equals(validator.getClass())) {
|
||||
errorMessage += "; ";
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
+65
-59
@@ -1,59 +1,65 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.Validator;
|
||||
import com.sap.sse.gwt.client.shared.components.Component;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentAndSettingsPair;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeTabbedSettingsDialogComponent.ComponentAndDialogComponent;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeTabbedSettingsDialogComponent.PerspectiveAndDialogComponent;
|
||||
|
||||
public class PerspectiveCompositeValidator implements Validator<PerspectiveCompositeSettings> {
|
||||
|
||||
private final Map<Component<?>, Validator<?>> validatorsMappedByComponent;
|
||||
private final PerspectiveAndDialogComponent<?> perspectiveAndDialogComponent;
|
||||
|
||||
public PerspectiveCompositeValidator(PerspectiveAndDialogComponent<?> perspectiveAndDialogComponent, Iterable<ComponentAndDialogComponent<?>> componentsAndDialogComponents) {
|
||||
this.perspectiveAndDialogComponent = perspectiveAndDialogComponent;
|
||||
validatorsMappedByComponent = new HashMap<>();
|
||||
for (ComponentAndDialogComponent<?> componentsAndSettingsDialog : componentsAndDialogComponents) {
|
||||
validatorsMappedByComponent.put(componentsAndSettingsDialog.getComponent(), componentsAndSettingsDialog.getSettingsDialog().getValidator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(PerspectiveCompositeSettings valueToValidate) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (ComponentAndSettingsPair<?> componentAndSettings : valueToValidate.getSettingsPerComponent()) {
|
||||
final String errorMessage = getComponentErrorMessage(componentAndSettings);
|
||||
if (errorMessage != null && !errorMessage.isEmpty()) {
|
||||
result.append(errorMessage);
|
||||
}
|
||||
}
|
||||
PerspectiveAndSettingsPair<?> perspectiveSettings = valueToValidate.getPerspectiveSettings();
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<Settings> validator = (Validator<Settings>) perspectiveAndDialogComponent.getSettingsDialog().getValidator();
|
||||
String perspectiveErrorMessage = validator.getErrorMessage(perspectiveSettings.getSettings());
|
||||
if (perspectiveErrorMessage != null && !perspectiveErrorMessage.isEmpty()) {
|
||||
result.append(perspectiveErrorMessage);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private <SettingsType extends Settings> String getComponentErrorMessage(ComponentAndSettingsPair<SettingsType> componentAndSettings) {
|
||||
String errorMessage = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<SettingsType> validator = (Validator<SettingsType>) validatorsMappedByComponent.get(componentAndSettings.getComponent());
|
||||
if (validator != null) {
|
||||
errorMessage = validator.getErrorMessage(componentAndSettings.getSettings());
|
||||
if (errorMessage != null && !errorMessage.isEmpty() && !getClass().equals(validator.getClass())) {
|
||||
errorMessage += "; ";
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.Validator;
|
||||
import com.sap.sse.gwt.client.shared.components.Component;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentAndSettingsPair;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeTabbedSettingsDialogComponent.ComponentAndDialogComponent;
|
||||
import com.sap.sse.gwt.client.shared.perspective.PerspectiveCompositeTabbedSettingsDialogComponent.PerspectiveAndDialogComponent;
|
||||
|
||||
public class PerspectiveCompositeValidator implements Validator<PerspectiveCompositeSettings> {
|
||||
|
||||
private final Map<Component<?>, Validator<?>> validatorsMappedByComponent;
|
||||
private final Validator<?> perspectiveValidator;
|
||||
|
||||
public PerspectiveCompositeValidator(PerspectiveAndDialogComponent<?> perspectiveAndDialogComponent, Iterable<ComponentAndDialogComponent<?>> componentsAndDialogComponents) {
|
||||
this.perspectiveValidator = perspectiveAndDialogComponent.getSettingsDialog().getValidator();
|
||||
validatorsMappedByComponent = new HashMap<>();
|
||||
for (ComponentAndDialogComponent<?> componentsAndSettingsDialog : componentsAndDialogComponents) {
|
||||
validatorsMappedByComponent.put(componentsAndSettingsDialog.getComponent(), componentsAndSettingsDialog.getSettingsDialog().getValidator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(PerspectiveCompositeSettings valueToValidate) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (ComponentAndSettingsPair<?> componentAndSettings : valueToValidate.getSettingsPerComponent()) {
|
||||
final String errorMessage = getComponentErrorMessage(componentAndSettings);
|
||||
if (errorMessage != null && !errorMessage.isEmpty()) {
|
||||
result.append(errorMessage);
|
||||
}
|
||||
}
|
||||
String perspectiveErrorMessage = getPerspectiveErrorMessage(valueToValidate.getPerspectiveSettings());
|
||||
if (perspectiveErrorMessage != null && !perspectiveErrorMessage.isEmpty()) {
|
||||
result.append(perspectiveErrorMessage);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private <SettingsType extends Settings> String getPerspectiveErrorMessage(PerspectiveAndSettingsPair<SettingsType> perspectiveAndSettings) {
|
||||
String errorMessage = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<SettingsType> validator = (Validator<SettingsType>) perspectiveValidator;
|
||||
if (validator != null) {
|
||||
errorMessage = validator.getErrorMessage(perspectiveAndSettings.getSettings());
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
private <SettingsType extends Settings> String getComponentErrorMessage(ComponentAndSettingsPair<SettingsType> componentAndSettings) {
|
||||
String errorMessage = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Validator<SettingsType> validator = (Validator<SettingsType>) validatorsMappedByComponent.get(componentAndSettings.getComponent());
|
||||
if (validator != null) {
|
||||
errorMessage = validator.getErrorMessage(componentAndSettings.getSettings());
|
||||
if (errorMessage != null && !errorMessage.isEmpty() && !getClass().equals(validator.getClass())) {
|
||||
errorMessage += "; ";
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
+24
-23
@@ -1,23 +1,24 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* A lifecycle interface for perspectives
|
||||
* @author Frank
|
||||
*
|
||||
* @param <P> the perspective type
|
||||
* @param <S> the settings type
|
||||
* @param <SDP> the settings dialog component type
|
||||
*/
|
||||
public interface PerspectiveLifecycle<P extends Perspective<S>, S extends Settings, SDP extends SettingsDialogComponent<S>>
|
||||
extends ComponentLifecycle<P, S, SDP> {
|
||||
Iterable<ComponentLifecycle<?,?,?>> getComponentLifecycles();
|
||||
|
||||
CompositeLifecycleSettings getComponentLifecyclesAndDefaultSettings();
|
||||
|
||||
String getPerspectiveName();
|
||||
}
|
||||
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;
|
||||
|
||||
/**
|
||||
* A lifecycle interface for perspectives
|
||||
* @author Frank
|
||||
*
|
||||
* @param <P> the perspective type
|
||||
* @param <S> the settings type
|
||||
* @param <SDP> the settings dialog component type
|
||||
*/
|
||||
public interface PerspectiveLifecycle<P extends Perspective<S>, S extends Settings, SDP extends SettingsDialogComponent<S>>
|
||||
extends ComponentLifecycle<P, S, SDP> {
|
||||
|
||||
Iterable<ComponentLifecycle<?,?,?>> getComponentLifecycles();
|
||||
|
||||
CompositeLifecycleSettings getComponentLifecyclesAndDefaultSettings();
|
||||
|
||||
String getPerspectiveName();
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
|
||||
|
||||
public class PerspectiveLifecycleAndComponentSettings<PerspectiveLifecycleType extends PerspectiveLifecycle<?,?,?>> {
|
||||
private final PerspectiveLifecycleType perspectiveLifecycle;
|
||||
private CompositeLifecycleSettings componentSettings;
|
||||
|
||||
public PerspectiveLifecycleAndComponentSettings(PerspectiveLifecycleType perspectiveLifecycle,
|
||||
CompositeLifecycleSettings settings) {
|
||||
this.perspectiveLifecycle = perspectiveLifecycle;
|
||||
this.componentSettings = settings;
|
||||
}
|
||||
|
||||
public PerspectiveLifecycleType getPerspectiveLifecycle() {
|
||||
return perspectiveLifecycle;
|
||||
}
|
||||
|
||||
public CompositeLifecycleSettings getComponentSettings() {
|
||||
return componentSettings;
|
||||
}
|
||||
|
||||
public void setComponentSettings(CompositeLifecycleSettings componentSettings) {
|
||||
this.componentSettings = componentSettings;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.sap.sse.gwt.client.shared.perspective;
|
||||
|
||||
import com.sap.sse.common.settings.Settings;
|
||||
import com.sap.sse.gwt.client.shared.components.CompositeLifecycleSettings;
|
||||
|
||||
/**
|
||||
* A class for keeping together all settings of a PerspectiveLifecycle including it's components
|
||||
* @author Frank
|
||||
*
|
||||
* @param <P> the type of the perspective lifecycle
|
||||
* @param <S> the type of the perspective settings
|
||||
*/
|
||||
public class PerspectiveLifecycleWithAllSettings<P extends PerspectiveLifecycle<?,S,?>, S extends Settings> {
|
||||
private final P perspectiveLifecycle;
|
||||
private PerspectiveCompositeLifecycleSettings<P,S> allSettings;
|
||||
|
||||
public PerspectiveLifecycleWithAllSettings(P perspectiveLifecycle, PerspectiveCompositeLifecycleSettings<P,S> allSettings) {
|
||||
this.perspectiveLifecycle = perspectiveLifecycle;
|
||||
this.allSettings = allSettings;
|
||||
}
|
||||
|
||||
public P getPerspectiveLifecycle() {
|
||||
return perspectiveLifecycle;
|
||||
}
|
||||
|
||||
public S getPerspectiveSettings() {
|
||||
return allSettings.getPerspectiveLifecycleAndSettings().getSettings();
|
||||
}
|
||||
|
||||
public CompositeLifecycleSettings getComponentSettings() {
|
||||
return allSettings.getComponentLifecyclesAndSettings();
|
||||
}
|
||||
|
||||
public PerspectiveCompositeLifecycleSettings<P,S> getAllSettings() {
|
||||
return allSettings;
|
||||
}
|
||||
|
||||
public void setAllSettings(PerspectiveCompositeLifecycleSettings<P,S> allSettings) {
|
||||
this.allSettings = allSettings;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user