Project

General

Profile

Download (3.31 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
	/**
45
	 * @param formFactory
46
	 * @param formElement
47
	 */
48
	public EditPasswordElement(CdmFormFactory formFactory,
49
			ICdmFormElement formElement, String labelString, User user, ConversationHolder conversation) {
50
		super(formFactory, formElement);
51
		
52
		this.conversation = conversation;
53
		this.user = user;
54
		
55
		Label label = formFactory.createLabel(getLayoutComposite(), null);
56
		addControl(label);
57
		
58
		String buttonLabelString = (labelString != null) ? labelString : "Change Password";
59
		
60
		button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
61
		button.setLayoutData(LayoutConstants.RIGHT());
62
		addControl(button);
63
		
64
		button.addSelectionListener(this);
65
	}
66

    
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
69
	 */
70
	@Override
71
	public void widgetSelected(SelectionEvent e) {
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
		}
79
	}
80

    
81
	/* (non-Javadoc)
82
	 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
83
	 */
84
	@Override
85
	public void widgetDefaultSelected(SelectionEvent e) {}
86

    
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
89
	 */
90
	@Override
91
	public void update(CdmDataChangeMap arg0) {}
92

    
93
	/* (non-Javadoc)
94
	 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
95
	 */
96
	@Override
97
	public ConversationHolder getConversationHolder() {
98
		return conversation;
99
	}
100

    
101

    
102
}
(1-1/3)