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
.dialog
.selection
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.swt
.widgets
.Shell
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
19 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
20 import eu
.etaxonomy
.cdm
.model
.common
.User
;
21 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewUserWizard
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * @created Mar 10, 2011
31 public class UserSelectionDialog
extends
32 AbstractFilteredCdmResourceSelectionDialog
<User
> {
41 public static User
select(Shell shell
, //ConversationHolder conversation,
43 UserSelectionDialog dialog
= new UserSelectionDialog(shell
, //conversation,
44 "Choose User", false, UserSelectionDialog
.class.getCanonicalName(), user
);
45 return getSelectionFromDialog(dialog
);
56 protected UserSelectionDialog(Shell shell
, //ConversationHolder conversation,
57 String title
, boolean multi
, String settings
, User cdmObject
) {
58 super(shell
, //conversation,
59 title
, multi
, settings
, cdmObject
);
63 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
66 protected void callService(String pattern
) {
67 List
<User
> users
= CdmStore
.getService(IUserService
.class).list(User
.class, null, null, null, null);
69 model
= new ArrayList
<UuidAndTitleCache
<User
>>();
71 for(User user
: users
){
72 if (pattern
== null || user
.getUsername().matches(CdmUtils
.quoteRegExWithWildcard(pattern
) + ".*")) {
73 model
.add(new UuidAndTitleCache
<User
>(User
.class, user
.getUuid(), user
.getId(), String
.format("%s, %s", user
.getUsername(), user
.getPerson())));
79 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
82 protected String
[] getNewWizardText() {
87 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
90 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
91 return new NewUserWizard();
95 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
98 protected User
getPersistentObject(UUID uuid
) {
99 return CdmStore
.getService(IUserService
.class).load(uuid
);
103 protected String
getTitle(User user
) {
104 return user
!= null ? user
.getUsername() : "";