aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/settings/parameters/GUIDoubleParameter.java')
-rw-r--r--src/jcgp/gui/settings/parameters/GUIDoubleParameter.java41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
index a1b4526..190f4b7 100644
--- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
@@ -11,12 +11,13 @@ import javafx.scene.text.Text;
import jcgp.backend.parameters.DoubleParameter;
import jcgp.backend.parameters.ParameterStatus;
import jcgp.gui.GUI;
+import jcgp.gui.settings.SettingsPane;
public class GUIDoubleParameter extends GUIParameter {
private double originalValue;
- GUIDoubleParameter(final DoubleParameter parameter) {
+ GUIDoubleParameter(final DoubleParameter parameter, final SettingsPane sp) {
super();
this.parameter = parameter;
@@ -54,18 +55,8 @@ public class GUIDoubleParameter extends GUIParameter {
String oldValue, String newValue) {
if (!newValue.isEmpty()) {
parameter.set(Double.parseDouble(newValue));
- if (parameter.getStatus() == ParameterStatus.INVALID) {
- valueControl.setStyle(GUI.INVALID_PARAMETER_STYLE);
- valueControl.setTooltip(tooltip);
- tooltip.setText(parameter.getStatus().getDetails());
- } else if (parameter.getStatus() == ParameterStatus.WARNING) {
- valueControl.setStyle(GUI.WARNING_PARAMETER_STYLE);
- valueControl.setTooltip(tooltip);
- tooltip.setText(parameter.getStatus().getDetails());
- } else {
- valueControl.setStyle(GUI.VALID_PARAMETER_STYLE);
- valueControl.setTooltip(null);
- }
+ setValidityStyle();
+ sp.revalidateParameters();
}
}
@@ -93,7 +84,8 @@ public class GUIDoubleParameter extends GUIParameter {
@Override
public boolean requiresReset() {
- return parameter.isCritical() && ((DoubleParameter) parameter).get() != originalValue;
+ return (parameter.isCritical() && ((DoubleParameter) parameter).get() != originalValue)
+ || parameter.getStatus() == ParameterStatus.WARNING_RESET;
}
@Override
@@ -101,4 +93,25 @@ public class GUIDoubleParameter extends GUIParameter {
originalValue = ((DoubleParameter) parameter).get();
}
+ @Override
+ public void validate() {
+ ((DoubleParameter) parameter).validate(((DoubleParameter) parameter).get());
+ setValidityStyle();
+ }
+
+ private void setValidityStyle() {
+ if (parameter.getStatus() == ParameterStatus.INVALID) {
+ valueControl.setStyle(GUI.INVALID_PARAMETER_STYLE);
+ valueControl.setTooltip(tooltip);
+ tooltip.setText(parameter.getStatus().getDetails());
+ } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) {
+ valueControl.setStyle(GUI.WARNING_PARAMETER_STYLE);
+ valueControl.setTooltip(tooltip);
+ tooltip.setText(parameter.getStatus().getDetails());
+ } else {
+ valueControl.setStyle(GUI.VALID_PARAMETER_STYLE);
+ valueControl.setTooltip(null);
+ }
+ }
+
}