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.Messages;
|
26
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
|
29
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
30
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
31
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
32
|
|
33
|
/**
|
34
|
* @author n.hoffmann
|
35
|
* @created Mar 10, 2011
|
36
|
* @version 1.0
|
37
|
*/
|
38
|
public class EditPasswordElement extends AbstractCdmFormElement implements SelectionListener, IConversationEnabled{
|
39
|
|
40
|
private User user;
|
41
|
private Button button;
|
42
|
|
43
|
private ConversationHolder conversation;
|
44
|
|
45
|
public EditPasswordElement(CdmFormFactory formFactory,
|
46
|
ICdmFormElement formElement, String labelString, User user, ConversationHolder conversation) {
|
47
|
super(formFactory, formElement);
|
48
|
|
49
|
this.conversation = conversation;
|
50
|
this.user = user;
|
51
|
|
52
|
Label label = formFactory.createLabel(getLayoutComposite(), null);
|
53
|
addControl(label);
|
54
|
|
55
|
String buttonLabelString = (labelString != null) ? labelString : Messages.PasswordWizardPage_CHANGE_PASSWORD;
|
56
|
|
57
|
button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
|
58
|
button.setLayoutData(LayoutConstants.RIGHT());
|
59
|
addControl(button);
|
60
|
|
61
|
button.addSelectionListener(this);
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public void widgetSelected(SelectionEvent e) {
|
66
|
if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
|
67
|
MessagingUtils.warningDialog(Messages.EditPasswordElement_USERNAME_DOES_NOT_EXIST, this, String.format(Messages.EditPasswordElement_PLEASE_CREATE_OR_SAVE_USER, user.getUsername()));
|
68
|
} else {
|
69
|
PasswordWizard wizard = new PasswordWizard(user, conversation);
|
70
|
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
|
71
|
dialog.open();
|
72
|
}
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
77
|
|
78
|
@Override
|
79
|
public void update(CdmDataChangeMap arg0) {}
|
80
|
|
81
|
@Override
|
82
|
public ConversationHolder getConversationHolder() {
|
83
|
return conversation;
|
84
|
}
|
85
|
|
86
|
|
87
|
}
|