Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import gwt.material.design.client.base.error.ErrorHandlerType;
import gwt.material.design.client.base.error.HasErrorHandler;
import gwt.material.design.client.base.mixin.ErrorHandlerMixin;
import gwt.material.design.client.base.mixin.ErrorMixin;
import gwt.material.design.client.base.mixin.StatusTextMixin;
import gwt.material.design.client.base.mixin.ValidatorMixin;
import gwt.material.design.client.base.validator.BlankValidator;
import gwt.material.design.client.base.validator.HasValidators;
Expand All @@ -42,13 +42,13 @@

//TODO: HasRawValue
public abstract class AbstractValueWidget<V> extends MaterialWidget implements HasValue<V>, LeafValueEditor<V>,
HasEditorErrors<V>, HasErrorHandler, HasError, HasValidators<V> {
HasEditorErrors<V>, HasErrorHandler, HasStatusText, HasValidators<V> {

private boolean allowBlank = true;
private boolean autoValidate;
private BlankValidator<V> blankValidator;
private ValidatorMixin<AbstractValueWidget<V>, V> validatorMixin;
private ErrorMixin<AbstractValueWidget, ?> errorMixin;
private StatusTextMixin<AbstractValueWidget, ?> statusTextMixin;
private ErrorHandlerMixin<V> errorHandlerMixin;

public AbstractValueWidget(Element element) {
Expand Down Expand Up @@ -85,23 +85,53 @@ public void setValue(V value, boolean fireEvents, boolean reload) {
//setSanitizer();

@Override
public void setError(String error) {
getErrorMixin().setError(error);
public void setErrorText(String errorText) {
getStatusTextMixin().setErrorText(errorText);
}

@Override
public void setSuccess(String success) {
getErrorMixin().setSuccess(success);
public void setSuccessText(String successText) {
getStatusTextMixin().setSuccessText(successText);
}

@Override
public void setHelperText(String helperText) {
getErrorMixin().setHelperText(helperText);
getStatusTextMixin().setHelperText(helperText);
}

@Override
public void clearErrorOrSuccess() {
getErrorMixin().clearErrorOrSuccess();
public void clearErrorText() {
getStatusTextMixin().clearErrorText();
}

@Override
public void clearHelperText() {
getStatusTextMixin().clearHelperText();
}

@Override
public void clearSuccessText() {
getStatusTextMixin().clearSuccessText();
}

@Override
public void clearStatusText() {
getStatusTextMixin().clearStatusText();
}

@Override
public boolean isErrorTextVisible() {
return getStatusTextMixin().isErrorTextVisible();
}

@Override
public boolean isHelperTextVisible() {
return getStatusTextMixin().isHelperTextVisible();
}

@Override
public boolean isSuccessTextVisible() {
return getStatusTextMixin().isSuccessTextVisible();
}

@Override
Expand Down Expand Up @@ -249,11 +279,11 @@ protected ValidatorMixin<AbstractValueWidget<V>, V> getValidatorMixin() {
return validatorMixin;
}

protected ErrorMixin<AbstractValueWidget, ?> getErrorMixin() {
if (errorMixin == null) {
errorMixin = new ErrorMixin<>(this);
protected StatusTextMixin<AbstractValueWidget, ?> getStatusTextMixin() {
if (statusTextMixin == null) {
statusTextMixin = new StatusTextMixin<>(this);
}
return errorMixin;
return statusTextMixin;
}

protected ErrorHandlerMixin<V> getErrorHandlerMixin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@
*/
package gwt.material.design.client.base;

public interface HasError {
public interface HasErrorText {

/**
* Errors occur when an app fails to complete what is expected, such as:
* - The app does not understand user input
* - The system or app fails
* - A user intends to run incompatible operations concurrently
*/
void setError(String error);
void setErrorText(String errorText);

/**
* Set the success message marking a widget as success.
* Is the error text applied and visible.
*/
void setSuccess(String success);
boolean isErrorTextVisible();

/**
* Apply a widgets help text.
* Clear the error states.
*/
void setHelperText(String helperText);

/**
* Clear the error or success states.
*/
void clearErrorOrSuccess();
void clearErrorText();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2018 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.base;

public interface HasHelperText {

/**
* Apply a widgets help text.
*/
void setHelperText(String helperText);

/**
* Is the helper text applied and visible.
*/
boolean isHelperTextVisible();

/**
* Clear the helper states.
*/
void clearHelperText();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2018 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.base;

public interface HasStatusText extends HasHelperText, HasErrorText, HasSuccessText {

void clearStatusText();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2018 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.client.base;

public interface HasSuccessText {

/**
* Set the success message marking a widget as success.
*/
void setSuccessText(String successText);

/**
* Is the success text applied and visible.
*/
boolean isSuccessTextVisible();

/**
* Clear the success text states.
*/
void clearSuccessText();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import com.google.gwt.editor.client.EditorError;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.HasError;
import gwt.material.design.client.base.HasErrorText;
import gwt.material.design.client.base.HasStatusText;
import gwt.material.design.client.ui.MaterialHelpBlock;

import java.util.List;
Expand Down Expand Up @@ -74,8 +75,8 @@ public void cleanup() {

@Override
public void clearErrors() {
if (inputWidget instanceof HasError) {
((HasError) inputWidget).clearErrorOrSuccess();
if (inputWidget instanceof HasStatusText) {
((HasStatusText) inputWidget).clearStatusText();
}
if (helpBlock != null) {
helpBlock.removeStyleName("field-error-label");
Expand Down Expand Up @@ -139,8 +140,8 @@ public void showErrors(List<EditorError> errors) {
}
}

if (inputWidget instanceof HasError) {
((HasError) inputWidget).setError(errorMsg);
if (inputWidget instanceof HasErrorText) {
((HasErrorText) inputWidget).setErrorText(errorMsg);
}

if (helpBlock != null) {
Expand Down
Loading