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:
SirWayne
2016-08-19 18:25:50 +02:00
parent fe113a4bc6
commit 9f9277d3ee
5 changed files with 12 additions and 35 deletions

View File

@@ -62,7 +62,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
} else {
addNewBaseSoftware();
}
}
@Override

View File

@@ -74,15 +74,16 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
onSave();
}
@Override
public boolean canWindowClose() {
return false;
}
@Override
public boolean canWindowSaveOrUpdate() {
return true;
}
@Override
public boolean canWindowClose() {
return false;
}
}
private static final String DELETE_BUTTON = "DELETE_BUTTON";

View File

@@ -141,15 +141,12 @@ public class CommonDialogWindow extends Window {
return;
}
// 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 (!closeListener.canWindowSaveOrUpdate()) {
return;
}
closeListener.saveOrUpdate();
if (canWindowClose) {
if (closeListener.canWindowClose()) {
close();
}
@@ -557,7 +554,7 @@ public class CommonDialogWindow extends Window {
* @return true/false based on the dialog window to be closed or not.
*/
default boolean canWindowClose() {
return canWindowSaveOrUpdate();
return true;
}
/**
@@ -567,22 +564,4 @@ 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;
// }
//
// }
}

View File

@@ -61,10 +61,9 @@ 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)) {

View File

@@ -594,7 +594,6 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
} else {
createRollout();
}
}
@Override