e61f23cdee1065997a8f856d48daddf29f51285a
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / handler / OpenPasswordWizzardHandler.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.handler;
12
13 import org.eclipse.core.commands.AbstractHandler;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.core.commands.IHandler;
17 import org.eclipse.jface.wizard.WizardDialog;
18
19 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
20 import eu.etaxonomy.cdm.model.common.User;
21 import eu.etaxonomy.taxeditor.model.AbstractUtility;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23 import eu.etaxonomy.taxeditor.ui.password.PasswordWizard;
24
25 /**
26 * <p>ShowLoginWindowHandler class.</p>
27 *
28 * @author n.hoffmann
29 * @created Aug 7, 2009
30 * @version 1.0
31 */
32 public class OpenPasswordWizzardHandler extends AbstractHandler implements IHandler{
33
34 /* (non-Javadoc)
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36 */
37 /** {@inheritDoc} */
38 @Override
39 public Object execute(ExecutionEvent event) throws ExecutionException {
40
41 Object principal = CdmStore.getCurrentAuthentiation().getPrincipal();
42
43 if(principal instanceof User){
44 ConversationHolder conversation = CdmStore.createConversation();
45
46 PasswordWizard wizard = new PasswordWizard(conversation, (User)principal);
47 WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
48
49 dialog.open();
50
51 // clean up
52 conversation.commit();
53 conversation.unbind();
54 conversation.close();
55 } else {
56 // should never happen, log an error
57 AbstractUtility.error(OpenPasswordWizzardHandler.class, "The principal currently authenticated is not a eu.etaxonomy.cdm.model.common.User", null);
58 }
59
60 return null;
61
62 }
63
64
65
66 }