Fixed review findings
This commit is contained in:
parent
0e9991b0a4
commit
9646e1eabc
@@ -39,14 +39,8 @@ import com.vaadin.ui.VerticalLayout;
|
||||
public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener, ValueChangeListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
@@ -119,13 +113,6 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
setCompositionRoot(rootPanel);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#save
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public void save() {
|
||||
certificateAuthenticationConfigurationItem.save();
|
||||
@@ -133,13 +120,6 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
gatewaySecurityTokenAuthenticationConfigurationItem.save();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#undo
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public void undo() {
|
||||
certificateAuthenticationConfigurationItem.undo();
|
||||
@@ -155,37 +135,32 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
notifyConfigurationChanged();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.
|
||||
* data.Property. ValueChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
|
||||
if (event.getProperty() instanceof CheckBox) {
|
||||
notifyConfigurationChanged();
|
||||
if (!(event.getProperty() instanceof CheckBox)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = (CheckBox) event.getProperty();
|
||||
AuthenticationConfigurationItem configurationItem = null;
|
||||
notifyConfigurationChanged();
|
||||
|
||||
if (checkBox == gatewaySecTokenCheckBox) {
|
||||
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
||||
} else if (checkBox == targetSecTokenCheckBox) {
|
||||
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
|
||||
} else if (checkBox == certificateAuthCheckbox) {
|
||||
configurationItem = certificateAuthenticationConfigurationItem;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
final CheckBox checkBox = (CheckBox) event.getProperty();
|
||||
AuthenticationConfigurationItem configurationItem;
|
||||
|
||||
if (checkBox.getValue()) {
|
||||
configurationItem.configEnable();
|
||||
} else {
|
||||
configurationItem.configDisable();
|
||||
}
|
||||
if (checkBox == gatewaySecTokenCheckBox) {
|
||||
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
||||
} else if (checkBox == targetSecTokenCheckBox) {
|
||||
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
|
||||
} else if (checkBox == certificateAuthCheckbox) {
|
||||
configurationItem = certificateAuthenticationConfigurationItem;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkBox.getValue()) {
|
||||
configurationItem.configEnable();
|
||||
} else {
|
||||
configurationItem.configDisable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* represents an configurationItem, which can be modified by the user
|
||||
*/
|
||||
public interface ConfigurationItem {
|
||||
|
||||
/**
|
||||
@@ -41,4 +44,4 @@ public interface ConfigurationItem {
|
||||
*/
|
||||
void configurationHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ import com.vaadin.ui.VerticalLayout;
|
||||
*/
|
||||
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
|
||||
@ViewScope
|
||||
public class TenantConfigurationDashboardView extends CustomComponent
|
||||
implements View, ConfigurationItemChangeListener {
|
||||
public class TenantConfigurationDashboardView extends CustomComponent implements View, ConfigurationItemChangeListener {
|
||||
|
||||
public static final String VIEW_NAME = "spSystemConfig";
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -68,7 +67,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
||||
private Button saveConfigurationBtn;
|
||||
private Button undoConfigurationBtn;
|
||||
|
||||
private List<ConfigurationGroup> configurationViews = new ArrayList<ConfigurationGroup>();
|
||||
private final List<ConfigurationGroup> configurationViews = new ArrayList<ConfigurationGroup>();
|
||||
|
||||
/**
|
||||
* init method adds all Configuration Views to the list of Views.
|
||||
@@ -91,9 +90,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
||||
rootLayout.setMargin(true);
|
||||
rootLayout.setSpacing(true);
|
||||
|
||||
configurationViews.forEach(view -> {
|
||||
rootLayout.addComponent(view);
|
||||
});
|
||||
configurationViews.forEach(view -> rootLayout.addComponent(view));
|
||||
|
||||
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
|
||||
rootLayout.addComponent(buttonContent);
|
||||
@@ -101,9 +98,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
||||
rootPanel.setContent(rootLayout);
|
||||
setCompositionRoot(rootPanel);
|
||||
|
||||
configurationViews.forEach(view -> {
|
||||
view.addChangeListener(this);
|
||||
});
|
||||
configurationViews.forEach(view -> view.addChangeListener(this));
|
||||
}
|
||||
|
||||
private HorizontalLayout saveConfigurationButtonsLayout() {
|
||||
@@ -132,23 +127,18 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
||||
|
||||
private void saveConfiguration() {
|
||||
|
||||
boolean isUserInputValid = configurationViews.stream().allMatch(confView -> {
|
||||
return confView.isUserInputValid();
|
||||
});
|
||||
final boolean isUserInputValid = configurationViews.stream().allMatch(confView -> confView.isUserInputValid());
|
||||
|
||||
if (isUserInputValid) {
|
||||
configurationViews.forEach(confView -> {
|
||||
confView.save();
|
||||
});
|
||||
|
||||
// More methods
|
||||
saveConfigurationBtn.setEnabled(false);
|
||||
undoConfigurationBtn.setEnabled(false);
|
||||
uINotification.displaySuccess(i18n.get("notification.configuration.save.successful"));
|
||||
|
||||
} else {
|
||||
if (!isUserInputValid) {
|
||||
uINotification.displayValidationError(i18n.get("notification.configuration.save.notpossible"));
|
||||
return;
|
||||
}
|
||||
configurationViews.forEach(confView -> confView.save());
|
||||
|
||||
// More methods
|
||||
saveConfigurationBtn.setEnabled(false);
|
||||
undoConfigurationBtn.setEnabled(false);
|
||||
uINotification.displaySuccess(i18n.get("notification.configuration.save.successful"));
|
||||
}
|
||||
|
||||
private void undoConfiguration() {
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
/**
|
||||
* Ab abstract authentication configuration item.
|
||||
* abstract authentication configuration item.
|
||||
*
|
||||
*
|
||||
*
|
||||
@@ -28,9 +28,6 @@ import com.vaadin.ui.VerticalLayout;
|
||||
abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLayout
|
||||
implements AuthenticationConfigurationItem {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final TenantConfigurationKey configurationKey;
|
||||
@@ -59,17 +56,9 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
|
||||
addComponent(SPUIComponentProvider.getLabel(labelText, SPUILabelDefinitions.SP_LABEL_SIMPLE));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
|
||||
* TenantConfigurationItem# isConfigEnabled()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConfigEnabled() {
|
||||
final boolean b = tenantConfigurationManagement.getConfigurationValue(configurationKey, Boolean.class)
|
||||
.getValue();
|
||||
return b;
|
||||
return tenantConfigurationManagement.getConfigurationValue(configurationKey, Boolean.class).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,14 +79,6 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
|
||||
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
|
||||
* TenantConfigurationItem# addConfigurationChangeListener
|
||||
* (hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem.
|
||||
* TenantConfigurationChangeListener)
|
||||
*/
|
||||
@Override
|
||||
public void addChangeListener(final ConfigurationItemChangeListener listener) {
|
||||
configurationChangeListeners.add(listener);
|
||||
|
||||
@@ -87,9 +87,10 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (configurationEnabledChange) {
|
||||
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
|
||||
if (!configurationEnabledChange) {
|
||||
return;
|
||||
}
|
||||
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,14 +56,18 @@ public class DurationConfigField extends GridLayout implements ValueChangeListen
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
if (event.getProperty() == checkBox) {
|
||||
if (checkBox.getValue()) {
|
||||
durationField.setEnabled(true);
|
||||
} else {
|
||||
durationField.setDuration(globalDuration);
|
||||
durationField.setEnabled(false);
|
||||
}
|
||||
if (event.getProperty() != checkBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
durationField.setEnabled(checkBox.getValue());
|
||||
|
||||
if (!checkBox.getValue()) {
|
||||
durationField.setDuration(globalDuration);
|
||||
}
|
||||
|
||||
durationField.setEnabled(false);
|
||||
|
||||
notifyConfigurationChanged();
|
||||
}
|
||||
|
||||
@@ -102,11 +106,12 @@ public class DurationConfigField extends GridLayout implements ValueChangeListen
|
||||
checkBox.setValue(false);
|
||||
durationField.setDuration(globalDuration);
|
||||
durationField.setEnabled(false);
|
||||
} else {
|
||||
checkBox.setValue(true);
|
||||
durationField.setDuration(tenantDuration);
|
||||
durationField.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
checkBox.setValue(true);
|
||||
durationField.setDuration(tenantDuration);
|
||||
durationField.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,21 +108,22 @@ public class DurationField extends DateField {
|
||||
// method. This method overwrites the super method, which is
|
||||
// necessary, that parsing works correctly on pressing enter key
|
||||
|
||||
if (event.getProperty() instanceof DurationField) {
|
||||
final Date value = (Date) event.getProperty().getValue();
|
||||
if (!(event.getProperty() instanceof DurationField)) {
|
||||
return;
|
||||
}
|
||||
final Date value = (Date) event.getProperty().getValue();
|
||||
|
||||
// setValue() calls valueChanged again, when the minimum is greater
|
||||
// than the maximum this can lead to an endless loop
|
||||
if (value != null && minimumDuration != null && maximumDuration != null
|
||||
&& minimumDuration.before(maximumDuration)) {
|
||||
// setValue() calls valueChanged again, when the minimum is greater
|
||||
// than the maximum this can lead to an endless loop
|
||||
if (value != null && minimumDuration != null && maximumDuration != null
|
||||
&& minimumDuration.before(maximumDuration)) {
|
||||
|
||||
if (compareTimeOfDates(value, maximumDuration) > 0) {
|
||||
((DateField) event.getProperty()).setValue(maximumDuration);
|
||||
}
|
||||
if (compareTimeOfDates(value, maximumDuration) > 0) {
|
||||
((DateField) event.getProperty()).setValue(maximumDuration);
|
||||
}
|
||||
|
||||
if (compareTimeOfDates(minimumDuration, value) > 0) {
|
||||
((DateField) event.getProperty()).setValue(minimumDuration);
|
||||
}
|
||||
if (compareTimeOfDates(minimumDuration, value) > 0) {
|
||||
((DateField) event.getProperty()).setValue(minimumDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user