The Unified and Autonomous Development Platform
Use self() pattern for abstract form element
steve6509d822169c
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractChoiceElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractChoiceElement.javaindex 771b5f340a..ca0916a480 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractChoiceElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractChoiceElement.java@@ -7,7 +7,8 @@ import org.apache.wicket.markup.html.form.IChoiceRenderer;import org.apache.wicket.model.IModel;import org.apache.wicket.model.util.WildcardListModel;-public abstract class AbstractChoiceElement<T> extends AbstractInputElement<T> {+public abstract class AbstractChoiceElement<T, B extends AbstractChoiceElement<T, B>>+ extends AbstractInputElement<T, B> {private static final long serialVersionUID = 1L;diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractInputElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractInputElement.javaindex 7686ae2f8e..c3c0ab449b 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractInputElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/AbstractInputElement.java@@ -15,7 +15,8 @@ import org.apache.wicket.validation.IValidator;import com.google.common.base.Strings;import com.google.common.collect.Lists;-public abstract class AbstractInputElement<T> extends ValidatableElement<T> {+public abstract class AbstractInputElement<T, B extends AbstractInputElement<T, B>>+ extends ValidatableElement<T> {private static final long serialVersionUID = 1L;@@ -33,6 +34,8 @@ public abstract class AbstractInputElement<T> extends ValidatableElement<T> {abstract protected IFeedbackMessageFilter getFeedbackMessageFilter();+ abstract protected B self();+public AbstractInputElement(String id, String label) {super(id);this.label = label;@@ -59,14 +62,14 @@ public abstract class AbstractInputElement<T> extends ValidatableElement<T> {return getFormComponent().hasErrorMessage();}- public AbstractInputElement<T> add(IValidator<T> validator) {+ public B add(IValidator<T> validator) {validators.add(validator);- return this;+ return self();}- public AbstractInputElement<T> addFormComponentBehavior(Behavior behavior) {+ public B addFormComponentBehavior(Behavior behavior) {behaviors.add(behavior);- return this;+ return self();}@SuppressWarnings({"serial"})@@ -111,9 +114,9 @@ public abstract class AbstractInputElement<T> extends ValidatableElement<T> {return extraCssClass;}- public AbstractInputElement<T> setExtraCssClass(String extraCssClass) {+ public B setExtraCssClass(String extraCssClass) {this.extraCssClass = extraCssClass;- return this;+ return self();}protected Component createFieldLabel(String id) {@@ -142,27 +145,27 @@ public abstract class AbstractInputElement<T> extends ValidatableElement<T> {return required;}- public AbstractInputElement<T> setRequired(boolean required) {+ public B setRequired(boolean required) {this.required = required;- return this;+ return self();}public boolean isReadOnly() {return readOnly;}- public AbstractInputElement<T> setReadOnly(boolean readOnly) {+ public B setReadOnly(boolean readOnly) {this.readOnly = readOnly;- return this;+ return self();}public String getHelp() {return help;}- public AbstractInputElement<T> setHelp(String help) {+ public B setHelp(String help) {this.help = help;- return this;+ return self();}public String getLabel() {diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/checkbox/CheckBoxElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/checkbox/CheckBoxElement.javaindex 0ea279b2f2..609ddcb8c5 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/checkbox/CheckBoxElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/checkbox/CheckBoxElement.java@@ -12,7 +12,7 @@ import org.apache.wicket.validation.IValidator;import com.google.common.base.Strings;import com.pmease.gitop.web.common.wicket.form.AbstractInputElement;-public class CheckBoxElement extends AbstractInputElement<Boolean> {+public class CheckBoxElement extends AbstractInputElement<Boolean, CheckBoxElement> {private static final long serialVersionUID = 1L;@@ -74,4 +74,9 @@ public class CheckBoxElement extends AbstractInputElement<Boolean> {protected IFeedbackMessageFilter getFeedbackMessageFilter() {return new ComponentFeedbackMessageFilter(checkbox);}++ @Override+ protected CheckBoxElement self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/flatradio/FlatRadioElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/flatradio/FlatRadioElement.javaindex cc968b8229..3651c39b81 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/flatradio/FlatRadioElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/flatradio/FlatRadioElement.java@@ -48,6 +48,11 @@ public class FlatRadioElement<T> extends RadioButtonElement<T> {return new Radio<T>(id, radioModel);}+ @Override+ protected FlatRadioElement<T> self() {+ return this;+ }+@Overridepublic void onDetach() {super.onDetach();diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/passwordfield/PasswordFieldElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/passwordfield/PasswordFieldElement.javaindex 3133f7a1ca..906d419030 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/passwordfield/PasswordFieldElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/passwordfield/PasswordFieldElement.java@@ -12,7 +12,7 @@ import org.apache.wicket.validation.IValidator;import com.pmease.gitop.web.common.wicket.form.AbstractInputElement;-public class PasswordFieldElement extends AbstractInputElement<String> {+public class PasswordFieldElement extends AbstractInputElement<String, PasswordFieldElement> {private static final long serialVersionUID = 1L;@@ -84,5 +84,8 @@ public class PasswordFieldElement extends AbstractInputElement<String> {return this;}-+ @Override+ protected PasswordFieldElement self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/radio/RadioButtonElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/radio/RadioButtonElement.javaindex 6ac05a1f5e..9f0a9052e1 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/radio/RadioButtonElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/radio/RadioButtonElement.java@@ -12,7 +12,7 @@ import org.apache.wicket.validation.IValidator;import com.pmease.gitop.web.common.wicket.form.AbstractInputElement;-public class RadioButtonElement<T> extends AbstractInputElement<T> {+public class RadioButtonElement<T> extends AbstractInputElement<T, RadioButtonElement<T>> {private static final long serialVersionUID = 1L;@@ -52,4 +52,9 @@ public class RadioButtonElement<T> extends AbstractInputElement<T> {public Panel getContainer() {return radioContainer;}++ @Override+ protected RadioButtonElement<T> self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/select/DropDownChoiceElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/select/DropDownChoiceElement.javaindex 29d5a881ae..7e20f5bb74 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/select/DropDownChoiceElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/select/DropDownChoiceElement.java@@ -14,7 +14,7 @@ import org.apache.wicket.validation.IValidator;import com.pmease.gitop.web.common.wicket.form.AbstractChoiceElement;-public class DropDownChoiceElement<T> extends AbstractChoiceElement<T> {+public class DropDownChoiceElement<T> extends AbstractChoiceElement<T, DropDownChoiceElement<T>> {private static final long serialVersionUID = 1L;@@ -90,4 +90,9 @@ public class DropDownChoiceElement<T> extends AbstractChoiceElement<T> {public FormComponent<T> getFormComponent() {return dropdownChoice;}++ @Override+ protected DropDownChoiceElement<T> self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textarea/TextAreaElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textarea/TextAreaElement.javaindex 4500786ed5..742f53d961 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textarea/TextAreaElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textarea/TextAreaElement.java@@ -14,7 +14,7 @@ import org.apache.wicket.validation.IValidator;import com.pmease.gitop.web.common.wicket.form.AbstractInputElement;-public class TextAreaElement<T> extends AbstractInputElement<T> {+public class TextAreaElement<T> extends AbstractInputElement<T, TextAreaElement<T>> {private static final long serialVersionUID = 1L;@@ -93,7 +93,7 @@ public class TextAreaElement<T> extends AbstractInputElement<T> {@Overridepublic TextAreaElement<T> add(IValidator<T> validator) {- return (TextAreaElement<T>) super.add(validator);+ return super.add(validator);}@Override@@ -109,4 +109,9 @@ public class TextAreaElement<T> extends AbstractInputElement<T> {this.rows = rows;return this;}++ @Override+ protected TextAreaElement<T> self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textfield/TextFieldElement.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textfield/TextFieldElement.javaindex f9d52404f4..dca3b8e56e 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textfield/TextFieldElement.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/form/textfield/TextFieldElement.java@@ -13,7 +13,7 @@ import org.apache.wicket.validation.IValidator;import com.pmease.gitop.web.common.wicket.form.AbstractInputElement;-public class TextFieldElement<T> extends AbstractInputElement<T> {+public class TextFieldElement<T> extends AbstractInputElement<T, TextFieldElement<T>> {private static final long serialVersionUID = 1L;@@ -88,4 +88,9 @@ public class TextFieldElement<T> extends AbstractInputElement<T> {protected IFeedbackMessageFilter getFeedbackMessageFilter() {return new ComponentFeedbackMessageFilter(getFormComponent());}++ @Override+ protected TextFieldElement<T> self() {+ return this;+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.javaindex a1fc3e118d..d9cb86476f 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java@@ -166,13 +166,13 @@ public abstract class AbstractDiffCommand<T, S extends AbstractDiffCommand<T, S>addArgWhitespaceType(cmd);addArgRenameType(cmd);addArgDiffAlgorithm(cmd);-+ addArgFormat(cmd);addArgPaths(cmd);return cmd;}- protected void applyFormat(Commandline cmd) {+ protected void addArgFormat(Commandline cmd) {if (!Strings.isNullOrEmpty(format)) {cmd.addArgs("--format=", format);}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/CatFileCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/CatFileCommand.javaindex e56ccc31ea..600f851633 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/CatFileCommand.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/CatFileCommand.java@@ -70,7 +70,7 @@ public class CatFileCommand extends GitCommand<String> {ByteArrayOutputStream out = (ByteArrayOutputStream) getOutputStream();InputStream in = getInputStream()) {- cmd.execute(out, errorLogger);+ cmd.execute(out, errorLogger).checkReturnCode();byte[] bytes = out.toByteArray();if (showType == ShowType.PRETTY) {