io.github.albertus82.jface.preference.field.AbstractIntegerComboFieldEditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jface-utils Show documentation
Show all versions of jface-utils Show documentation
Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.
package io.github.albertus82.jface.preference.field;
import org.eclipse.swt.widgets.Composite;
import io.github.albertus82.jface.JFaceMessages;
abstract class AbstractIntegerComboFieldEditor> extends AbstractNumberComboFieldEditor {
protected AbstractIntegerComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) {
super(name, labelText, entryNamesAndValues, parent);
}
@Override
protected void updateTextLimit() {
int maxNumberLength = getDefaultTextLimit();
if (getMinValidValue() != null && getMaxValidValue() != null) {
maxNumberLength = Math.max(getMinValidValue().toString().length(), getMaxValidValue().toString().length());
}
setTextLimit(Math.max(maxNumberLength, getMaxLabelLength()));
}
@Override
protected void updateErrorMessage() {
if (getMinValidValue() == null && getMaxValidValue() == null) {
setErrorMessage(JFaceMessages.get("err.preferences.integer"));
}
else if (getMinValidValue() != null && getMaxValidValue() == null) {
setErrorMessage(JFaceMessages.get("err.preferences.integer.min", getMinValidValue()));
}
else if (getMinValidValue() == null && getMaxValidValue() != null) {
setErrorMessage(JFaceMessages.get("err.preferences.integer.max", getMaxValidValue()));
}
else {
setErrorMessage(JFaceMessages.get("err.preferences.integer.range", getMinValidValue(), getMaxValidValue()));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy