diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/AbstractChromatogramReportSettings.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/AbstractChromatogramReportSettings.java index dd41452600..a383821666 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/AbstractChromatogramReportSettings.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/AbstractChromatogramReportSettings.java @@ -22,7 +22,7 @@ public abstract class AbstractChromatogramReportSettings extends AbstractProcessSettings implements IChromatogramReportSettings { - @JsonProperty(value = "Export Folder", defaultValue = "") + @JsonProperty(value = "Export Folder", defaultValue = "", required = true) @FileSettingProperty(onlyDirectory = true) private File exportFolder; @JsonProperty(value = "Append", defaultValue = "false") diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/DefaultChromatogramReportSettings.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/DefaultChromatogramReportSettings.java index 9a4c8036ce..19bc600ab7 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/DefaultChromatogramReportSettings.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.report/src/org/eclipse/chemclipse/chromatogram/xxd/report/settings/DefaultChromatogramReportSettings.java @@ -26,7 +26,7 @@ protected String getDefaultFolder() { } /** - * Method that check if systemsettings are available, this is used in conjunction with the SystemSettings annotation but can also be called by user code + * Method that check if system settings are available, this is used in conjunction with the SystemSettings annotation but can also be called by user code * * @return */ diff --git a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/parser/SettingsClassParser.java b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/parser/SettingsClassParser.java index 1fc3da7a4a..b1419a30e9 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/parser/SettingsClassParser.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/parser/SettingsClassParser.java @@ -34,11 +34,11 @@ import org.eclipse.chemclipse.support.settings.SystemSettings; import org.eclipse.chemclipse.support.settings.SystemSettingsStrategy; import org.eclipse.chemclipse.support.settings.ValidatorSettingsProperty; +import org.eclipse.chemclipse.support.settings.validation.EmptyStringValidator; import org.eclipse.chemclipse.support.settings.validation.EvenOddValidatorByte; import org.eclipse.chemclipse.support.settings.validation.EvenOddValidatorInteger; import org.eclipse.chemclipse.support.settings.validation.EvenOddValidatorLong; import org.eclipse.chemclipse.support.settings.validation.EvenOddValidatorShort; -import org.eclipse.chemclipse.support.settings.validation.InputValidator; import org.eclipse.chemclipse.support.settings.validation.MinMaxValidator; import org.eclipse.chemclipse.support.settings.validation.RegularExpressionValidator; import org.eclipse.core.databinding.validation.IValidator; @@ -128,7 +128,7 @@ public List getInputValues() { for(Annotation annotation : annotations) { if(annotation instanceof JsonProperty jsonProperty) { if(jsonProperty.required()) { - inputValue.addValidator(new InputValidator(inputValue)); + inputValue.addValidator(new EmptyStringValidator()); } } if(annotation instanceof LabelProperty labelProperty) { diff --git a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/EmptyStringValidator.java b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/EmptyStringValidator.java new file mode 100644 index 0000000000..f74f5ed8ae --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/EmptyStringValidator.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2023 Lablicate GmbH. + * + * All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.support.settings.validation; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; + +public class EmptyStringValidator implements IValidator { + + private static final String ERROR = "Please enter a value."; + + public EmptyStringValidator() { + + } + + @Override + public IStatus validate(Object value) { + + if(value == null) { + return ValidationStatus.error(ERROR); + } + if(value instanceof String text && text.isEmpty()) { + return ValidationStatus.error(ERROR); + } + return ValidationStatus.ok(); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/InputValidator.java b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/InputValidator.java index 577e574a98..f74f34799f 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/InputValidator.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/settings/validation/InputValidator.java @@ -37,8 +37,6 @@ public IStatus validate(Object value) { String message = null; if(value == null) { message = ERROR; - } else if(value instanceof String text && text.isEmpty()) { - message = ERROR; } else { Class rawType = inputValue.getRawType(); if(rawType != null) { @@ -65,7 +63,7 @@ private String parse(Class rawType, String value) { } } else if(rawType == File.class) { FileSettingProperty property = inputValue.getFileSettingProperty(); - if(property != null && !(property.dialogType() == DialogType.SAVE_DIALOG)) { + if(property != null && property.dialogType() != DialogType.SAVE_DIALOG) { if(value != null && !value.isEmpty() && !new File(value).exists()) { return "Location does not exits, please choose a valid location"; }