3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
22 import eu
.etaxonomy
.cdm
.model
.common
.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
> {
35 public static Group
select(Shell shell
, ConversationHolder conversation
, Group group
){
36 GroupSelectionDialog dialog
= new GroupSelectionDialog(shell
, conversation
,
37 "Choose Group", false, GroupSelectionDialog
.class.getCanonicalName(), group
);
38 return getSelectionFromDialog(dialog
);
49 protected GroupSelectionDialog(Shell shell
,
50 ConversationHolder conversation
, String title
, boolean multi
,
51 String settings
, Group cdmObject
) {
52 super(shell
, conversation
, title
, multi
, settings
, cdmObject
);
56 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
59 protected void initModel() {
60 List
<Group
> groups
= CdmStore
.getService(IGroupService
.class).list(Group
.class, null, null, null, null);
62 model
= new ArrayList
<UuidAndTitleCache
<Group
>>();
64 for(Group group
: groups
){
65 model
.add(new UuidAndTitleCache
<Group
>(Group
.class, group
.getUuid(), group
.getId(), String
.format("%s", group
.getName())));
70 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
73 protected String
getNewWizardLinkText() {
74 return String
.format("Create a new <a>%1s</a>", "Group ");
78 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
81 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
82 return new NewGroupWizard();
86 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
89 protected Group
getPersistentObject(UUID uuid
) {
90 return CdmStore
.getService(IGroupService
.class).load(uuid
);
94 protected String
getTitle(Group group
) {
95 return group
!= null ? group
.getName() : "";