1
|
/**
|
2
|
* Copyright (C) 2012 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.section.grantedAuthority;
|
11
|
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
|
15
|
import eu.etaxonomy.cdm.model.common.Group;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
21
|
|
22
|
/**
|
23
|
* @author a.kohlbecker
|
24
|
* @date Sept 12 2012
|
25
|
*
|
26
|
*/
|
27
|
public class GrantedAuthorityCollectionElement extends AbstractEntityCollectionElement<GrantedAuthorityImpl> {
|
28
|
|
29
|
private EntitySelectionElement<GrantedAuthorityImpl> selection_authority;
|
30
|
private Group grantedAuthorityUser;
|
31
|
|
32
|
|
33
|
public GrantedAuthorityCollectionElement(CdmFormFactory formFactory,
|
34
|
AbstractFormSection section, GrantedAuthorityImpl entity, Group group,
|
35
|
SelectionListener removeListener, int style) {
|
36
|
super(formFactory, section, entity, removeListener, null, style);
|
37
|
this.grantedAuthorityUser = group;
|
38
|
// TODO Auto-generated constructor stub
|
39
|
}
|
40
|
|
41
|
/* (non-Javadoc)
|
42
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#setEntity(java.lang.Object)
|
43
|
*/
|
44
|
@Override
|
45
|
public void setEntity(GrantedAuthorityImpl entity) {
|
46
|
this.entity = entity;
|
47
|
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, int)
|
52
|
*/
|
53
|
@Override
|
54
|
public void createControls(ICdmFormElement element, int style) {
|
55
|
selection_authority = formFactory.createSelectionElement(
|
56
|
GrantedAuthorityImpl.class, //getConversationHolder(),
|
57
|
element, "", getEntity(), EntitySelectionElement.SELECTABLE, style);
|
58
|
}
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent(java.lang.Object)
|
62
|
*/
|
63
|
@Override
|
64
|
public void handleEvent(Object eventSource) {
|
65
|
if (eventSource == selection_authority) {
|
66
|
GrantedAuthorityImpl oldGrantedAuthority = entity;
|
67
|
grantedAuthorityUser.removeGrantedAuthority(entity);
|
68
|
|
69
|
setEntity(selection_authority.getEntity());
|
70
|
grantedAuthorityUser.addGrantedAuthority(entity);
|
71
|
|
72
|
}
|
73
|
}
|
74
|
|
75
|
|
76
|
}
|