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
.IGroupService
;
19 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
21 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
24 import eu
.etaxonomy
.taxeditor
.newWizard
.NewGroupWizard
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * @created Mar 10, 2011
32 public class GroupSelectionDialog
extends
33 AbstractFilteredCdmResourceSelectionDialog
<Group
> {
37 public static Group
select(Shell shell
, //ConversationHolder conversation,
38 Group group
, User user
){
39 GroupSelectionDialog dialog
= new GroupSelectionDialog(shell
, //conversation,
40 "Choose Group", false, GroupSelectionDialog
.class.getCanonicalName(), group
, user
);
41 return getSelectionFromDialog(dialog
);
52 protected GroupSelectionDialog(Shell shell
,//ConversationHolder conversation,
53 String title
, boolean multi
,
54 String settings
, Group cdmObject
, User user
) {
55 super(shell
, //conversation,
56 title
, multi
, settings
, cdmObject
);
61 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
64 protected void callService(String pattern
) {
65 List
<Group
> groups
= CdmStore
.getService(IGroupService
.class).list(Group
.class, null, null, null, null);
67 model
= new ArrayList
<UuidAndTitleCache
<Group
>>();
69 for(Group group
: groups
){
70 if (pattern
== null || group
.getName().matches("(?i)"+CdmUtils
.quoteRegExWithWildcard(pattern
) + ".*")){
71 if (user
!= null && !user
.getGroups().isEmpty() && user
.getGroups().contains(group
)){
74 model
.add(new UuidAndTitleCache
<Group
>(Group
.class, group
.getUuid(), group
.getId(), String
.format("%s", group
.getName())));
80 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
83 protected String
[] getNewWizardText() {
88 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
91 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
92 return new NewGroupWizard();
96 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
99 protected Group
getPersistentObject(UUID uuid
) {
100 return CdmStore
.getService(IGroupService
.class).load(uuid
);
104 protected String
getTitle(Group group
) {
105 return group
!= null ? group
.getName() : "";