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
;
17 import org
.springframework
.security
.core
.GrantedAuthority
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IGrantedAuthorityService
;
20 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
21 import eu
.etaxonomy
.cdm
.model
.permission
.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
;
29 * @author a.kohlbecker
30 * @created Sept 12, 2011
32 public class GrantedAuthoritySelectionDialog
33 extends AbstractFilteredCdmResourceSelectionDialog
<GrantedAuthorityImpl
> {
35 public static GrantedAuthority
select(Shell shell
, //ConversationHolder conversation,
36 GrantedAuthorityImpl authority
){
38 GrantedAuthoritySelectionDialog dialog
= new GrantedAuthoritySelectionDialog(shell
,//conversation,
39 "Choose Granted Authority", false, GrantedAuthoritySelectionDialog
.class.getCanonicalName(), authority
);
41 return getSelectionFromDialog(dialog
);
44 protected GrantedAuthoritySelectionDialog(Shell shell
,//ConversationHolder conversation,
45 String title
, boolean multi
,
46 String settings
, GrantedAuthorityImpl cdmObject
) {
47 super(shell
, //conversation,
48 title
, multi
, settings
, cdmObject
);
52 protected void callService(String pattern
) {
53 List
<GrantedAuthorityImpl
> authorities
= CdmStore
.getService(IGrantedAuthorityService
.class).list(GrantedAuthorityImpl
.class, null, null, null, null);
55 model
= new ArrayList
<>();
57 for(GrantedAuthorityImpl authority
: authorities
){
58 if ( pattern
== null || authority
.getAuthority().matches(CdmUtils
.quoteRegExWithWildcard(pattern
) +".*")){
59 model
.add(new UuidAndTitleCache
<>(GrantedAuthorityImpl
.class, authority
.getUuid(), authority
.getId(), String
.format("%s", GrantedAuthorityLabelTextProvider
.getText(authority
))));
65 protected String
[] getNewWizardText() {
66 return new String
[]{"New GrantedAuthority"};
70 protected AbstractNewEntityWizard
<GrantedAuthorityImpl
> getNewEntityWizard(String parameter
) {
71 return new NewGrantedAuthorityWizard();
75 protected GrantedAuthorityImpl
getPersistentObject(UUID uuid
) {
76 return CdmStore
.getService(IGrantedAuthorityService
.class).load(uuid
);
80 protected String
getTitle(GrantedAuthorityImpl authority
) {
81 return authority
!= null ? GrantedAuthorityLabelTextProvider
.getText(authority
) : "";