Revision b50ab815
Added by Patrick Plitzner over 10 years ago
- converted Browse, Edit, Delete functionality of EntitySelection
- adapted layout of detail elements to fill up the horizontal space
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.ui.selection; |
5 | 5 |
|
... | ... | |
8 | 8 |
import org.eclipse.swt.SWT; |
9 | 9 |
import org.eclipse.swt.events.SelectionAdapter; |
10 | 10 |
import org.eclipse.swt.events.SelectionEvent; |
11 |
import org.eclipse.swt.events.SelectionListener; |
|
12 | 11 |
import org.eclipse.swt.graphics.Color; |
13 | 12 |
import org.eclipse.swt.widgets.Button; |
14 | 13 |
import org.eclipse.swt.widgets.Composite; |
... | ... | |
17 | 16 |
import org.springframework.security.core.GrantedAuthority; |
18 | 17 |
|
19 | 18 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
20 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
21 | 19 |
import eu.etaxonomy.cdm.common.CdmUtils; |
22 | 20 |
import eu.etaxonomy.cdm.model.common.Group; |
23 | 21 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
... | ... | |
31 | 29 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
32 | 30 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
33 | 31 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
34 |
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; |
|
35 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
|
36 |
import eu.etaxonomy.taxeditor.ui.element.ILabeledElement; |
|
37 |
import eu.etaxonomy.taxeditor.ui.element.ISelectable; |
|
38 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
|
39 | 32 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
40 | 33 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
34 |
import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.IEntitySelectionElement; |
|
41 | 35 |
|
42 | 36 |
/** |
43 | 37 |
* <p> |
44 | 38 |
* Abstract AbstractSelectionElement class. |
45 | 39 |
* </p> |
46 |
*
|
|
40 |
* |
|
47 | 41 |
* @author n.hoffmann |
48 | 42 |
* @created Nov 17, 2009 |
49 | 43 |
* @version 1.0 |
50 | 44 |
* @param <T> |
51 | 45 |
*/ |
52 | 46 |
public class EntitySelectionElement<T extends ICdmBase> extends |
53 |
AbstractCdmFormElement implements SelectionListener, |
|
54 |
IEnableableFormElement, ISelectableElement, IEntityElement<T>, |
|
55 |
ILabeledElement, IConversationEnabled, ISelectable { |
|
47 |
AbstractCdmFormElement implements IEntitySelectionElement<T>{ |
|
56 | 48 |
|
57 | 49 |
/** |
58 | 50 |
* Bitmask for configuring functionality of selection element |
... | ... | |
90 | 82 |
* <p> |
91 | 83 |
* Constructor for AbstractSelectionElement. |
92 | 84 |
* </p> |
93 |
*
|
|
85 |
* |
|
94 | 86 |
* @param formFactory |
95 | 87 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
96 | 88 |
* object. |
... | ... | |
122 | 114 |
this.isEditable = (mode & EDITABLE) == EDITABLE; |
123 | 115 |
this.isDeletable = (mode & DELETABLE) == DELETABLE; |
124 | 116 |
boolean isSelectable = (mode & SELECTABLE) == SELECTABLE; |
125 |
|
|
117 |
|
|
126 | 118 |
this.labelString = labelString; |
127 | 119 |
|
128 | 120 |
this.conversation = conversation; |
... | ... | |
135 | 127 |
|
136 | 128 |
setEntity(entity); |
137 | 129 |
} |
138 |
|
|
130 |
|
|
139 | 131 |
public EntitySelectionElement(CdmFormFactory formFactory, |
140 | 132 |
ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz, |
141 | 133 |
String labelString, T entity, int mode, int style) { |
... | ... | |
177 | 169 |
button_selection.setImage(ImageResources |
178 | 170 |
.getImage(ImageResources.BROWSE_ICON)); |
179 | 171 |
button_selection.setToolTipText("Browse existing"); |
180 |
|
|
172 |
|
|
181 | 173 |
addControl(button_selection); |
182 | 174 |
button_selection.addSelectionListener(this); |
183 | 175 |
|
... | ... | |
202 | 194 |
} |
203 | 195 |
} |
204 | 196 |
|
205 |
public void widgetSelected(SelectionEvent e) { |
|
197 |
@Override |
|
198 |
public void widgetSelected(SelectionEvent e) { |
|
206 | 199 |
T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getEntity()); |
207 | 200 |
setSelectionInternal(selection); |
208 | 201 |
} |
209 |
|
|
202 |
|
|
210 | 203 |
/** |
211 | 204 |
* Return the selected object |
212 |
*
|
|
205 |
* |
|
213 | 206 |
* @return a T object. |
214 | 207 |
*/ |
215 | 208 |
public T getSelection() { |
... | ... | |
218 | 211 |
|
219 | 212 |
/* |
220 | 213 |
* (non-Javadoc) |
221 |
*
|
|
214 |
* |
|
222 | 215 |
* @see |
223 | 216 |
* eu.etaxonomy.taxeditor.forms.IEnableableFormElement#setEnabled(boolean) |
224 | 217 |
*/ |
... | ... | |
235 | 228 |
* <p> |
236 | 229 |
* setSelectionInternal |
237 | 230 |
* </p> |
238 |
*
|
|
231 |
* |
|
239 | 232 |
* @param selection |
240 | 233 |
* a T object. |
241 | 234 |
*/ |
... | ... | |
250 | 243 |
* <p> |
251 | 244 |
* Setter for the field <code>entity</code>. |
252 | 245 |
* </p> |
253 |
*
|
|
246 |
* |
|
254 | 247 |
* @param selection |
255 | 248 |
* a T object. |
256 | 249 |
*/ |
... | ... | |
273 | 266 |
} |
274 | 267 |
} |
275 | 268 |
|
276 |
/** |
|
277 |
* <p> |
|
278 |
* updateFromWizard |
|
279 |
* </p> |
|
280 |
*/ |
|
281 |
protected void updateFromWizard() { |
|
269 |
@Override |
|
270 |
public void updateFromWizard() { |
|
282 | 271 |
updateElement(); |
283 | 272 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
284 | 273 |
} |
... | ... | |
287 | 276 |
* <p> |
288 | 277 |
* getTitle |
289 | 278 |
* </p> |
290 |
*
|
|
279 |
* |
|
291 | 280 |
* @return a {@link java.lang.String} object. |
292 | 281 |
*/ |
293 | 282 |
protected String getTitle() { |
... | ... | |
311 | 300 |
|
312 | 301 |
/* |
313 | 302 |
* (non-Javadoc) |
314 |
*
|
|
303 |
* |
|
315 | 304 |
* @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity() |
316 | 305 |
*/ |
317 | 306 |
/** |
318 | 307 |
* <p> |
319 | 308 |
* Getter for the field <code>entity</code>. |
320 | 309 |
* </p> |
321 |
*
|
|
310 |
* |
|
322 | 311 |
* @return a T object. |
323 | 312 |
*/ |
324 | 313 |
@Override |
... | ... | |
328 | 317 |
|
329 | 318 |
/* |
330 | 319 |
* (non-Javadoc) |
331 |
*
|
|
320 |
* |
|
332 | 321 |
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement# |
333 | 322 |
* getSelectionArbitrator() |
334 | 323 |
*/ |
... | ... | |
336 | 325 |
* <p> |
337 | 326 |
* Getter for the field <code>selectionArbitrator</code>. |
338 | 327 |
* </p> |
339 |
*
|
|
328 |
* |
|
340 | 329 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} |
341 | 330 |
* object. |
342 | 331 |
*/ |
... | ... | |
347 | 336 |
|
348 | 337 |
/** |
349 | 338 |
* Convenient access to current shell |
350 |
*
|
|
339 |
* |
|
351 | 340 |
* @return a {@link org.eclipse.swt.widgets.Shell} object. |
352 | 341 |
*/ |
353 |
protected Shell getShell() { |
|
342 |
@Override |
|
343 |
public Shell getShell() { |
|
354 | 344 |
return getLayoutComposite().getShell(); |
355 | 345 |
} |
356 | 346 |
|
... | ... | |
409 | 399 |
* <p> |
410 | 400 |
* getConversationHolder |
411 | 401 |
* </p> |
412 |
*
|
|
402 |
* |
|
413 | 403 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
414 | 404 |
* object. |
415 | 405 |
*/ |
... | ... | |
436 | 426 |
* <p> |
437 | 427 |
* Getter for the field <code>label</code>. |
438 | 428 |
* </p> |
439 |
*
|
|
429 |
* |
|
440 | 430 |
* @return a {@link java.lang.String} object. |
441 | 431 |
*/ |
442 | 432 |
@Override |
Also available in: Unified diff