3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.forms
.password
;
13 import org
.eclipse
.jface
.wizard
.Wizard
;
14 import org
.eclipse
.swt
.widgets
.Display
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
19 import eu
.etaxonomy
.cdm
.model
.common
.User
;
20 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
23 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
;
27 * @created Mar 10, 2011
30 public class PasswordWizard
extends Wizard
implements IConversationEnabled
{
32 private PasswordWizardPage passwordPage
;
34 private ConversationHolder conversation
;
36 public PasswordWizard(ConversationHolder conversation
, User user
){
37 this.conversation
= conversation
;
42 * @see org.eclipse.jface.wizard.Wizard#addPages()
45 public void addPages() {
46 CdmFormFactory formFactory
= new CdmFormFactory(Display
.getDefault());
48 passwordPage
= new PasswordWizardPage(formFactory
, getConversationHolder(), user
);
49 addPage(passwordPage
);
53 * @see org.eclipse.jface.wizard.Wizard#performFinish()
56 public boolean performFinish() {
57 String userName
= user
.getUsername();
58 ConversationHolder internalConversation
= CdmStore
.getLoginManager().getConversationHolder();
59 internalConversation
.bind();
61 if(CdmStore
.getLoginManager().isAdmin()){
62 CdmStore
.getService(IUserService
.class).changePasswordForUser(userName
, passwordPage
.getNewPassword());
64 CdmStore
.getService(IUserService
.class).changePassword(passwordPage
.getOldPassword(), passwordPage
.getNewPassword());
66 internalConversation
.commit();
69 StoreUtil
.errorDialog("Error while changing password", getClass(), "There was a problem changing the password.", e
);
77 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
80 public void update(CdmDataChangeMap arg0
) {
81 // TODO Auto-generated method stub
86 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
89 public ConversationHolder
getConversationHolder() {