package eu.etaxonomy.taxeditor.annotatedlineeditor.handler;
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Event;
if (key != null) {
if(!(key instanceof SpecimenOrObservationType)) {
String text = ((Event)event.getTrigger()).text;
- InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), "Create " + text, "Enter new " + text, "", null);
+
+ //FIXME : This should probably go into some ValidatorFactory
+ IInputValidator nonEmptyInputValidator = null;
+ //FIXME : This is a workaround to not allow empty strings in the
+ // input dialog for User and Group entities.
+ // Normally this should be default
+ // behaviour, so we need to discuss whether this handler
+ // should be used to handle the creating new entities of
+ // type other than User and Group.
+ // Once #4348 is fixed this check can be removed.
+ if(text.equals("User") || text.equals("Group")) {
+ nonEmptyInputValidator = new IInputValidator() {
+ public String isValid(String text) {
+ if(text == null || text.isEmpty()) {
+ return "Input cannot be empty";
+ }
+ return null;
+ }
+ };
+ }
+ InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event),
+ "Create " + text,
+ "Enter new " + text, "",
+ nonEmptyInputValidator);
+
if (dialog.open() != Window.CANCEL) {
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue());
}