2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.password
;
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
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
22 import eu
.etaxonomy
.cdm
.model
.common
.User
;
23 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
24 import eu
.etaxonomy
.taxeditor
.Messages
;
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
;
34 * @created Mar 10, 2011
37 public class EditPasswordElement
extends AbstractCdmFormElement
implements SelectionListener
, IConversationEnabled
{
40 private Button button
;
42 private ConversationHolder conversation
;
44 public EditPasswordElement(CdmFormFactory formFactory
,
45 ICdmFormElement formElement
, String labelString
, User user
, ConversationHolder conversation
) {
46 super(formFactory
, formElement
);
48 this.conversation
= conversation
;
51 Label label
= formFactory
.createLabel(getLayoutComposite(), null);
54 String buttonLabelString
= (labelString
!= null) ? labelString
: Messages
.PasswordWizardPage_CHANGE_PASSWORD
;
56 button
= formFactory
.createButton(getLayoutComposite(), buttonLabelString
, SWT
.PUSH
);
57 button
.setLayoutData(LayoutConstants
.RIGHT());
60 button
.addSelectionListener(this);
64 public void widgetSelected(SelectionEvent e
) {
65 if(!CdmStore
.getService(IUserService
.class).userExists(user
.getUsername())) {
66 MessagingUtils
.warningDialog(Messages
.EditPasswordElement_USERNAME_DOES_NOT_EXIST
, this, String
.format(Messages
.EditPasswordElement_PLEASE_CREATE_OR_SAVE_USER
, user
.getUsername()));
68 PasswordWizard wizard
= new PasswordWizard(user
, conversation
);
69 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
75 public void widgetDefaultSelected(SelectionEvent e
) {}
78 public void update(CdmDataChangeMap arg0
) {}
81 public ConversationHolder
getConversationHolder() {