Deactivate validation if control is disabled
This commit is contained in:
parent
6e58dd6be5
commit
2616d318c0
|
@ -60,6 +60,16 @@ public abstract class AbstractFileSelectionBox extends HBox {
|
|||
fileInput.disableProperty().bind(disableProperty());
|
||||
browse.disableProperty().bind(disableProperty());
|
||||
HBox.setHgrow(fileInput, Priority.ALWAYS);
|
||||
|
||||
disabledProperty().addListener((obs, oldV, newV) -> {
|
||||
if (newV) {
|
||||
hideValidationHints();
|
||||
} else {
|
||||
if (StringUtil.isNotBlank(fileInput.getText())) {
|
||||
setFile(new File(fileInput.getText()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public AbstractFileSelectionBox(String initialValue) {
|
||||
|
@ -104,6 +114,10 @@ public abstract class AbstractFileSelectionBox extends HBox {
|
|||
}
|
||||
|
||||
protected String validate(File file) {
|
||||
if(isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (file == null || !file.exists()) {
|
||||
return "File does not exist";
|
||||
} else {
|
||||
|
|
|
@ -25,6 +25,10 @@ public class DirectorySelectionBox extends AbstractFileSelectionBox {
|
|||
|
||||
@Override
|
||||
protected String validate(File file) {
|
||||
if(isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String msg = super.validate(file);
|
||||
if(msg != null) {
|
||||
return msg;
|
||||
|
|
|
@ -12,6 +12,10 @@ public class FileSelectionBox extends AbstractFileSelectionBox {
|
|||
|
||||
@Override
|
||||
protected String validate(File file) {
|
||||
if(isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String msg = super.validate(file);
|
||||
if(msg != null) {
|
||||
return msg;
|
||||
|
|
|
@ -12,6 +12,10 @@ public class ProgramSelectionBox extends FileSelectionBox {
|
|||
|
||||
@Override
|
||||
protected String validate(File file) {
|
||||
if(isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String msg = super.validate(file);
|
||||
if(msg != null) {
|
||||
return msg;
|
||||
|
|
Loading…
Reference in New Issue