Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
1 a60842d7 n.hoffmann
/**
2
* Copyright (C) 2007 EDIT
3 144153b3 Patrick Plitzner
* European Distributed Institute of Taxonomy
4 a60842d7 n.hoffmann
* http://www.e-taxonomy.eu
5 144153b3 Patrick Plitzner
*
6 a60842d7 n.hoffmann
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
10 78222507 n.hoffmann
package eu.etaxonomy.taxeditor.ui.password;
11 a60842d7 n.hoffmann
12
import org.eclipse.jface.wizard.WizardDialog;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.events.SelectionListener;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Label;
18
19
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
20
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
21 35a95f17 Cherian Mathew
import eu.etaxonomy.cdm.api.service.IUserService;
22 a60842d7 n.hoffmann
import eu.etaxonomy.cdm.model.common.User;
23
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
24 a86dbf9a Patrick Plitzner
import eu.etaxonomy.taxeditor.l10n.Messages;
25 35a95f17 Cherian Mathew
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27 78222507 n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29 dacb59c9 Patric Plitzner
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
30 23783f7a n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
31 a60842d7 n.hoffmann
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 144153b3 Patrick Plitzner
44 a60842d7 n.hoffmann
	public EditPasswordElement(CdmFormFactory formFactory,
45
			ICdmFormElement formElement, String labelString, User user, ConversationHolder conversation) {
46
		super(formFactory, formElement);
47 144153b3 Patrick Plitzner
48 a60842d7 n.hoffmann
		this.conversation = conversation;
49 59351073 n.hoffmann
		this.user = user;
50 144153b3 Patrick Plitzner
51 a60842d7 n.hoffmann
		Label label = formFactory.createLabel(getLayoutComposite(), null);
52
		addControl(label);
53 144153b3 Patrick Plitzner
54 41d514e3 Patrick Plitzner
		String buttonLabelString = (labelString != null) ? labelString : Messages.PasswordWizardPage_CHANGE_PASSWORD;
55 144153b3 Patrick Plitzner
56 a60842d7 n.hoffmann
		button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
57 23783f7a n.hoffmann
		button.setLayoutData(LayoutConstants.RIGHT());
58 a60842d7 n.hoffmann
		addControl(button);
59 144153b3 Patrick Plitzner
60 a60842d7 n.hoffmann
		button.addSelectionListener(this);
61
	}
62
63
	@Override
64
	public void widgetSelected(SelectionEvent e) {
65 35a95f17 Cherian Mathew
		if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
66 41d514e3 Patrick Plitzner
			MessagingUtils.warningDialog(Messages.EditPasswordElement_USERNAME_DOES_NOT_EXIST, this, String.format(Messages.EditPasswordElement_PLEASE_CREATE_OR_SAVE_USER, user.getUsername()));
67 35a95f17 Cherian Mathew
		} else {
68
			PasswordWizard wizard = new PasswordWizard(user, conversation);
69 144153b3 Patrick Plitzner
			WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
70 35a95f17 Cherian Mathew
			dialog.open();
71
		}
72 a60842d7 n.hoffmann
	}
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
}