Project

General

Profile

Download (2.71 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.ui.password;
12

    
13
import org.eclipse.jface.wizard.WizardDialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.events.SelectionListener;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Label;
19

    
20
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22
import eu.etaxonomy.cdm.api.service.IUserService;
23
import eu.etaxonomy.cdm.model.common.User;
24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
30
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
31

    
32
/**
33
 * @author n.hoffmann
34
 * @created Mar 10, 2011
35
 * @version 1.0
36
 */
37
public class EditPasswordElement extends AbstractCdmFormElement implements SelectionListener, IConversationEnabled{
38

    
39
	private User user;
40
	private Button button;
41

    
42
	private ConversationHolder conversation;
43

    
44
	public EditPasswordElement(CdmFormFactory formFactory,
45
			ICdmFormElement formElement, String labelString, User user, ConversationHolder conversation) {
46
		super(formFactory, formElement);
47

    
48
		this.conversation = conversation;
49
		this.user = user;
50

    
51
		Label label = formFactory.createLabel(getLayoutComposite(), null);
52
		addControl(label);
53

    
54
		String buttonLabelString = (labelString != null) ? labelString : "Change Password";
55

    
56
		button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
57
		button.setLayoutData(LayoutConstants.RIGHT());
58
		addControl(button);
59

    
60
		button.addSelectionListener(this);
61
	}
62

    
63
	@Override
64
	public void widgetSelected(SelectionEvent e) {
65
		if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
66
			MessagingUtils.warningDialog("Username does not exist", this, "Please create or save user '" + user.getUsername() + "' before changing password");
67
		} else {
68
			PasswordWizard wizard = new PasswordWizard(user, conversation);
69
			WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
70
			dialog.open();
71
		}
72
	}
73

    
74
	@Override
75
	public void widgetDefaultSelected(SelectionEvent e) {}
76

    
77
	@Override
78
	public void update(CdmDataChangeMap arg0) {}
79

    
80
	@Override
81
	public ConversationHolder getConversationHolder() {
82
		return conversation;
83
	}
84

    
85

    
86
}
(1-1/3)