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
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
21 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewGroupWizard
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * @created Mar 10, 2011
31 public class GroupSelectionDialog
extends
32 AbstractFilteredCdmResourceSelectionDialog
<Group
> {
34 public static Group
select(Shell shell
, ConversationHolder conversation
, Group group
){
35 GroupSelectionDialog dialog
= new GroupSelectionDialog(shell
, conversation
,
36 "Choose Group", false, GroupSelectionDialog
.class.getCanonicalName(), group
);
37 return getSelectionFromDialog(dialog
);
48 protected GroupSelectionDialog(Shell shell
,
49 ConversationHolder conversation
, String title
, boolean multi
,
50 String settings
, Group cdmObject
) {
51 super(shell
, conversation
, title
, multi
, settings
, cdmObject
);
55 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
58 protected void search() {
59 List
<Group
> groups
= CdmStore
.getService(IGroupService
.class).list(Group
.class, null, null, null, null);
61 model
= new ArrayList
<UuidAndTitleCache
<Group
>>();
63 for(Group group
: groups
){
64 model
.add(new UuidAndTitleCache
<Group
>(Group
.class, group
.getUuid(), group
.getId(), String
.format("%s", group
.getName())));
69 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
72 protected String
[] getNewWizardText() {
73 return new String
[]{"Group "};
77 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
80 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
81 return new NewGroupWizard();
85 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
88 protected Group
getPersistentObject(UUID uuid
) {
89 return CdmStore
.getService(IGroupService
.class).load(uuid
);
93 protected String
getTitle(Group group
) {
94 return group
!= null ? group
.getName() : "";