Revision 80379c19
Added by Katja Luther almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityRow.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
29 | 29 |
|
30 | 30 |
/** |
31 | 31 |
* Row widget for editing a single CDM Authority |
32 |
*
|
|
32 |
* |
|
33 | 33 |
* @author cmathew |
34 | 34 |
* @created Mar 28, 2013 |
35 | 35 |
* |
... | ... | |
41 | 41 |
private Label lblUuid; |
42 | 42 |
private CRUDOperationChooser operationChooser; |
43 | 43 |
private Button btnDelete; |
44 |
|
|
44 |
|
|
45 | 45 |
private GrantedAuthorityImpl grantedAuthorityI; |
46 | 46 |
private Label lblDirtyFlag; |
47 |
|
|
47 |
|
|
48 | 48 |
private CdmAuthorityCompositeViewer cdmaModel; |
49 | 49 |
private Label lblType; |
50 |
|
|
50 |
|
|
51 | 51 |
/** |
52 | 52 |
* Create the composite, made up of 5 elements : |
53 |
* 1. '*' or depending on whether the row is being edited
|
|
54 |
* 2. Classname of entity (e.g. TAXONNODE)
|
|
55 |
* 3. Uuid of entity
|
|
56 |
* 4. CRUD operations edit widget (this is essentially 4 checkboxes to select the 4 possible operations)
|
|
57 |
* 5. Delete button (to delete the row)
|
|
58 |
*
|
|
53 |
* 1. '*' or depending on whether the row is being edited |
|
54 |
* 2. Classname of entity (e.g. TAXONNODE) |
|
55 |
* 3. Uuid of entity |
|
56 |
* 4. CRUD operations edit widget (this is essentially 4 checkboxes to select the 4 possible operations) |
|
57 |
* 5. Delete button (to delete the row) |
|
58 |
* |
|
59 | 59 |
* @param parent |
60 | 60 |
* @param style |
61 | 61 |
*/ |
62 | 62 |
public CdmAuthorityRow(Composite parent, int style) { |
63 | 63 |
super(parent, SWT.NONE); |
64 | 64 |
addDisposeListener(new DisposeListener() { |
65 |
public void widgetDisposed(DisposeEvent e) { |
|
65 |
@Override |
|
66 |
public void widgetDisposed(DisposeEvent e) { |
|
66 | 67 |
toolkit.dispose(); |
67 | 68 |
} |
68 | 69 |
}); |
69 | 70 |
toolkit.adapt(this); |
70 | 71 |
toolkit.paintBordersFor(this); |
71 | 72 |
setLayout(new GridLayout(6, false)); |
72 |
|
|
73 | 73 |
|
74 |
|
|
74 |
|
|
75 |
|
|
75 | 76 |
lblDirtyFlag = new Label(this, SWT.NONE); |
76 | 77 |
lblDirtyFlag.setAlignment(SWT.CENTER); |
77 | 78 |
GridData gd_lblDirtyFlag = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); |
... | ... | |
79 | 80 |
lblDirtyFlag.setLayoutData(gd_lblDirtyFlag); |
80 | 81 |
toolkit.adapt(lblDirtyFlag, true, true); |
81 | 82 |
lblDirtyFlag.setText("*"); |
82 |
|
|
83 |
|
|
83 | 84 |
lblType = new Label(this, SWT.BORDER); |
84 | 85 |
GridData gd_lblType = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); |
85 | 86 |
gd_lblType.heightHint = 30; |
... | ... | |
88 | 89 |
lblType.setText("Type"); |
89 | 90 |
lblType.setAlignment(SWT.CENTER); |
90 | 91 |
toolkit.adapt(lblType, true, true); |
91 |
|
|
92 |
|
|
92 | 93 |
lblEntity = new Label(this, SWT.BORDER | SWT.WRAP | SWT.CENTER); |
93 | 94 |
GridData gd_lblEntity = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); |
94 | 95 |
gd_lblEntity.heightHint = 30; |
... | ... | |
97 | 98 |
lblEntity.setAlignment(SWT.CENTER); |
98 | 99 |
toolkit.adapt(lblEntity, true, true); |
99 | 100 |
lblEntity.setText("Entity"); |
100 |
|
|
101 |
|
|
101 |
|
|
102 |
|
|
102 | 103 |
operationChooser = new CRUDOperationChooser(this, SWT.BORDER); |
103 | 104 |
operationChooser.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); |
104 | 105 |
toolkit.adapt(operationChooser); |
105 | 106 |
toolkit.paintBordersFor(operationChooser); |
106 |
|
|
107 |
|
|
107 | 108 |
btnDelete = new Button(this, SWT.NONE); |
108 | 109 |
|
109 | 110 |
btnDelete.setImage(ImageResources.getImage(ImageResources.TRASH_ICON)); |
... | ... | |
115 | 116 |
cdmaModel.removeCdmAuthority(grantedAuthorityI); |
116 | 117 |
} |
117 | 118 |
} |
118 |
});
|
|
119 |
|
|
119 |
}); |
|
120 |
|
|
120 | 121 |
toolkit.adapt(btnDelete, true, true); |
121 | 122 |
|
122 | 123 |
} |
123 | 124 |
|
124 | 125 |
/** |
125 | 126 |
* Sets the dirty flag for this row |
126 |
*
|
|
127 |
* |
|
127 | 128 |
* @param isDirty |
128 | 129 |
*/ |
129 | 130 |
public void setDirty(boolean isDirty) { |
... | ... | |
133 | 134 |
lblDirtyFlag.setText(" "); |
134 | 135 |
} |
135 | 136 |
} |
136 |
|
|
137 |
|
|
137 | 138 |
/** |
138 | 139 |
* Create a {@link CdmAuthority} from a {@link GrantedAuthorityImpl} and create a row from it. |
139 |
*
|
|
140 |
* |
|
140 | 141 |
* @param cdmaModel |
141 | 142 |
* @param grantedAuthorityI |
142 | 143 |
* @param isDirty |
143 | 144 |
*/ |
144 | 145 |
public void setRowCdmAuthority(CdmAuthorityCompositeViewer cdmaModel, GrantedAuthorityImpl grantedAuthorityI, boolean isDirty, boolean showUuid) { |
145 |
this.grantedAuthorityI = grantedAuthorityI;
|
|
146 |
this.grantedAuthorityI = grantedAuthorityI; |
|
146 | 147 |
this.cdmaModel = cdmaModel; |
147 |
|
|
148 |
|
|
148 | 149 |
try { |
149 | 150 |
CdmAuthority cdmAuthority = CdmAuthority.fromGrantedAuthority(grantedAuthorityI); |
150 | 151 |
|
... | ... | |
154 | 155 |
lblType.setText(entityStr); |
155 | 156 |
String targetLabelText = GrantedAuthorityLabelTextProvider.getTargetText(cdmAuthority); |
156 | 157 |
lblEntity.setText(targetLabelText); |
157 |
|
|
158 |
|
|
158 | 159 |
setUuidCellVisible(showUuid); |
159 | 160 |
if(lblUuid != null) { |
160 |
String targetUuid = cdmAuthority.getTargetUUID().toString(); |
|
161 |
lblUuid.setText(targetUuid); |
|
161 |
if (cdmAuthority.getTargetUUID() != null){ |
|
162 |
String targetUuid = cdmAuthority.getTargetUUID().toString(); |
|
163 |
lblUuid.setText(targetUuid); |
|
164 |
} |
|
165 |
else{ |
|
166 |
lblUuid.setText("Uuid"); |
|
167 |
} |
|
168 |
|
|
162 | 169 |
} |
163 |
|
|
164 |
operationChooser.setAuthority(cdmaModel, grantedAuthorityI, cdmAuthority);
|
|
165 |
|
|
170 |
|
|
171 |
operationChooser.setAuthority(cdmaModel, grantedAuthorityI, cdmAuthority); |
|
172 |
|
|
166 | 173 |
} catch (Exception e) { |
167 | 174 |
// TODO Auto-generated catch block |
168 | 175 |
e.printStackTrace(); |
169 | 176 |
} |
170 | 177 |
|
171 | 178 |
} |
172 |
|
|
179 |
|
|
173 | 180 |
public void setUuidCellVisible(boolean visible) { |
174 | 181 |
if(visible) { |
175 | 182 |
if(lblUuid == null) { |
176 | 183 |
createUuidCell(); |
177 | 184 |
} |
178 | 185 |
lblUuid.moveAbove(operationChooser); |
179 |
|
|
186 |
|
|
180 | 187 |
} else { |
181 | 188 |
if(lblUuid != null) { |
182 | 189 |
lblUuid.dispose(); |
... | ... | |
185 | 192 |
} |
186 | 193 |
layout(); |
187 | 194 |
} |
188 |
|
|
195 |
|
|
189 | 196 |
private void createUuidCell() { |
190 | 197 |
lblUuid = new Label(this, SWT.BORDER | SWT.CENTER); |
191 | 198 |
GridData gd_lblUuid = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); |
Also available in: Unified diff
mend
display of status in drop down according to preference