1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.eclipse.swt.widgets.Shell;
|
17
|
|
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;
|
25
|
|
26
|
/**
|
27
|
* @author n.hoffmann
|
28
|
* @created Mar 10, 2011
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class GroupSelectionDialog extends
|
32
|
AbstractFilteredCdmResourceSelectionDialog<Group> {
|
33
|
|
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);
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* @param shell
|
42
|
* @param conversation
|
43
|
* @param title
|
44
|
* @param multi
|
45
|
* @param settings
|
46
|
* @param cdmObject
|
47
|
*/
|
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);
|
52
|
}
|
53
|
|
54
|
/* (non-Javadoc)
|
55
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
|
56
|
*/
|
57
|
@Override
|
58
|
protected void initModel() {
|
59
|
List<Group> groups = CdmStore.getService(IGroupService.class).list(Group.class, null, null, null, null);
|
60
|
|
61
|
model = new ArrayList<UuidAndTitleCache<Group>>();
|
62
|
|
63
|
for(Group group : groups){
|
64
|
model.add(new UuidAndTitleCache<Group>(Group.class, group.getUuid(), group.getId(), String.format("%s", group.getName())));
|
65
|
}
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
|
70
|
*/
|
71
|
@Override
|
72
|
protected String getNewWizardLinkText() {
|
73
|
return String.format("Create a new <a>%1s</a>", "Group ");
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
|
78
|
*/
|
79
|
@Override
|
80
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
81
|
return new NewGroupWizard();
|
82
|
}
|
83
|
|
84
|
/* (non-Javadoc)
|
85
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
|
86
|
*/
|
87
|
@Override
|
88
|
protected Group getPersistentObject(UUID uuid) {
|
89
|
return CdmStore.getService(IGroupService.class).load(uuid);
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
protected String getTitle(Group group) {
|
94
|
return group != null ? group.getName() : "";
|
95
|
}
|
96
|
|
97
|
}
|