Add javadoc

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-08-22 09:30:33 +02:00
parent ef8436d945
commit 7bd8b6554c
7 changed files with 135 additions and 118 deletions

View File

@@ -50,26 +50,6 @@ 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
@@ -105,6 +85,25 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private FormLayout formLayout;
/**
* Save or update the sw module.
*/
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
@Override
public void saveOrUpdate() {
if (editSwModule) {
updateSwModule();
return;
}
addNewBaseSoftware();
}
@Override
public boolean canWindowSaveOrUpdate() {
return editSwModule || !isDuplicate();
}
}
/**
* Initialize Distribution Add and Edit Window.
*/

View File

@@ -65,27 +65,6 @@ 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 canWindowClose() {
return false;
}
@Override
public boolean canWindowSaveOrUpdate() {
return true;
}
}
private static final String DELETE_BUTTON = "DELETE_BUTTON";
private static final long serialVersionUID = -1491218218453167613L;
@@ -119,6 +98,27 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
private HorizontalLayout mainLayout;
/**
* Save the metadata and never close the window after saving.
*/
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
@Override
public void saveOrUpdate() {
onSave();
}
@Override
public boolean canWindowClose() {
return false;
}
@Override
public boolean canWindowSaveOrUpdate() {
return true;
}
}
@PostConstruct
void init() {
createComponents();

View File

@@ -518,7 +518,7 @@ public class CommonDialogWindow extends Window {
* @param component
* AbstractField
*/
public void updateAllComponents(final AbstractField component) {
public void updateAllComponents(final AbstractField<?> component) {
allComponents.add(component);
component.addValueChangeListener(new ChangeListener(component));
@@ -537,28 +537,31 @@ public class CommonDialogWindow extends Window {
}
/**
* Called before the save happens.
* Check if the safe action can executed. After a the save action the
* listener checks if the dialog can closed.
*
*/
public interface SaveDialogCloseListener {
/**
* Default true for all the windows except for DistributionAddUpdate
* window.
* Checks if the safe action can executed.
*
* @return true/false .
* @return <true> = save action can executed <false> = cannot execute
* safe action .
*/
boolean canWindowSaveOrUpdate();
/**
* @return true/false based on the dialog window to be closed or not.
* Checks if the window can closed after the safe action is executed
*
* @return <true> = window will close <false> = will not closed.
*/
default boolean canWindowClose() {
return true;
}
/**
* Saves/Updates
* Saves/Updates action. Is called if canWindowSaveOrUpdate is <true>.
*
*/
void saveOrUpdate();

View File

@@ -57,30 +57,14 @@ import com.vaadin.ui.components.colorpicker.ColorSelector;
import com.vaadin.ui.themes.ValoTheme;
/**
*
* Abstract class for create/update target tag layout.
*
* @param <E>
*/
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";
@@ -127,11 +111,32 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
protected String tagNameValue;
protected String tagDescValue;
protected abstract String getWindowCaption();
/**
*
* Save or update the entity.
*/
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
protected abstract void updateEntity(E entity);
@Override
public void saveOrUpdate() {
if (isUpdateAction()) {
updateEntity(findEntityByName());
return;
}
protected abstract void createEntity();
createEntity();
}
@Override
public boolean canWindowSaveOrUpdate() {
return isUpdateAction() || !isDuplicate();
}
private boolean isUpdateAction() {
return !optiongroup.getValue().equals(createTagStr);
}
}
/**
* Discard the changes and close the popup.
@@ -419,7 +424,7 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
*
* @param colorPickedPreview
*/
private void getTargetDynamicStyles(final String colorPickedPreview) {
private static void getTargetDynamicStyles(final String colorPickedPreview) {
Page.getCurrent().getJavaScript()
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
}
@@ -595,8 +600,6 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
return isDuplicateByName();
}
protected abstract E findEntityByName();
public String getColorPicked() {
return colorPicked;
}
@@ -637,4 +640,12 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
public void removeColorChangeListener(final ColorChangeListener listener) {
}
protected abstract E findEntityByName();
protected abstract String getWindowCaption();
protected abstract void updateEntity(E entity);
protected abstract void createEntity();
}

View File

@@ -95,14 +95,18 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
private FormLayout formLayout;
/**
* Save or update distribution set.
*
*/
private final class SaveOnCloseDialogListener implements SaveDialogCloseListener {
@Override
public void saveOrUpdate() {
if (editDistribution) {
updateDistribution();
} else {
addNewDistribution();
return;
}
addNewDistribution();
}
@Override

View File

@@ -48,26 +48,6 @@ import com.vaadin.ui.Window;
@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
@@ -88,11 +68,31 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
private TextField controllerIDTextField;
private TextField nameTextField;
private TextArea descTextArea;
private boolean editTarget = Boolean.FALSE;
private boolean editTarget;
private String controllerId;
private FormLayout formLayout;
private CommonDialogWindow window;
/**
* Save or update the target.
*/
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
@Override
public void saveOrUpdate() {
if (editTarget) {
updateTarget();
return;
}
addNewTarget();
}
@Override
public boolean canWindowSaveOrUpdate() {
return editTarget || !isDuplicate();
}
}
/**
* Initialize the Add Update Window Component for Target.
*/

View File

@@ -145,6 +145,28 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private final NullValidator nullValidator = new NullValidator(null, false);
/**
* Save or update the rollout.
*/
private final class SaveOnDialogCloseListener implements SaveDialogCloseListener {
@Override
public void saveOrUpdate() {
if (editRolloutEnabled) {
editRollout();
return;
}
createRollout();
}
@Override
public boolean canWindowSaveOrUpdate() {
if (editRolloutEnabled) {
return duplicateCheckForEdit();
}
return duplicateCheck();
}
}
/**
* Create components and layout.
*/
@@ -583,28 +605,6 @@ 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;