Project

General

Profile

« Previous | Next » 

Revision f561b00c

Added by Niels Hoffmann about 13 years ago

Refactoring selection elements so they can be configured

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/ReferenceSelectionElement.java
14 14
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
15 15

  
16 16
/**
17
 * <p>ReferenceSelectionElement class.</p>
18
 *
17
 * <p>
18
 * ReferenceSelectionElement class.
19
 * </p>
20
 * 
19 21
 * @author n.hofmann
20 22
 * @version $Id: $
21 23
 */
22
public class ReferenceSelectionElement extends AbstractSelectionElement<Reference>{
24
public class ReferenceSelectionElement extends
25
		AbstractSelectionElement<Reference> {
26

  
27
	public static final int DEFAULT = EDITABLE | SELECTABLE | DELETABLE;
23 28

  
24 29
	/**
25
	 * <p>Constructor for ReferenceSelectionElement.</p>
26
	 *
27
	 * @param labelString a {@link java.lang.String} object.
28
	 * @param selection a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
29
	 * @param style a int.
30
	 * @param toolkit a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
31
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
32
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
30
	 * <p>
31
	 * Constructor for ReferenceSelectionElement.
32
	 * </p>
33
	 * 
34
	 * @param labelString
35
	 *            a {@link java.lang.String} object.
36
	 * @param selection
37
	 *            a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase}
38
	 *            object.
39
	 * @param style
40
	 *            a int.
41
	 * @param toolkit
42
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
43
	 *            object.
44
	 * @param conversation
45
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
46
	 *            object.
47
	 * @param parentElement
48
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
49
	 *            object.
33 50
	 */
34
	public ReferenceSelectionElement(CdmFormFactory toolkit, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
35
			Reference selection, int style) {
36
		super(toolkit, conversation, parentElement, labelString, selection, true, true, true, style);
51
	public ReferenceSelectionElement(CdmFormFactory toolkit,
52
			ConversationHolder conversation, ICdmFormElement parentElement,
53
			String labelString, Reference selection, int mode, int style) {
54
		super(toolkit, conversation, parentElement, labelString, selection,
55
				mode, style);
37 56
	}
38 57

  
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
58
	/*
59
	 * (non-Javadoc)
60
	 * 
61
	 * @see
62
	 * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt
63
	 * .events.SelectionEvent)
41 64
	 */
42 65
	/** {@inheritDoc} */
66
	@Override
43 67
	public void widgetSelected(SelectionEvent e) {
44
		Reference newSelection = ReferenceSelectionDialog.select(getShell(), getConversationHolder(), entity);
45
		
68
		Reference newSelection = ReferenceSelectionDialog.select(getShell(),
69
				getConversationHolder(), entity);
70

  
46 71
		Reference freshlyLoadedSelection = null;
47
		if(newSelection != null)
48
			freshlyLoadedSelection = CdmStore.getService(IReferenceService.class).load(newSelection.getUuid());
49
		
72
		if (newSelection != null)
73
			freshlyLoadedSelection = CdmStore.getService(
74
					IReferenceService.class).load(newSelection.getUuid());
75

  
50 76
		setSelectionInternal(freshlyLoadedSelection);
51 77
	}
52 78
}

Also available in: Unified diff