Project

General

Profile

Download (3.04 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy 
5
 * http://www.e-taxonomy.eu
6
 * 
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.
9
 */
10

    
11
package eu.etaxonomy.taxeditor.ui.section.grantedAuthority;
12

    
13
import java.util.Collection;
14

    
15
import org.springframework.security.core.GrantedAuthority;
16

    
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.model.common.Group;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
20
import eu.etaxonomy.taxeditor.ui.dialog.selection.GrantedAuthoritySelectionDialog;
21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created Mar 9, 2011
28
 * @version 1.0
29
 */
30
public class GrantedAuthorityDetailSection extends
31
		AbstractEntityCollectionSection<Group, GrantedAuthority> {
32

    
33
	/**
34
	 * @param formFactory
35
	 * @param conversation
36
	 * @param parentElement
37
	 * @param title
38
	 * @param style
39
	 */
40
	public GrantedAuthorityDetailSection(CdmFormFactory formFactory,
41
			ConversationHolder conversation, ICdmFormElement parentElement,
42
			int style) {
43
		super(formFactory, conversation, parentElement, "Granted Authorities",
44
				style);
45
	}
46

    
47
	/*
48
	 * (non-Javadoc)
49
	 * 
50
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
51
	 * getCollection(java.lang.Object)
52
	 */
53
	@Override
54
	public Collection<GrantedAuthority> getCollection(Group entity) {
55
		return entity.getGrantedAuthorities();
56
	}
57

    
58
	/*
59
	 * (non-Javadoc)
60
	 * 
61
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
62
	 * createNewElement()
63
	 */
64
	@Override
65
	public GrantedAuthority createNewElement() {
66
//		StoreUtil
67
//				.warningDialog("Not implemented yet", getClass(),
68
//						"This functionality needs to be implemented in CDM Library first.");
69
		
70
		GrantedAuthority selection = GrantedAuthoritySelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
71
		return selection;
72
	}
73

    
74
	/*
75
	 * (non-Javadoc)
76
	 * 
77
	 * @see
78
	 * eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement
79
	 * (java.lang.Object)
80
	 */
81
	@Override
82
	public void addElement(GrantedAuthority element) {
83
		getEntity().addGrantedAuthority(element);
84
	}
85

    
86
	/*
87
	 * (non-Javadoc)
88
	 * 
89
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
90
	 * removeElement(java.lang.Object)
91
	 */
92
	@Override
93
	public void removeElement(GrantedAuthority element) {
94
		getEntity().removeGrantedAuthority(element);
95
	}
96

    
97
	/*
98
	 * (non-Javadoc)
99
	 * 
100
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
101
	 * getEmptyString()
102
	 */
103
	@Override
104
	public String getEmptyString() {
105
		return "No Granted Authorities yet.";
106
	}
107

    
108
	/*
109
	 * (non-Javadoc)
110
	 * 
111
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
112
	 * getTooltipString()
113
	 */
114
	@Override
115
	protected String getTooltipString() {
116
		return "Add a Granted Authority";
117
	}
118

    
119
}
(3-3/4)