Fix for the dialog window must not close after save if duplicate exists.

Signed-off-by: Gaurav <gaurav.sahay@in.bosch.com>
This commit is contained in:
Gaurav
2016-08-15 15:38:08 +02:00
parent d89b6993d4
commit 75905472c8
6 changed files with 42 additions and 5 deletions

View File

@@ -202,9 +202,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent implements Se
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
uiNotifcation.displayValidationError(
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
window.setIsDuplicate(Boolean.TRUE);
} else {
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
window.setIsDuplicate(Boolean.FALSE);
if (newBaseSoftwareModule != null) {
/* display success message */
uiNotifcation.displaySuccess(i18n.get("message.save.success",

View File

@@ -101,6 +101,8 @@ public class CommonDialogWindow extends Window implements Serializable {
private final List<AbstractField<?>> allComponents;
private final I18N i18n;
private boolean isDuplicate;
/**
* Constructor.
@@ -137,11 +139,15 @@ public class CommonDialogWindow extends Window implements Serializable {
@Override
public void close() {
super.close();
orginalValues.clear();
removeListeners();
allComponents.clear();
this.saveButton.setEnabled(false);
if(!isDuplicate){
super.close();
orginalValues.clear();
removeListeners();
allComponents.clear();
this.saveButton.setEnabled(false);
}else{
isDuplicate = Boolean.FALSE;
}
}
private void removeListeners() {
@@ -523,4 +529,22 @@ public class CommonDialogWindow extends Window implements Serializable {
public void setCancelButtonEnabled(final boolean enabled) {
cancelButton.setEnabled(enabled);
}
/**
* Boolean.TRUE/Boolean.FALSE based on the entity saved in the window already exists.
* @return isDuplicate
*/
public boolean getIsDuplicate() {
return isDuplicate;
}
/**
* Sets Boolean.TRUE/Boolean.FALSE based on the entity saved in the window already exists.
* @param isDuplicate
*/
public void setIsDuplicate(final boolean isDuplicate) {
this.isDuplicate = isDuplicate;
}
}

View File

@@ -563,8 +563,10 @@ public abstract class AbstractCreateUpdateTagLayout extends CustomComponent
protected Boolean checkIsDuplicate(final Tag existingTag) {
if (existingTag != null) {
displayValidationError(i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() }));
window.setIsDuplicate(Boolean.TRUE);
return Boolean.TRUE;
}
window.setIsDuplicate(Boolean.FALSE);
return Boolean.FALSE;
}

View File

@@ -260,8 +260,10 @@ public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayo
if (existingType != null) {
uiNotification.displayValidationError(
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
window.setIsDuplicate(Boolean.TRUE);
return Boolean.TRUE;
}
window.setIsDuplicate(Boolean.FALSE);
return Boolean.FALSE;
}
@@ -271,13 +273,16 @@ public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayo
if (existingType instanceof DistributionSetType) {
uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check",
new Object[] { ((DistributionSetType) existingType).getKey() }));
window.setIsDuplicate(Boolean.TRUE);
return Boolean.TRUE;
} else if (existingType instanceof SoftwareModuleType) {
uiNotification.displayValidationError(i18n.get("message.type.key.swmodule.duplicate.check",
new Object[] { ((SoftwareModuleType) existingType).getKey() }));
window.setIsDuplicate(Boolean.TRUE);
return Boolean.TRUE;
}
}
window.setIsDuplicate(Boolean.FALSE);
return Boolean.FALSE;
}

View File

@@ -273,9 +273,11 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distVersionTextField.addStyleName("v-textfield-error");
notificationMessage.displayValidationError(
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
window.setIsDuplicate(Boolean.TRUE);
return false;
} else {
window.setIsDuplicate(Boolean.FALSE);
return true;
}
}

View File

@@ -201,8 +201,10 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
if (existingTarget != null) {
uINotification.displayValidationError(
i18n.get("message.target.duplicate.check", new Object[] { newControlllerId }));
window.setIsDuplicate(Boolean.TRUE);
return false;
} else {
window.setIsDuplicate(Boolean.FALSE);
return true;
}
}