merging in latest changes from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / password / EditPasswordElement.java
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.model.common.User;
23 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
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 * @version 1.0
33 */
34 public class EditPasswordElement extends AbstractCdmFormElement implements SelectionListener, IConversationEnabled{
35
36 private User user;
37 private Button button;
38
39 private ConversationHolder conversation;
40
41 /**
42 * @param formFactory
43 * @param formElement
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 : "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 /* (non-Javadoc)
65 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
66 */
67 @Override
68 public void widgetSelected(SelectionEvent e) {
69 PasswordWizard wizard = new PasswordWizard(conversation, user);
70 WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
71
72 dialog.open();
73 }
74
75 /* (non-Javadoc)
76 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
77 */
78 @Override
79 public void widgetDefaultSelected(SelectionEvent e) {}
80
81 /* (non-Javadoc)
82 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
83 */
84 @Override
85 public void update(CdmDataChangeMap arg0) {}
86
87 /* (non-Javadoc)
88 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
89 */
90 @Override
91 public ConversationHolder getConversationHolder() {
92 return conversation;
93 }
94
95
96 }