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.user.wizard;
|
12
|
|
13
|
import org.eclipse.core.runtime.Status;
|
14
|
import org.eclipse.jface.wizard.Wizard;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.common.User;
|
17
|
import eu.etaxonomy.taxeditor.operations.AbstractPostOperation;
|
18
|
import eu.etaxonomy.taxeditor.operations.CreateUserOperation;
|
19
|
import eu.etaxonomy.taxeditor.operations.EditUserOperation;
|
20
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
21
|
import eu.etaxonomy.taxeditor.user.view.UserManagerView;
|
22
|
|
23
|
/**
|
24
|
* <p>UserWizard class.</p>
|
25
|
*
|
26
|
* @author n.hoffmann
|
27
|
* @created 02.07.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class UserWizard extends Wizard {
|
31
|
private User user;
|
32
|
private UserWizardPage page;
|
33
|
private UserManagerView view;
|
34
|
private boolean createMode;
|
35
|
|
36
|
/**
|
37
|
* <p>Constructor for UserWizard.</p>
|
38
|
*
|
39
|
* @param view a {@link eu.etaxonomy.taxeditor.user.view.UserManagerView} object.
|
40
|
*/
|
41
|
public UserWizard(UserManagerView view){
|
42
|
this.view = view;
|
43
|
setWindowTitle("User Wizard");
|
44
|
createMode = true;
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* <p>Constructor for UserWizard.</p>
|
49
|
*
|
50
|
* @param view a {@link eu.etaxonomy.taxeditor.user.view.UserManagerView} object.
|
51
|
* @param user a {@link eu.etaxonomy.cdm.model.common.User} object.
|
52
|
*/
|
53
|
public UserWizard(UserManagerView view, User user){
|
54
|
this(view);
|
55
|
if(user != null){
|
56
|
this.user = user;
|
57
|
createMode = false;
|
58
|
}
|
59
|
}
|
60
|
|
61
|
/* (non-Javadoc)
|
62
|
* @see org.eclipse.jface.wizard.Wizard#addPages()
|
63
|
*/
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void addPages() {
|
67
|
super.addPages();
|
68
|
|
69
|
page = new UserWizardPage(user);
|
70
|
|
71
|
addPage(page);
|
72
|
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
77
|
*/
|
78
|
/** {@inheritDoc} */
|
79
|
@Override
|
80
|
public boolean performFinish() {
|
81
|
|
82
|
AbstractPostOperation operation;
|
83
|
if(createMode){
|
84
|
operation = new CreateUserOperation("Create User",
|
85
|
StoreUtil.getUndoContext(), page.getUser(), view, view);
|
86
|
}else{
|
87
|
operation = new EditUserOperation("Edit User",
|
88
|
StoreUtil.getUndoContext(), page.getUser(), view, view);
|
89
|
}
|
90
|
|
91
|
return StoreUtil.executeOperation(operation) == Status.OK_STATUS ? true : false;
|
92
|
}
|
93
|
|
94
|
}
|