-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't always complain for missing fields.
- Loading branch information
1 parent
9619b73
commit 33e3e13
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
....support/src/org/eclipse/chemclipse/support/settings/validation/EmptyStringValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Object> { | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters