Project

General

Profile

« Previous | Next » 

Revision 35a95f17

Added by Cherian Mathew over 9 years ago

ApplicationWorkbenchAdvisor : added comments
EditPasswordElement : Added to make sure user exists in db before changing password
UserDetailElement : Disabled user text field since User is immutable
NewObjectHandler : added non-empty validator for the case of User and Group

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java
133 133

  
134 134
	/**
135 135
	 * Custom status handler for handling scenarios which are 
136
	 * not handled by the editor (e.g. runtime exceptions)
136
	 * not handled by the editor (e.g. runtime exceptions).
137
	 * 
138
	 * The default {@link org.eclipse.ui.statushandlers.WorkbenchErrorHandler}
139
	 * is not used or extended because we need a handler for specific scenarios
140
	 * which displays a custom built error dialog.
137 141
	 * 
138 142
	 * @author cmathew
139 143
	 *
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.annotatedlineeditor.handler;
12 12

  
13
import java.net.URI;
14
import java.net.URISyntaxException;
15

  
13 16
import org.eclipse.core.commands.AbstractHandler;
14 17
import org.eclipse.core.commands.ExecutionEvent;
15 18
import org.eclipse.core.commands.ExecutionException;
19
import org.eclipse.jface.dialogs.IInputValidator;
16 20
import org.eclipse.jface.dialogs.InputDialog;
17 21
import org.eclipse.jface.window.Window;
18 22
import org.eclipse.swt.widgets.Event;
......
47 51
			if (key != null) {
48 52
				if(!(key instanceof SpecimenOrObservationType)) {
49 53
					String text = ((Event)event.getTrigger()).text; 
50
					InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), "Create " + text, "Enter new " + text, "", null); 
54
					
55
					//FIXME : This should probably go into some ValidatorFactory
56
					IInputValidator nonEmptyInputValidator = null;
57
					//FIXME : This is a workaround to not allow empty strings in the 
58
					//        input dialog for User and Group entities. 
59
					//        Normally this should be default
60
					//        behaviour, so we need to discuss whether this handler
61
					//        should be used to handle the creating new entities of
62
					//        type other than User and Group.
63
					//        Once #4348 is fixed this check can be removed.
64
					if(text.equals("User") || text.equals("Group")) {
65
						nonEmptyInputValidator = new IInputValidator() {
66
							public String isValid(String text) {							
67
								if(text == null || text.isEmpty()) {
68
									return "Input cannot be empty";
69
								}
70
								return null;
71
							}			
72
						};
73
					}
74
					InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), 
75
							"Create " + text, 
76
							"Enter new " + text, "",
77
							nonEmptyInputValidator); 
78

  
51 79
					if (dialog.open() != Window.CANCEL) { 
52 80
						((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue()); 
53 81
					}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/password/EditPasswordElement.java
19 19

  
20 20
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21 21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22
import eu.etaxonomy.cdm.api.service.IUserService;
22 23
import eu.etaxonomy.cdm.model.common.User;
23 24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
24 27
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
25 28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26 29
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
66 69
	 */
67 70
	@Override
68 71
	public void widgetSelected(SelectionEvent e) {
69
		PasswordWizard wizard = new PasswordWizard(user, conversation);
70
		WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
71
		
72
		dialog.open();
72
		if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
73
			MessagingUtils.warningDialog("Username does not exist", this, "Please create or save user '" + user.getUsername() + "' before changing password");
74
		} else {
75
			PasswordWizard wizard = new PasswordWizard(user, conversation);
76
			WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);		
77
			dialog.open();
78
		}
73 79
	}
74 80

  
75 81
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailElement.java
44 44
			int style) {
45 45
		text_username = formFactory.createTextWithLabelElement(formElement,
46 46
				"Username", entity.getUsername(), style);
47
		// Disabling the text field since the user entity is immutable
48
		text_username.setEnabled(false);
47 49

  
48 50
		if (userIsAuthenticated() || CdmStore.getLoginManager().isAdmin()) {
49 51
			formFactory.createEditPasswordElement(

Also available in: Unified diff