1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* 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
|
package eu.etaxonomy.taxeditor.ui.password;
|
10
|
|
11
|
import org.eclipse.jface.wizard.WizardDialog;
|
12
|
import org.eclipse.swt.SWT;
|
13
|
import org.eclipse.swt.events.SelectionEvent;
|
14
|
import org.eclipse.swt.events.SelectionListener;
|
15
|
import org.eclipse.swt.widgets.Button;
|
16
|
import org.eclipse.swt.widgets.Label;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
19
|
import eu.etaxonomy.cdm.model.permission.User;
|
20
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
21
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
22
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
23
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
28
|
|
29
|
/**
|
30
|
* @author n.hoffmann
|
31
|
* @created Mar 10, 2011
|
32
|
*/
|
33
|
public class EditPasswordElement
|
34
|
extends AbstractCdmFormElement
|
35
|
implements SelectionListener{
|
36
|
|
37
|
private User user;
|
38
|
private Button button;
|
39
|
|
40
|
public EditPasswordElement(CdmFormFactory formFactory,
|
41
|
ICdmFormElement formElement, String labelString, User user) {
|
42
|
super(formFactory, formElement);
|
43
|
|
44
|
this.user = user;
|
45
|
|
46
|
Label label = formFactory.createLabel(getLayoutComposite(), null);
|
47
|
addControl(label);
|
48
|
|
49
|
String buttonLabelString = (labelString != null) ? labelString : Messages.PasswordWizardPage_CHANGE_PASSWORD;
|
50
|
|
51
|
button = formFactory.createButton(getLayoutComposite(), buttonLabelString, SWT.PUSH);
|
52
|
button.setLayoutData(LayoutConstants.RIGHT());
|
53
|
addControl(button);
|
54
|
|
55
|
button.addSelectionListener(this);
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public void widgetSelected(SelectionEvent e) {
|
60
|
if(!CdmStore.getService(IUserService.class).userExists(user.getUsername())) {
|
61
|
MessagingUtils.warningDialog(Messages.EditPasswordElement_USERNAME_DOES_NOT_EXIST, this, String.format(Messages.EditPasswordElement_PLEASE_CREATE_OR_SAVE_USER, user.getUsername()));
|
62
|
} else {
|
63
|
PasswordWizard wizard = new PasswordWizard(user);
|
64
|
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
|
65
|
dialog.open();
|
66
|
}
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
71
|
|
72
|
|
73
|
}
|