1 |
a60842d7
|
n.hoffmann
|
// $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 |
78222507
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
12 |
a60842d7
|
n.hoffmann
|
|
13 |
|
|
import java.util.ArrayList;
|
14 |
|
|
import java.util.List;
|
15 |
|
|
import java.util.UUID;
|
16 |
|
|
|
17 |
|
|
import org.eclipse.swt.widgets.Shell;
|
18 |
|
|
|
19 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20 |
|
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
21 |
|
|
import eu.etaxonomy.cdm.model.common.User;
|
22 |
|
|
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
|
23 |
|
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
24 |
|
|
import eu.etaxonomy.taxeditor.newWizard.NewUserWizard;
|
25 |
|
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* @author n.hoffmann
|
29 |
|
|
* @created Mar 10, 2011
|
30 |
|
|
* @version 1.0
|
31 |
|
|
*/
|
32 |
|
|
public class UserSelectionDialog extends
|
33 |
|
|
AbstractFilteredCdmResourceSelectionDialog<User> {
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
*
|
37 |
|
|
* @param shell
|
38 |
|
|
* @param conversation
|
39 |
|
|
* @param user
|
40 |
|
|
* @return
|
41 |
|
|
*/
|
42 |
|
|
public static User select(Shell shell, ConversationHolder conversation, User user){
|
43 |
|
|
UserSelectionDialog dialog = new UserSelectionDialog(shell, conversation,
|
44 |
|
|
"Choose User", false, UserSelectionDialog.class.getCanonicalName(), user);
|
45 |
|
|
return getSelectionFromDialog(dialog);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* @param shell
|
50 |
|
|
* @param conversation
|
51 |
|
|
* @param title
|
52 |
|
|
* @param multi
|
53 |
|
|
* @param settings
|
54 |
|
|
* @param cdmObject
|
55 |
|
|
*/
|
56 |
|
|
protected UserSelectionDialog(Shell shell, ConversationHolder conversation,
|
57 |
|
|
String title, boolean multi, String settings, User cdmObject) {
|
58 |
|
|
super(shell, conversation, title, multi, settings, cdmObject);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/* (non-Javadoc)
|
62 |
|
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
|
63 |
|
|
*/
|
64 |
|
|
@Override
|
65 |
|
|
protected void initModel() {
|
66 |
|
|
List<User> users = CdmStore.getService(IUserService.class).list(User.class, null, null, null, null);
|
67 |
|
|
|
68 |
|
|
model = new ArrayList<UuidAndTitleCache<User>>();
|
69 |
|
|
|
70 |
|
|
for(User user : users){
|
71 |
|
|
model.add(new UuidAndTitleCache<User>(User.class, user.getUuid(),String.format("%s, %s", user.getUsername(), user.getPerson())));
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
/* (non-Javadoc)
|
76 |
|
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
|
77 |
|
|
*/
|
78 |
|
|
@Override
|
79 |
|
|
protected String getNewWizardLinkText() {
|
80 |
|
|
return "Create a new <A>User</A>.";
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
/* (non-Javadoc)
|
84 |
|
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
|
85 |
|
|
*/
|
86 |
|
|
@Override
|
87 |
|
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
88 |
|
|
return new NewUserWizard();
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
/* (non-Javadoc)
|
92 |
|
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
|
93 |
|
|
*/
|
94 |
|
|
@Override
|
95 |
|
|
protected User getPersistentObject(UUID uuid) {
|
96 |
|
|
return CdmStore.getService(IUserService.class).load(uuid);
|
97 |
|
|
}
|
98 |
|
|
|
99 |
b478a42f
|
n.hoffmann
|
@Override
|
100 |
|
|
protected String getTitle(User user) {
|
101 |
|
|
return user != null ? user.getUsername() : "";
|
102 |
|
|
}
|
103 |
|
|
|
104 |
a60842d7
|
n.hoffmann
|
}
|