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());
|
fileInput.disableProperty().bind(disableProperty());
|
||||||
browse.disableProperty().bind(disableProperty());
|
browse.disableProperty().bind(disableProperty());
|
||||||
HBox.setHgrow(fileInput, Priority.ALWAYS);
|
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) {
|
public AbstractFileSelectionBox(String initialValue) {
|
||||||
|
@ -104,6 +114,10 @@ public abstract class AbstractFileSelectionBox extends HBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String validate(File file) {
|
protected String validate(File file) {
|
||||||
|
if(isDisabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (file == null || !file.exists()) {
|
if (file == null || !file.exists()) {
|
||||||
return "File does not exist";
|
return "File does not exist";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,10 @@ public class DirectorySelectionBox extends AbstractFileSelectionBox {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String validate(File file) {
|
protected String validate(File file) {
|
||||||
|
if(isDisabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String msg = super.validate(file);
|
String msg = super.validate(file);
|
||||||
if(msg != null) {
|
if(msg != null) {
|
||||||
return msg;
|
return msg;
|
||||||
|
|
|
@ -12,6 +12,10 @@ public class FileSelectionBox extends AbstractFileSelectionBox {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String validate(File file) {
|
protected String validate(File file) {
|
||||||
|
if(isDisabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String msg = super.validate(file);
|
String msg = super.validate(file);
|
||||||
if(msg != null) {
|
if(msg != null) {
|
||||||
return msg;
|
return msg;
|
||||||
|
|
|
@ -12,6 +12,10 @@ public class ProgramSelectionBox extends FileSelectionBox {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String validate(File file) {
|
protected String validate(File file) {
|
||||||
|
if(isDisabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String msg = super.validate(file);
|
String msg = super.validate(file);
|
||||||
if(msg != null) {
|
if(msg != null) {
|
||||||
return msg;
|
return msg;
|
||||||
|
|
Loading…
Reference in New Issue