All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.albertus82.jface.preference.field.AbstractIntegerComboFieldEditor Maven / Gradle / Ivy

Go to download

Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.

There is a newer version: 20.1.0
Show newest version
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