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());
}
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
*/
@Override
public void widgetSelected(SelectionEvent e) {
- PasswordWizard wizard = new PasswordWizard(user, conversation);
- WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
-
- dialog.open();
+ if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
+ MessagingUtils.warningDialog("Username does not exist", this, "Please create or save user '" + user.getUsername() + "' before changing password");
+ } else {
+ PasswordWizard wizard = new PasswordWizard(user, conversation);
+ WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
+ dialog.open();
+ }
}
/* (non-Javadoc)