Fix save and close order for common window dialog. Close the window
after the save action, because after the close action there is no UI anymore. So an error cannot shown on the UI. Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -50,6 +50,27 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
@ViewScope
|
||||
public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
||||
|
||||
/**
|
||||
* @author Dennis Melzer
|
||||
*
|
||||
*/
|
||||
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editSwModule) {
|
||||
updateSwModule();
|
||||
} else {
|
||||
addNewBaseSoftware();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
return editSwModule || !isDuplicate();
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -5217675246477211483L;
|
||||
|
||||
@Autowired
|
||||
@@ -179,28 +200,9 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
||||
|
||||
setCompositionRoot(formLayout);
|
||||
|
||||
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this)
|
||||
.layout(formLayout).i18n(i18n)
|
||||
.buildCommonDialogWindow();
|
||||
|
||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editSwModule) {
|
||||
updateSwModule();
|
||||
} else {
|
||||
addNewBaseSoftware();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
return editSwModule || !isDuplicate();
|
||||
}
|
||||
});
|
||||
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n)
|
||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||
nameTextField.setEnabled(!editSwModule);
|
||||
versionTextField.setEnabled(!editSwModule);
|
||||
typeComboBox.setEnabled(!editSwModule);
|
||||
@@ -215,11 +217,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
||||
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
||||
|
||||
if (isDuplicate()) {
|
||||
uiNotifcation.displayValidationError(
|
||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||
return;
|
||||
}
|
||||
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name, version,
|
||||
vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
|
||||
if (newBaseSoftwareModule != null) {
|
||||
@@ -238,7 +235,13 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
||||
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
|
||||
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
|
||||
swMgmtService.findSoftwareModuleTypeByName(type));
|
||||
return swModule != null;
|
||||
|
||||
if (swModule != null) {
|
||||
uiNotifcation.displayValidationError(
|
||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,26 @@ import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
||||
public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity, M extends MetaData>
|
||||
extends CustomComponent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
onSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String DELETE_BUTTON = "DELETE_BUTTON";
|
||||
|
||||
private static final long serialVersionUID = -1491218218453167613L;
|
||||
@@ -120,20 +140,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
|
||||
metadataWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||
.caption(getMetadataCaption(nameVersion)).content(this).cancelButtonClickListener(event -> onCancel())
|
||||
.id(SPUIComponentIdProvider.METADATA_POPUP_ID).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
|
||||
|
||||
metadataWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
onSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
.id(SPUIComponentIdProvider.METADATA_POPUP_ID).layout(mainLayout).i18n(i18n)
|
||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||
|
||||
metadataWindow.setHeight(550, Unit.PIXELS);
|
||||
metadataWindow.setWidth(800, Unit.PIXELS);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -63,8 +65,10 @@ import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
* Table pop-up-windows including a minimize and close icon in the upper right
|
||||
* corner and a save and cancel button at the bottom. Is not intended to reuse.
|
||||
*
|
||||
*/
|
||||
public class CommonDialogWindow extends Window {
|
||||
|
||||
@@ -107,6 +111,8 @@ public class CommonDialogWindow extends Window {
|
||||
* the content
|
||||
* @param helpLink
|
||||
* the helpLinks
|
||||
* @param closeListener
|
||||
* the saveDialogCloseListener
|
||||
* @param cancelButtonClickListener
|
||||
* the cancelButtonClickListener
|
||||
* @param layout
|
||||
@@ -115,10 +121,13 @@ public class CommonDialogWindow extends Window {
|
||||
* the i18n service
|
||||
*/
|
||||
public CommonDialogWindow(final String caption, final Component content, final String helpLink,
|
||||
final ClickListener cancelButtonClickListener, final AbstractLayout layout, final I18N i18n) {
|
||||
final SaveDialogCloseListener closeListener, final ClickListener cancelButtonClickListener,
|
||||
final AbstractLayout layout, final I18N i18n) {
|
||||
checkNotNull(closeListener);
|
||||
this.caption = caption;
|
||||
this.content = content;
|
||||
this.helpLink = helpLink;
|
||||
this.closeListener = closeListener;
|
||||
this.cancelButtonClickListener = cancelButtonClickListener;
|
||||
this.orginalValues = new HashMap<>();
|
||||
this.allComponents = getAllComponents(layout);
|
||||
@@ -126,29 +135,24 @@ public class CommonDialogWindow extends Window {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the close Listener
|
||||
*
|
||||
* @param closeListener
|
||||
*/
|
||||
public void setSaveDialogCloseListener(final SaveDialogCloseListener closeListener) {
|
||||
this.closeListener = closeListener;
|
||||
}
|
||||
|
||||
private void onCloseEvent(final ClickEvent clickEvent) {
|
||||
if (!clickEvent.getButton().equals(saveButton)) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (closeListener == null || closeListener.canWindowClose()) {
|
||||
close();
|
||||
}
|
||||
|
||||
// check first the can window close before you save the dialog, because
|
||||
// if you save the dialog first, the entity exist and the duplicate
|
||||
// check is failing.
|
||||
final boolean canWindowClose = closeListener.canWindowClose();
|
||||
if (closeListener.canWindowSaveOrUpdate()) {
|
||||
closeListener.saveOrUpdate();
|
||||
}
|
||||
|
||||
if (canWindowClose) {
|
||||
close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -547,14 +551,14 @@ public class CommonDialogWindow extends Window {
|
||||
*
|
||||
* @return true/false .
|
||||
*/
|
||||
default boolean canWindowSaveOrUpdate() {
|
||||
return true;
|
||||
}
|
||||
boolean canWindowSaveOrUpdate();
|
||||
|
||||
/**
|
||||
* @return true/false based on the dialog window to be closed or not.
|
||||
*/
|
||||
boolean canWindowClose();
|
||||
default boolean canWindowClose() {
|
||||
return canWindowSaveOrUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves/Updates
|
||||
@@ -563,4 +567,22 @@ public class CommonDialogWindow extends Window {
|
||||
void saveOrUpdate();
|
||||
}
|
||||
|
||||
// public abstract class DefaultSaveDialogCloseListener implements
|
||||
// SaveDialogCloseListener {
|
||||
//
|
||||
// private boolean canWindowSaveOrUpdate;
|
||||
//
|
||||
// @Override
|
||||
// public boolean canWindowSaveOrUpdate() {
|
||||
// return this.canWindowSaveOrUpdate;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canWindowClose() {
|
||||
// this.canWindowSaveOrUpdate =
|
||||
// return this.canWindowSaveOrUpdate;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -144,23 +144,8 @@ public class WindowBuilder {
|
||||
* @return the window.
|
||||
*/
|
||||
public CommonDialogWindow buildCommonDialogWindow() {
|
||||
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
|
||||
layout, i18n);
|
||||
window.setSaveDialogCloseListener(saveDialogCloseListener);
|
||||
decorateWindow(window);
|
||||
return window;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the common dialog window.
|
||||
*
|
||||
* @return the window.
|
||||
*/
|
||||
public CommonDialogWindow buildConfirmationWindow() {
|
||||
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
|
||||
layout, i18n);
|
||||
window.setSaveDialogCloseListener(saveDialogCloseListener);
|
||||
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, saveDialogCloseListener,
|
||||
cancelButtonClickListener, layout, i18n);
|
||||
decorateWindow(window);
|
||||
return window;
|
||||
|
||||
|
||||
@@ -61,6 +61,27 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
*/
|
||||
public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> extends CustomComponent
|
||||
implements ColorChangeListener, ColorSelector {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (optiongroup.getValue().equals(createTagStr)) {
|
||||
createEntity();
|
||||
} else {
|
||||
updateEntity(findEntityByName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
final boolean update = !optiongroup.getValue().equals(createTagStr);
|
||||
return update || !isDuplicate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 4229177824620576456L;
|
||||
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||
@@ -462,27 +483,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
|
||||
public CommonDialogWindow getWindow() {
|
||||
reset();
|
||||
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(getWindowCaption()).content(this)
|
||||
.cancelButtonClickListener(event -> discard()).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
|
||||
|
||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (optiongroup.getValue().equals(createTagStr)) {
|
||||
if (!isDuplicate()) {
|
||||
createEntity();
|
||||
}
|
||||
} else {
|
||||
updateEntity(findEntityByName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
final boolean update = !optiongroup.getValue().equals(createTagStr);
|
||||
return update || !isDuplicate();
|
||||
|
||||
}
|
||||
});
|
||||
.cancelButtonClickListener(event -> discard()).layout(mainLayout).i18n(i18n)
|
||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import javax.annotation.PostConstruct;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
@@ -42,8 +41,6 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||
@@ -69,8 +66,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
private static final long serialVersionUID = -5602182034230568435L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DistributionAddUpdateWindowLayout.class);
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@@ -100,6 +95,23 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
private FormLayout formLayout;
|
||||
|
||||
private final class SaveOnCloseDialogListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editDistribution) {
|
||||
updateDistribution();
|
||||
} else {
|
||||
addNewDistribution();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
return !isDuplicate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Distribution Add and Edit Window.
|
||||
*/
|
||||
@@ -198,17 +210,12 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
/* identify the changes */
|
||||
setDistributionValues(currentDS, name, version, distSetTypeName, desc, isMigStepReq);
|
||||
try {
|
||||
distributionSetManagement.updateDistributionSet(currentDS);
|
||||
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
||||
new Object[] { currentDS.getName(), currentDS.getVersion() }));
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS));
|
||||
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
|
||||
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
|
||||
notificationMessage.displayValidationError(
|
||||
i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion()));
|
||||
}
|
||||
distributionSetManagement.updateDistributionSet(currentDS);
|
||||
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
||||
new Object[] { currentDS.getName(), currentDS.getVersion() }));
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,28 +343,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
populateDistSetTypeNameCombo();
|
||||
populateValuesOfDistribution(editDistId);
|
||||
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.dist"))
|
||||
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
|
||||
|
||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editDistribution) {
|
||||
updateDistribution();
|
||||
} else {
|
||||
addNewDistribution();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
return editDistribution || !isDuplicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
return !isDuplicate();
|
||||
}
|
||||
});
|
||||
.content(this).layout(formLayout).i18n(i18n).saveDialogCloseListener(new SaveOnCloseDialogListener())
|
||||
.buildCommonDialogWindow();
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,27 @@ import com.vaadin.ui.Window;
|
||||
@SpringComponent
|
||||
@VaadinSessionScope
|
||||
public class TargetAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editTarget) {
|
||||
updateTarget();
|
||||
} else {
|
||||
addNewTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
return editTarget || !isDuplicate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -6659290471705262389L;
|
||||
|
||||
@Autowired
|
||||
@@ -127,9 +148,6 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
||||
}
|
||||
|
||||
private void addNewTarget() {
|
||||
if (isDuplicate()) {
|
||||
return;
|
||||
}
|
||||
final String newControlllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerIDTextField.getValue());
|
||||
final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(nameTextField.getValue());
|
||||
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
@@ -152,23 +170,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
||||
public Window getWindow() {
|
||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.target"))
|
||||
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
|
||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editTarget) {
|
||||
updateTarget();
|
||||
} else {
|
||||
addNewTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
return editTarget || !isDuplicate();
|
||||
}
|
||||
});
|
||||
.content(this).layout(formLayout).i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener())
|
||||
.buildCommonDialogWindow();
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -171,27 +171,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
resetComponents();
|
||||
final CommonDialogWindow commonDialogWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||
.caption(i18n.get("caption.configure.rollout")).content(this).layout(this).i18n(i18n)
|
||||
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView()).buildCommonDialogWindow();
|
||||
commonDialogWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editRolloutEnabled) {
|
||||
editRollout();
|
||||
} else {
|
||||
createRollout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowClose() {
|
||||
if (editRolloutEnabled) {
|
||||
return duplicateCheckForEdit();
|
||||
}
|
||||
return duplicateCheck();
|
||||
}
|
||||
});
|
||||
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView())
|
||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||
return commonDialogWindow;
|
||||
}
|
||||
|
||||
@@ -418,26 +399,26 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
}
|
||||
|
||||
private void editRollout() {
|
||||
if (duplicateCheckForEdit() && rolloutForEdit != null) {
|
||||
rolloutForEdit.setName(rolloutName.getValue());
|
||||
rolloutForEdit.setDescription(description.getValue());
|
||||
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
|
||||
rolloutForEdit.setDistributionSet(
|
||||
distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
|
||||
rolloutForEdit.setActionType(getActionType());
|
||||
rolloutForEdit.setForcedTime(getForcedTimeStamp());
|
||||
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
|
||||
final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup);
|
||||
|
||||
for (final RolloutGroup rolloutGroup : rolloutForEdit.getRolloutGroups()) {
|
||||
rolloutGroup.setErrorConditionExp(triggerThreshold.getValue());
|
||||
rolloutGroup.setSuccessConditionExp(String.valueOf(errorThresoldPercent));
|
||||
}
|
||||
final Rollout updatedRollout = rolloutManagement.updateRollout(rolloutForEdit);
|
||||
uiNotification
|
||||
.displaySuccess(i18n.get("message.update.success", new Object[] { updatedRollout.getName() }));
|
||||
eventBus.publish(this, RolloutEvent.UPDATE_ROLLOUT);
|
||||
if (rolloutForEdit == null) {
|
||||
return;
|
||||
}
|
||||
rolloutForEdit.setName(rolloutName.getValue());
|
||||
rolloutForEdit.setDescription(description.getValue());
|
||||
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
|
||||
rolloutForEdit
|
||||
.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
|
||||
rolloutForEdit.setActionType(getActionType());
|
||||
rolloutForEdit.setForcedTime(getForcedTimeStamp());
|
||||
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
|
||||
final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup);
|
||||
|
||||
for (final RolloutGroup rolloutGroup : rolloutForEdit.getRolloutGroups()) {
|
||||
rolloutGroup.setErrorConditionExp(triggerThreshold.getValue());
|
||||
rolloutGroup.setSuccessConditionExp(String.valueOf(errorThresoldPercent));
|
||||
}
|
||||
final Rollout updatedRollout = rolloutManagement.updateRollout(rolloutForEdit);
|
||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { updatedRollout.getName() }));
|
||||
eventBus.publish(this, RolloutEvent.UPDATE_ROLLOUT);
|
||||
}
|
||||
|
||||
private boolean duplicateCheckForEdit() {
|
||||
@@ -463,11 +444,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
}
|
||||
|
||||
private void createRollout() {
|
||||
if (duplicateCheck()) {
|
||||
final Rollout rolloutToCreate = saveRollout();
|
||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { rolloutToCreate.getName() }));
|
||||
eventBus.publish(this, RolloutEvent.CREATE_ROLLOUT);
|
||||
}
|
||||
final Rollout rolloutToCreate = saveRollout();
|
||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { rolloutToCreate.getName() }));
|
||||
}
|
||||
|
||||
private Rollout saveRollout() {
|
||||
@@ -605,6 +583,29 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
return HawkbitCommonUtil.trimAndNullIfEmpty(rolloutName.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
|
||||
@Override
|
||||
public void saveOrUpdate() {
|
||||
if (editRolloutEnabled) {
|
||||
editRollout();
|
||||
} else {
|
||||
createRollout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWindowSaveOrUpdate() {
|
||||
if (editRolloutEnabled) {
|
||||
return duplicateCheckForEdit();
|
||||
}
|
||||
return duplicateCheck();
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorThresoldOptionValidator implements Validator {
|
||||
private static final long serialVersionUID = 9049939751976326550L;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user