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
|
import org.springframework.security.core.GrantedAuthority;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
|
21
|
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
|
22
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
23
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
24
|
import eu.etaxonomy.taxeditor.newWizard.NewGrantedAuthorityWizard;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityLabelTextProvider;
|
27
|
|
28
|
/**
|
29
|
* @author a.kohlbecker
|
30
|
* @created Sept 12, 2011
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class GrantedAuthoritySelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<GrantedAuthorityImpl> {
|
34
|
|
35
|
public static GrantedAuthority select(Shell shell, ConversationHolder conversation, GrantedAuthorityImpl authority){
|
36
|
|
37
|
GrantedAuthoritySelectionDialog dialog = new GrantedAuthoritySelectionDialog(shell, conversation,
|
38
|
"Choose Granted Authority", false, GrantedAuthoritySelectionDialog.class.getCanonicalName(), authority);
|
39
|
|
40
|
return getSelectionFromDialog(dialog);
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* @param shell
|
45
|
* @param conversation
|
46
|
* @param title
|
47
|
* @param multi
|
48
|
* @param settings
|
49
|
* @param cdmObject
|
50
|
*/
|
51
|
protected GrantedAuthoritySelectionDialog(Shell shell,
|
52
|
ConversationHolder conversation, String title, boolean multi,
|
53
|
String settings, GrantedAuthorityImpl cdmObject) {
|
54
|
super(shell, conversation, title, multi, settings, cdmObject);
|
55
|
}
|
56
|
|
57
|
/* (non-Javadoc)
|
58
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
|
59
|
*/
|
60
|
@Override
|
61
|
protected void search() {
|
62
|
List<GrantedAuthorityImpl> authorities = CdmStore.getService(IGrantedAuthorityService.class).list(GrantedAuthorityImpl.class, null, null, null, null);
|
63
|
|
64
|
model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
|
65
|
|
66
|
for(GrantedAuthorityImpl authority : authorities){
|
67
|
|
68
|
model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
|
69
|
}
|
70
|
}
|
71
|
|
72
|
/* (non-Javadoc)
|
73
|
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
|
74
|
*/
|
75
|
@Override
|
76
|
protected String getNewWizardLinkText() {
|
77
|
return String.format("Create a new <a>%1s</a>", "GrantedAuthority ");
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
82
|
return new NewGrantedAuthorityWizard();
|
83
|
}
|
84
|
|
85
|
@Override
|
86
|
protected GrantedAuthorityImpl getPersistentObject(UUID uuid) {
|
87
|
return CdmStore.getService(IGrantedAuthorityService.class).load(uuid);
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
protected String getTitle(GrantedAuthorityImpl authority) {
|
92
|
return authority != null ? GrantedAuthorityLabelTextProvider.getText(authority) : "";
|
93
|
}
|
94
|
|
95
|
}
|