Revision a14f5d39
Added by Patrick Plitzner over 10 years ago
- adapted EntitiySelectionElement to be able to use with WindowBuilder
.gitattributes | ||
---|---|---|
1258 | 1258 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElement.java -text |
1259 | 1259 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementComposite.java -text |
1260 | 1260 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementWithErrors.java -text |
1261 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java -text |
|
1262 | 1261 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java -text |
1263 | 1262 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/BrowserElement.java -text |
1264 | 1263 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java -text |
... | ... | |
1314 | 1313 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java -text |
1315 | 1314 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java -text |
1316 | 1315 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java -text |
1316 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java -text |
|
1317 | 1317 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java -text |
1318 | 1318 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractIdentifiableEntityDetailElement.java -text |
1319 | 1319 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/EmptyElement.java -text |
... | ... | |
1422 | 1422 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java -text |
1423 | 1423 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractDeterminationEventDetailSection.java -text |
1424 | 1424 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElement.java -text |
1425 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java -text |
|
1425 | 1426 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java -text |
1426 | 1427 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionDetailElement.java -text |
1427 | 1428 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionWizardPage.java -text |
... | ... | |
1434 | 1435 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailElement.java -text |
1435 | 1436 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailSection.java -text |
1436 | 1437 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElement.java -text |
1438 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java -text |
|
1437 | 1439 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationHistoryDetailSection.java -text |
1438 | 1440 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailElement.java -text |
1439 | 1441 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailSection.java -text |
... | ... | |
1498 | 1500 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermVocabularyDetailSection.java -text |
1499 | 1501 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java -text |
1500 | 1502 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java -text |
1503 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java -text |
|
1501 | 1504 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/NomenclaturalAuthorTeamSelectionElement.java -text |
1502 | 1505 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElement.java -text |
1503 | 1506 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/GoogleLanguageApiWrapper.java -text |
... | ... | |
1530 | 1533 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/reporting/ReportingViewPart.java -text |
1531 | 1534 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java -text |
1532 | 1535 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java -text |
1536 |
eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/ResourceManager.java -text |
|
1533 | 1537 |
eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java -text |
1534 | 1538 |
eu.etaxonomy.taxeditor.store/src/main/resources/eu/etaxonomy/cdm/editorApplicationContext.xml -text |
1535 | 1539 |
eu.etaxonomy.taxeditor.store/src/main/resources/log4j.properties -text |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementComposite.java | ||
---|---|---|
8 | 8 |
import org.eclipse.core.runtime.Assert; |
9 | 9 |
import org.eclipse.jface.util.IPropertyChangeListener; |
10 | 10 |
import org.eclipse.jface.util.PropertyChangeEvent; |
11 |
import org.eclipse.swt.SWT; |
|
11 | 12 |
import org.eclipse.swt.graphics.Color; |
12 | 13 |
import org.eclipse.swt.widgets.Composite; |
13 | 14 |
import org.eclipse.swt.widgets.Control; |
14 | 15 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
15 | 16 |
import org.eclipse.ui.forms.widgets.Section; |
16 | 17 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
18 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
17 | 19 |
|
18 | 20 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
19 | 21 |
|
... | ... | |
35 | 37 |
*/ |
36 | 38 |
public AbstractCdmFormElementComposite(Composite parent, final FormToolkit formFactory, ICdmFormElement parentFormElement, int style) { |
37 | 39 |
super(parent, style); |
40 |
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); |
|
38 | 41 |
|
39 | 42 |
this.parentElement = parentFormElement; |
40 | 43 |
if(formFactory instanceof CdmFormFactory){ |
41 | 44 |
this.formFactory = (CdmFormFactory) formFactory; |
42 | 45 |
} |
46 |
//TODO what to do when not instance of CdmFormFactory |
|
43 | 47 |
|
44 | 48 |
TableWrapLayout twl_layoutComposite = new TableWrapLayout(); |
45 | 49 |
twl_layoutComposite.numColumns = 2; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.ui.element; |
|
2 |
|
|
3 |
import org.eclipse.jface.resource.ResourceManager; |
|
4 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
5 |
import org.eclipse.swt.SWT; |
|
6 |
import org.eclipse.swt.events.SelectionEvent; |
|
7 |
import org.eclipse.swt.events.SelectionListener; |
|
8 |
import org.eclipse.swt.graphics.Color; |
|
9 |
import org.eclipse.swt.widgets.Button; |
|
10 |
import org.eclipse.swt.widgets.Composite; |
|
11 |
import org.eclipse.swt.widgets.Layout; |
|
12 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
13 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
16 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
17 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
18 |
|
|
19 |
public abstract class AbstractEntityCollectionElementComposite<ENTITY> |
|
20 |
extends AbstractCdmFormElementComposite |
|
21 |
implements IEntityElement<ENTITY>, SelectionListener, IConversationEnabled { |
|
22 |
|
|
23 |
protected ENTITY entity; |
|
24 |
|
|
25 |
private final Composite container; |
|
26 |
|
|
27 |
private final Composite box; |
|
28 |
|
|
29 |
private final Button button_remove; |
|
30 |
|
|
31 |
private Color backgroundColor; |
|
32 |
|
|
33 |
/** |
|
34 |
* Create the composite. |
|
35 |
* |
|
36 |
* @param parent |
|
37 |
* @param style |
|
38 |
*/ |
|
39 |
public AbstractEntityCollectionElementComposite(Composite parent, ICdmFormElement parentFormElement, FormToolkit formFactory, ENTITY entity, SelectionListener removeListener, int style) { |
|
40 |
super(parent, parentFormElement, style); |
|
41 |
|
|
42 |
box = formFactory.createComposite(parent); |
|
43 |
box.setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
44 |
addControl(box); |
|
45 |
|
|
46 |
TableWrapLayout boxLayout = LayoutConstants.LAYOUT(2, false); |
|
47 |
boxLayout.topMargin = 4; |
|
48 |
boxLayout.bottomMargin = 4; |
|
49 |
box.setLayout(boxLayout); |
|
50 |
|
|
51 |
box.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
52 |
|
|
53 |
container = formFactory.createComposite(box); |
|
54 |
container.setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
55 |
|
|
56 |
setLayoutComposite(container); |
|
57 |
|
|
58 |
addControl(container); |
|
59 |
Layout containerLayout = LayoutConstants.LAYOUT(2, false); |
|
60 |
|
|
61 |
container.setLayout(containerLayout); |
|
62 |
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
63 |
|
|
64 |
// if (removeListener != null) { |
|
65 |
button_remove = formFactory.createButton(box, null, SWT.PUSH); |
|
66 |
addControl(button_remove); |
|
67 |
button_remove.setLayoutData(LayoutConstants.RIGHT()); |
|
68 |
button_remove.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); |
|
69 |
button_remove.setToolTipText("Remove"); |
|
70 |
// button_remove.addSelectionListener(removeListener); |
|
71 |
// } |
|
72 |
|
|
73 |
createControls(this, style); |
|
74 |
setEntity(entity); |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Init gets executed before any other setup of the section takes place |
|
80 |
* |
|
81 |
* Implement this if you want to configure the section |
|
82 |
*/ |
|
83 |
public void init() { |
|
84 |
// default implementation is empty |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* <p> |
|
89 |
* Setter for the field <code>entity</code>. |
|
90 |
* </p> |
|
91 |
* |
|
92 |
* @param entity |
|
93 |
* a ENTITY object. |
|
94 |
*/ |
|
95 |
public abstract void setEntity(ENTITY entity); |
|
96 |
|
|
97 |
/** |
|
98 |
* <p> |
|
99 |
* Getter for the field <code>entity</code>. |
|
100 |
* </p> |
|
101 |
* |
|
102 |
* @return a ENTITY object. |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
public ENTITY getEntity() { |
|
106 |
return entity; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* <p> |
|
111 |
* createControls |
|
112 |
* </p> |
|
113 |
* |
|
114 |
* @param element |
|
115 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
|
116 |
* object. |
|
117 |
* @param style |
|
118 |
* a int. |
|
119 |
*/ |
|
120 |
public abstract void createControls(ICdmFormElement element, int style); |
|
121 |
|
|
122 |
/** |
|
123 |
* Mark <code>this</code> element as selected. |
|
124 |
*/ |
|
125 |
@Override |
|
126 |
public void setSelected(boolean selected) { |
|
127 |
|
|
128 |
for (ICdmFormElement element : getElements()) { |
|
129 |
if (element instanceof ISelectable) { |
|
130 |
((ISelectable) element).setSelected(selected); |
|
131 |
} |
|
132 |
} |
|
133 |
setBackground(selected ? SELECTED : getPersistentBackground()); |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* |
|
139 |
* @see |
|
140 |
* eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org |
|
141 |
* .eclipse.jface.util.PropertyChangeEvent) |
|
142 |
*/ |
|
143 |
/** {@inheritDoc} */ |
|
144 |
@Override |
|
145 |
public void propertyChange(PropertyChangeEvent event) { |
|
146 |
if (event == null) { |
|
147 |
return; |
|
148 |
} |
|
149 |
Object eventSource = event.getSource(); |
|
150 |
if (getElements().contains(eventSource)) { |
|
151 |
handleEvent(eventSource); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* <p> |
|
157 |
* handleEvent |
|
158 |
* </p> |
|
159 |
* |
|
160 |
* @param eventSource |
|
161 |
* a {@link java.lang.Object} object. |
|
162 |
*/ |
|
163 |
public abstract void handleEvent(Object eventSource); |
|
164 |
|
|
165 |
/** {@inheritDoc} */ |
|
166 |
@Override |
|
167 |
public void setBackground(Color color) { |
|
168 |
backgroundColor = color; |
|
169 |
super.setBackground(backgroundColor); |
|
170 |
box.setBackground(backgroundColor); |
|
171 |
container.setBackground(backgroundColor); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* {@inheritDoc} |
|
176 |
* |
|
177 |
* React when selection occurs |
|
178 |
*/ |
|
179 |
@Override |
|
180 |
public void widgetSelected(SelectionEvent e) { |
|
181 |
|
|
182 |
} |
|
183 |
|
|
184 |
/** {@inheritDoc} */ |
|
185 |
@Override |
|
186 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
187 |
} |
|
188 |
|
|
189 |
/** {@inheritDoc} */ |
|
190 |
@Override |
|
191 |
public Composite getLayoutComposite() { |
|
192 |
return container; |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* <p> |
|
197 |
* Getter for the field <code>backgroundColor</code>. |
|
198 |
* </p> |
|
199 |
* |
|
200 |
* @return the backgroundColor |
|
201 |
*/ |
|
202 |
public Color getBackgroundColor() { |
|
203 |
return backgroundColor; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* <p> |
|
208 |
* getConversationHolder |
|
209 |
* </p> |
|
210 |
* |
|
211 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
|
212 |
* object. |
|
213 |
*/ |
|
214 |
@Override |
|
215 |
public ConversationHolder getConversationHolder() { |
|
216 |
if (getParentElement() instanceof IConversationEnabled) { |
|
217 |
return ((IConversationEnabled) getParentElement()) |
|
218 |
.getConversationHolder(); |
|
219 |
} |
|
220 |
throw new IllegalArgumentException( |
|
221 |
"Parent element should be IConversationEnabled"); |
|
222 |
} |
|
223 |
|
|
224 |
/** {@inheritDoc} */ |
|
225 |
@Override |
|
226 |
public void update(CdmDataChangeMap changeEvents) { |
|
227 |
} |
|
228 |
|
|
229 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.ui.element; |
2 | 2 |
import org.eclipse.swt.widgets.Composite; |
3 | 3 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
4 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite; |
|
5 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
6 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
4 | 7 |
|
5 | 8 |
public final class CdmElementFactory { |
6 | 9 |
/** |
... | ... | |
28 | 31 |
CdmTextField cdmNumberField = new CdmTextField(parent, formFactory, parentFormElement, initialText, textHeight, style); |
29 | 32 |
return cdmNumberField; |
30 | 33 |
} |
34 |
/** |
|
35 |
* @wbp.factory |
|
36 |
* @wbp.factory.parameter.source formFactory formFactory |
|
37 |
* @wbp.factory.parameter.source conversation getConversationHolder() |
|
38 |
* @wbp.factory.parameter.source parentElement element |
|
39 |
* @wbp.factory.parameter.source clazz eu.etaxonomy.cdm.model.taxon.TaxonBase.class |
|
40 |
* @wbp.factory.parameter.source labelString "Taxon" |
|
41 |
* @wbp.factory.parameter.source entity (eu.etaxonomy.cdm.model.taxon.TaxonBase) null |
|
42 |
* @wbp.factory.parameter.source mode eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite.NOTHING |
|
43 |
* @wbp.factory.parameter.source style style |
|
44 |
*/ |
|
45 |
public static EntitySelectionElementComposite createEntitySelectionElementComposite(Composite parent, FormToolkit formFactory, ConversationHolder conversation, ICdmFormElement parentElement, Class clazz, String labelString, ICdmBase entity, int mode, int style) { |
|
46 |
EntitySelectionElementComposite entitySelectionElementComposite = new EntitySelectionElementComposite(parent, formFactory, conversation, parentElement, clazz, labelString, entity, mode, style); |
|
47 |
return entitySelectionElementComposite; |
|
48 |
} |
|
31 | 49 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
199 | 199 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement; |
200 | 200 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection; |
201 | 201 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement; |
202 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElementComposite; |
|
202 | 203 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection; |
203 | 204 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement; |
204 | 205 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection; |
... | ... | |
2095 | 2096 |
} else if (entity instanceof NamedArea) { |
2096 | 2097 |
element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style); |
2097 | 2098 |
} else if (entity instanceof DeterminationEvent) { |
2098 |
element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, |
|
2099 |
removeListener, style); |
|
2099 |
element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style); |
|
2100 | 2100 |
} else if (entity instanceof Specimen) { |
2101 | 2101 |
element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style); |
2102 | 2102 |
} else if (entity instanceof User) { |
... | ... | |
2125 | 2125 |
|
2126 | 2126 |
else if (backgroundColor != null && !backgroundColor.isDisposed()) { |
2127 | 2127 |
element.setPersistentBackground(backgroundColor); |
2128 |
adapt(element); |
|
2129 |
parentElement.addElement(element); |
|
2128 | 2130 |
} |
2129 | 2131 |
|
2132 |
return element; |
|
2133 |
} |
|
2134 |
|
|
2135 |
public DeterminationEventDetailElementComposite createDeterminationEventDetailElementComposite(AbstractFormSection parentElement, |
|
2136 |
Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style){ |
|
2137 |
Object entity = HibernateProxyHelper.deproxy(versionableEntity); |
|
2138 |
DeterminationEventDetailElementComposite element = new DeterminationEventDetailElementComposite(parentElement.getLayoutComposite(), this, parentElement, (DeterminationEvent) entity, |
|
2139 |
removeListener, style); |
|
2130 | 2140 |
adapt(element); |
2131 | 2141 |
parentElement.addElement(element); |
2132 | 2142 |
return element; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
36 | 36 |
* <p> |
37 | 37 |
* Abstract AbstractEntityCollectionElement class. |
38 | 38 |
* </p> |
39 |
*
|
|
39 |
* |
|
40 | 40 |
* @author n.hoffmann |
41 | 41 |
* @created Nov 16, 2009 |
42 | 42 |
* @version 1.0 |
... | ... | |
47 | 47 |
|
48 | 48 |
protected ENTITY entity; |
49 | 49 |
|
50 |
private Composite container; |
|
50 |
private final Composite container;
|
|
51 | 51 |
|
52 |
private Composite box; |
|
52 |
private final Composite box;
|
|
53 | 53 |
|
54 | 54 |
private Button button_remove; |
55 | 55 |
|
... | ... | |
59 | 59 |
* <p> |
60 | 60 |
* Constructor for AbstractEntityCollectionElement. |
61 | 61 |
* </p> |
62 |
*
|
|
62 |
* |
|
63 | 63 |
* @param style |
64 | 64 |
* a int. |
65 | 65 |
* @param formFactory |
... | ... | |
129 | 129 |
|
130 | 130 |
/** |
131 | 131 |
* Init gets executed before any other setup of the section takes place |
132 |
*
|
|
132 |
* |
|
133 | 133 |
* Implement this if you want to configure the section |
134 | 134 |
*/ |
135 | 135 |
public void init() { |
... | ... | |
140 | 140 |
* <p> |
141 | 141 |
* Setter for the field <code>entity</code>. |
142 | 142 |
* </p> |
143 |
*
|
|
143 |
* |
|
144 | 144 |
* @param entity |
145 | 145 |
* a ENTITY object. |
146 | 146 |
*/ |
... | ... | |
150 | 150 |
* <p> |
151 | 151 |
* Getter for the field <code>entity</code>. |
152 | 152 |
* </p> |
153 |
*
|
|
153 |
* |
|
154 | 154 |
* @return a ENTITY object. |
155 | 155 |
*/ |
156 |
public ENTITY getEntity() { |
|
156 |
@Override |
|
157 |
public ENTITY getEntity() { |
|
157 | 158 |
return entity; |
158 | 159 |
} |
159 | 160 |
|
... | ... | |
161 | 162 |
* <p> |
162 | 163 |
* createControls |
163 | 164 |
* </p> |
164 |
*
|
|
165 |
* |
|
165 | 166 |
* @param element |
166 | 167 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
167 | 168 |
* object. |
... | ... | |
173 | 174 |
/** |
174 | 175 |
* Mark <code>this</code> element as selected. |
175 | 176 |
*/ |
176 |
public void setSelected(boolean selected) { |
|
177 |
@Override |
|
178 |
public void setSelected(boolean selected) { |
|
177 | 179 |
|
178 | 180 |
for (ICdmFormElement element : getElements()) { |
179 | 181 |
if (element instanceof ISelectable) { |
... | ... | |
185 | 187 |
|
186 | 188 |
/* |
187 | 189 |
* (non-Javadoc) |
188 |
*
|
|
190 |
* |
|
189 | 191 |
* @see |
190 | 192 |
* eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org |
191 | 193 |
* .eclipse.jface.util.PropertyChangeEvent) |
... | ... | |
206 | 208 |
* <p> |
207 | 209 |
* handleEvent |
208 | 210 |
* </p> |
209 |
*
|
|
211 |
* |
|
210 | 212 |
* @param eventSource |
211 | 213 |
* a {@link java.lang.Object} object. |
212 | 214 |
*/ |
213 | 215 |
public abstract void handleEvent(Object eventSource); |
214 | 216 |
|
215 | 217 |
/** {@inheritDoc} */ |
216 |
public void setBackground(Color color) { |
|
218 |
@Override |
|
219 |
public void setBackground(Color color) { |
|
217 | 220 |
backgroundColor = color; |
218 | 221 |
super.setBackground(color); |
219 | 222 |
box.setBackground(color); |
... | ... | |
222 | 225 |
|
223 | 226 |
/** |
224 | 227 |
* {@inheritDoc} |
225 |
*
|
|
228 |
* |
|
226 | 229 |
* React when selection occurs |
227 | 230 |
*/ |
228 |
public void widgetSelected(SelectionEvent e) { |
|
231 |
@Override |
|
232 |
public void widgetSelected(SelectionEvent e) { |
|
229 | 233 |
|
230 | 234 |
} |
231 | 235 |
|
232 | 236 |
/** {@inheritDoc} */ |
233 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
237 |
@Override |
|
238 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
234 | 239 |
} |
235 | 240 |
|
236 | 241 |
/** {@inheritDoc} */ |
... | ... | |
243 | 248 |
* <p> |
244 | 249 |
* Getter for the field <code>backgroundColor</code>. |
245 | 250 |
* </p> |
246 |
*
|
|
251 |
* |
|
247 | 252 |
* @return the backgroundColor |
248 | 253 |
*/ |
249 | 254 |
public Color getBackgroundColor() { |
... | ... | |
254 | 259 |
* <p> |
255 | 260 |
* getConversationHolder |
256 | 261 |
* </p> |
257 |
*
|
|
262 |
* |
|
258 | 263 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
259 | 264 |
* object. |
260 | 265 |
*/ |
261 |
public ConversationHolder getConversationHolder() { |
|
266 |
@Override |
|
267 |
public ConversationHolder getConversationHolder() { |
|
262 | 268 |
if (getParentElement() instanceof IConversationEnabled) { |
263 | 269 |
return ((IConversationEnabled) getParentElement()) |
264 | 270 |
.getConversationHolder(); |
... | ... | |
268 | 274 |
} |
269 | 275 |
|
270 | 276 |
/** {@inheritDoc} */ |
271 |
public void update(CdmDataChangeMap changeEvents) { |
|
277 |
@Override |
|
278 |
public void update(CdmDataChangeMap changeEvents) { |
|
272 | 279 |
} |
273 | 280 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.section; |
|
11 |
|
|
12 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
13 |
import org.eclipse.swt.SWT; |
|
14 |
import org.eclipse.swt.events.SelectionEvent; |
|
15 |
import org.eclipse.swt.events.SelectionListener; |
|
16 |
import org.eclipse.swt.graphics.Color; |
|
17 |
import org.eclipse.swt.widgets.Button; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Layout; |
|
20 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
21 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
22 |
import org.eclipse.wb.swt.ResourceManager; |
|
23 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
24 |
|
|
25 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
26 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
27 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
28 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElementComposite; |
|
29 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
30 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
31 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
|
32 |
import eu.etaxonomy.taxeditor.ui.element.ISelectable; |
|
33 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
34 |
|
|
35 |
/** |
|
36 |
* @author pplitzner |
|
37 |
* @date 02.08.2013 |
|
38 |
* |
|
39 |
*/ |
|
40 |
public abstract class AbstractEntityCollectionElementComposite<ENTITY> extends AbstractCdmFormElementComposite implements IEntityElement<ENTITY>, SelectionListener, IConversationEnabled { |
|
41 |
|
|
42 |
protected ENTITY entity; |
|
43 |
|
|
44 |
private final Composite container; |
|
45 |
|
|
46 |
// private final Composite box; |
|
47 |
|
|
48 |
private final Button btnRstre; |
|
49 |
|
|
50 |
private Color backgroundColor; |
|
51 |
|
|
52 |
/** |
|
53 |
* <p> |
|
54 |
* Constructor for AbstractEntityCollectionElement. |
|
55 |
* </p> |
|
56 |
* |
|
57 |
* @param style |
|
58 |
* a int. |
|
59 |
* @param formFactory |
|
60 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
|
61 |
* object. |
|
62 |
* @param section |
|
63 |
* a |
|
64 |
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} |
|
65 |
* object. |
|
66 |
* @param entity |
|
67 |
* a ENTITY object. |
|
68 |
* @param removeListener |
|
69 |
* a {@link org.eclipse.swt.events.SelectionListener} object. |
|
70 |
* @param <ENTITY> |
|
71 |
* a ENTITY object. |
|
72 |
*/ |
|
73 |
public AbstractEntityCollectionElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, ENTITY entity, SelectionListener removeListener, Color backgroundColor, int style) { |
|
74 |
super(parent, formFactory, parentFormElement, style); |
|
75 |
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); |
|
76 |
|
|
77 |
init(); |
|
78 |
|
|
79 |
if(formFactory instanceof CdmFormFactory){ |
|
80 |
((CdmFormFactory) formFactory).addPropertyChangeListener(this); |
|
81 |
} |
|
82 |
|
|
83 |
// section.getLayoutComposite().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN)); |
|
84 |
|
|
85 |
// box = formFactory.createComposite(this); |
|
86 |
this.setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
87 |
addControl(this); |
|
88 |
|
|
89 |
TableWrapLayout boxLayout = LayoutConstants.LAYOUT(2, false); |
|
90 |
boxLayout.topMargin = 4; |
|
91 |
boxLayout.bottomMargin = 4; |
|
92 |
this.setLayout(boxLayout); |
|
93 |
|
|
94 |
this.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
95 |
|
|
96 |
// box.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); |
|
97 |
|
|
98 |
container = formFactory.createComposite(this); |
|
99 |
container.setBackgroundMode(SWT.INHERIT_DEFAULT); |
|
100 |
|
|
101 |
// container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
102 |
setLayoutComposite(container); |
|
103 |
|
|
104 |
addControl(container); |
|
105 |
Layout containerLayout = LayoutConstants.LAYOUT(2, false); |
|
106 |
|
|
107 |
container.setLayout(containerLayout); |
|
108 |
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
109 |
|
|
110 |
btnRstre = formFactory.createButton(this, null, SWT.PUSH); |
|
111 |
addControl(btnRstre); |
|
112 |
btnRstre.setLayoutData(LayoutConstants.RIGHT()); |
|
113 |
btnRstre.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); |
|
114 |
btnRstre.setToolTipText("Remove"); |
|
115 |
|
|
116 |
if (removeListener != null) { |
|
117 |
btnRstre.addSelectionListener(removeListener); |
|
118 |
} |
|
119 |
|
|
120 |
createControls(this, style); |
|
121 |
|
|
122 |
setEntity(entity); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Init gets executed before any other setup of the section takes place |
|
127 |
* |
|
128 |
* Implement this if you want to configure the section |
|
129 |
*/ |
|
130 |
public void init() { |
|
131 |
// default implementation is empty |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* <p> |
|
136 |
* Setter for the field <code>entity</code>. |
|
137 |
* </p> |
|
138 |
* |
|
139 |
* @param entity |
|
140 |
* a ENTITY object. |
|
141 |
*/ |
|
142 |
public abstract void setEntity(ENTITY entity); |
|
143 |
|
|
144 |
/** |
|
145 |
* <p> |
|
146 |
* Getter for the field <code>entity</code>. |
|
147 |
* </p> |
|
148 |
* |
|
149 |
* @return a ENTITY object. |
|
150 |
*/ |
|
151 |
@Override |
|
152 |
public ENTITY getEntity() { |
|
153 |
return entity; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* <p> |
|
158 |
* createControls |
|
159 |
* </p> |
|
160 |
* |
|
161 |
* @param element |
|
162 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
|
163 |
* object. |
|
164 |
* @param style |
|
165 |
* a int. |
|
166 |
*/ |
|
167 |
public abstract void createControls(ICdmFormElement element, int style); |
|
168 |
|
|
169 |
/** |
|
170 |
* Mark <code>this</code> element as selected. |
|
171 |
*/ |
|
172 |
@Override |
|
173 |
public void setSelected(boolean selected) { |
|
174 |
|
|
175 |
for (ICdmFormElement element : getElements()) { |
|
176 |
if (element instanceof ISelectable) { |
|
177 |
((ISelectable) element).setSelected(selected); |
|
178 |
} |
|
179 |
} |
|
180 |
setBackground(selected ? SELECTED : getPersistentBackground()); |
|
181 |
} |
|
182 |
|
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* |
|
186 |
* @see |
|
187 |
* eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org |
|
188 |
* .eclipse.jface.util.PropertyChangeEvent) |
|
189 |
*/ |
|
190 |
/** {@inheritDoc} */ |
|
191 |
@Override |
|
192 |
public void propertyChange(PropertyChangeEvent event) { |
|
193 |
if (event == null) { |
|
194 |
return; |
|
195 |
} |
|
196 |
Object eventSource = event.getSource(); |
|
197 |
if (getElements().contains(eventSource)) { |
|
198 |
handleEvent(eventSource); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* <p> |
|
204 |
* handleEvent |
|
205 |
* </p> |
|
206 |
* |
|
207 |
* @param eventSource |
|
208 |
* a {@link java.lang.Object} object. |
|
209 |
*/ |
|
210 |
public abstract void handleEvent(Object eventSource); |
|
211 |
|
|
212 |
/** {@inheritDoc} */ |
|
213 |
@Override |
|
214 |
public void setBackground(Color color) { |
|
215 |
if(color!=null){ |
|
216 |
backgroundColor = color; |
|
217 |
super.setBackground(color); |
|
218 |
// box.setBackground(color); |
|
219 |
// container.setBackground(color); |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* {@inheritDoc} |
|
225 |
* |
|
226 |
* React when selection occurs |
|
227 |
*/ |
|
228 |
@Override |
|
229 |
public void widgetSelected(SelectionEvent e) { |
|
230 |
|
|
231 |
} |
|
232 |
|
|
233 |
/** {@inheritDoc} */ |
|
234 |
@Override |
|
235 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
236 |
} |
|
237 |
|
|
238 |
/** {@inheritDoc} */ |
|
239 |
@Override |
|
240 |
public Composite getLayoutComposite() { |
|
241 |
return container; |
|
242 |
} |
|
243 |
|
|
244 |
/** |
|
245 |
* <p> |
|
246 |
* Getter for the field <code>backgroundColor</code>. |
|
247 |
* </p> |
|
248 |
* |
|
249 |
* @return the backgroundColor |
|
250 |
*/ |
|
251 |
public Color getBackgroundColor() { |
|
252 |
return backgroundColor; |
|
253 |
} |
|
254 |
|
|
255 |
/** |
|
256 |
* <p> |
|
257 |
* getConversationHolder |
|
258 |
* </p> |
|
259 |
* |
|
260 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
|
261 |
* object. |
|
262 |
*/ |
|
263 |
@Override |
|
264 |
public ConversationHolder getConversationHolder() { |
|
265 |
if (getParentElement() instanceof IConversationEnabled) { |
|
266 |
return ((IConversationEnabled) getParentElement()).getConversationHolder(); |
|
267 |
} |
|
268 |
throw new IllegalArgumentException("Parent element should be IConversationEnabled"); |
|
269 |
} |
|
270 |
|
|
271 |
/** {@inheritDoc} */ |
|
272 |
@Override |
|
273 |
public void update(CdmDataChangeMap changeEvents) { |
|
274 |
} |
|
275 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java | ||
---|---|---|
280 | 280 |
} |
281 | 281 |
|
282 | 282 |
/** |
283 |
* Remove an element from the entities collection and update the section
|
|
283 |
* Remove an element from the entities collection and update the section |
|
284 | 284 |
* |
285 | 285 |
* @param element a ELEMENT object. |
286 | 286 |
*/ |
... | ... | |
288 | 288 |
removeElement(element); |
289 | 289 |
internalUpdateSection(true); |
290 | 290 |
} |
291 |
|
|
291 |
|
|
292 | 292 |
/** |
293 | 293 |
* Get the specific collection of this entity |
294 | 294 |
* |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractDeterminationEventDetailSection.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.ui.section.occurrence; |
12 | 12 |
|
13 |
import org.eclipse.swt.SWT; |
|
14 |
import org.eclipse.swt.events.SelectionListener; |
|
15 |
import org.eclipse.swt.graphics.Color; |
|
16 |
|
|
13 | 17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
14 | 18 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
15 | 19 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
... | ... | |
78 | 82 |
return "No determinations yet."; |
79 | 83 |
} |
80 | 84 |
|
85 |
/* (non-Javadoc) |
|
86 |
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createElementComposite(java.lang.Object, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.graphics.Color) |
|
87 |
*/ |
|
88 |
@Override |
|
89 |
protected void createElementComposite(DeterminationEvent element, SelectionListener removeListener, Color backgroundColor) { |
|
90 |
formFactory.createDeterminationEventDetailElementComposite(this, element, removeListener, backgroundColor, SWT.NULL); |
|
91 |
} |
|
92 |
|
|
81 | 93 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.section.occurrence; |
|
11 |
|
|
12 |
import org.eclipse.swt.events.SelectionListener; |
|
13 |
import org.eclipse.swt.widgets.Composite; |
|
14 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
17 |
import eu.etaxonomy.cdm.model.common.EventBase; |
|
18 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
|
19 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
20 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement; |
|
22 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElementComposite; |
|
23 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author pplitzner |
|
27 |
* @date 02.08.2013 |
|
28 |
* |
|
29 |
*/ |
|
30 |
public abstract class AbstractEventDetailElementComposite<T extends EventBase> extends AbstractEntityCollectionElementComposite<T> { |
|
31 |
|
|
32 |
protected EntitySelectionElement<AgentBase> selection_agent; |
|
33 |
protected TextWithLabelElement text_description; |
|
34 |
protected TimePeriodElement element_timePeriod; |
|
35 |
|
|
36 |
/** |
|
37 |
* <p> |
|
38 |
* Constructor for AbstractEventDetailElement. |
|
39 |
* </p> |
|
40 |
* |
|
41 |
* @param formFactory |
|
42 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
|
43 |
* object. |
|
44 |
* @param section |
|
45 |
* a |
|
46 |
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} |
|
47 |
* object. |
|
48 |
* @param entity |
|
49 |
* a T object. |
|
50 |
* @param removeListener |
|
51 |
* a {@link org.eclipse.swt.events.SelectionListener} object. |
|
52 |
* @param style |
|
53 |
* a int. |
|
54 |
* @param <T> |
|
55 |
* a T object. |
|
56 |
*/ |
|
57 |
public AbstractEventDetailElementComposite(Composite parent, FormToolkit formFactory, AbstractFormSection section, T entity, SelectionListener removeListener, int style) { |
|
58 |
super(parent, formFactory, section, entity, removeListener, null, style); |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* |
|
64 |
* @see |
|
65 |
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity |
|
66 |
* (java.lang.Object) |
|
67 |
*/ |
|
68 |
/** {@inheritDoc} */ |
|
69 |
@Override |
|
70 |
public void setEntity(T entity) { |
|
71 |
if(entity!=null){ |
|
72 |
selection_agent.setEntity(entity.getActor()); |
|
73 |
text_description.setText(entity.getDescription()); |
|
74 |
element_timePeriod.setEntity(entity.getTimeperiod()); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* |
|
81 |
* @see |
|
82 |
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls |
|
83 |
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int) |
|
84 |
*/ |
|
85 |
/** {@inheritDoc} */ |
|
86 |
@Override |
|
87 |
public void createControls(ICdmFormElement element, int style) { |
|
88 |
selection_agent = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Actor", null, EntitySelectionElement.ALL, style); |
|
89 |
element_timePeriod = formFactory.createTimePeriodElement(element, "Time Period", null, style); |
|
90 |
text_description = formFactory.createTextWithLabelElement(element, "Description", null, style); |
|
91 |
} |
|
92 |
|
|
93 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
21 | 21 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection; |
22 | 22 |
|
23 | 23 |
/** |
24 |
* <p>CollectingAreasDetailSection class.</p> |
|
24 |
* <p> |
|
25 |
* CollectingAreasDetailSection class. |
|
26 |
* </p> |
|
25 | 27 |
* |
26 | 28 |
* @author n.hoffmann |
27 | 29 |
* @created Oct 14, 2010 |
28 | 30 |
* @version 1.0 |
29 | 31 |
*/ |
30 |
public class CollectingAreasDetailSection extends |
|
31 |
AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> { |
|
32 |
public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> { |
|
32 | 33 |
|
33 | 34 |
/** |
34 | 35 |
* <p>Constructor for CollectingAreasDetailSection.</p> |
... | ... | |
59 | 60 |
@Override |
60 | 61 |
public NamedArea createNewElement() { |
61 | 62 |
NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null); |
62 |
|
|
63 |
|
|
63 | 64 |
return selection; |
64 | 65 |
} |
65 | 66 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailSection.java | ||
---|---|---|
16 | 16 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
17 | 17 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
18 | 18 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
19 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
|
20 | 19 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
20 |
import eu.etaxonomy.taxeditor.ui.section.ICdmDetailElement; |
|
21 | 21 |
|
22 | 22 |
/** |
23 | 23 |
* @author n.hoffmann |
... | ... | |
51 | 51 |
* @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int) |
52 | 52 |
*/ |
53 | 53 |
@Override |
54 |
protected AbstractCdmDetailElement<DerivedUnitFacade> createCdmDetailElement(AbstractCdmDetailSection<DerivedUnitFacade> parentElement, int style) {
|
|
54 |
protected ICdmDetailElement<DerivedUnitFacade> createCdmDetailElement(AbstractCdmDetailSection<DerivedUnitFacade> parentElement, int style) {
|
|
55 | 55 |
return formFactory.createDeterminationDetailElement(parentElement); |
56 | 56 |
} |
57 | 57 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2013 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 |
package eu.etaxonomy.taxeditor.ui.section.occurrence; |
|
11 |
|
|
12 |
import org.eclipse.swt.events.SelectionListener; |
|
13 |
import org.eclipse.swt.widgets.Composite; |
|
14 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
|
17 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationModifier; |
|
18 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
19 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
|
20 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.CdmElementFactory; |
|
22 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
|
23 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
24 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author pplitzner |
|
28 |
* @date 02.08.2013 |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class DeterminationEventDetailElementComposite extends AbstractEventDetailElementComposite<DeterminationEvent> { |
|
32 |
|
|
33 |
private TermComboElement<DeterminationModifier> combo_determinationModifier; |
|
34 |
private CheckboxElement checkbox_preferredFlag; |
|
35 |
private EntitySelectionElementComposite<TaxonBase> selection_taxonBase; |
|
36 |
|
|
37 |
// private TODO a set of references |
|
38 |
|
|
39 |
/** |
|
40 |
* <p> |
|
41 |
* Constructor for DeterminationEventDetailElement. |
|
42 |
* </p> |
|
43 |
* |
|
44 |
* @param formFactory |
|
45 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
|
46 |
* object. |
|
47 |
* @param section |
|
48 |
* a |
|
49 |
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} |
|
50 |
* object. |
|
51 |
* @param entity |
|
52 |
* a {@link eu.etaxonomy.cdm.model.occurrence.DeterminationEvent} |
|
53 |
* object. |
|
54 |
* @param removeListener |
|
55 |
* a {@link org.eclipse.swt.events.SelectionListener} object. |
|
56 |
* @param style |
|
57 |
* a int. |
|
58 |
*/ |
|
59 |
public DeterminationEventDetailElementComposite(Composite parent, FormToolkit formFactory, AbstractFormSection section, DeterminationEvent entity, SelectionListener removeListener, int style) { |
|
60 |
super(parent, formFactory, section, entity, removeListener, style); |
|
61 |
} |
|
62 |
|
|
63 |
/* |
|
64 |
* (non-Javadoc) |
|
65 |
* |
|
66 |
* @see |
|
67 |
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity |
|
68 |
* (eu.etaxonomy.cdm.model.common.IVersionableEntity) |
|
69 |
*/ |
|
70 |
/** {@inheritDoc} */ |
|
71 |
@Override |
|
72 |
public void setEntity(DeterminationEvent entity) { |
|
73 |
this.entity = entity; |
|
74 |
combo_determinationModifier.setSelection(entity.getModifier()); |
|
75 |
selection_taxonBase.setEntity(entity.getTaxon()); |
|
76 |
super.setEntity(entity); |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* |
|
82 |
* @see |
|
83 |
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls |
|
84 |
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int) |
|
85 |
*/ |
|
86 |
/** {@inheritDoc} */ |
|
87 |
@Override |
|
88 |
public void createControls(ICdmFormElement element, int style) { |
|
89 |
// TODO set of references |
|
90 |
|
|
91 |
// WindowBuilder does not support generics!! That's why they are missing here |
|
92 |
selection_taxonBase = CdmElementFactory.createEntitySelectionElementComposite(this, formFactory, getConversationHolder(), element, TaxonBase.class, "Taxon", (TaxonBase) null, EntitySelectionElementComposite.NOTHING, style); |
|
93 |
// this.addElement(selection_taxonBase);// TODO use factory method to create and add selection_taxonBase |
|
94 |
|
|
95 |
super.createControls(element, style); |
|
96 |
|
|
97 |
element_timePeriod.setLabel("Determined When"); |
|
98 |
selection_agent.setLabel("Determined by"); |
|
99 |
|
|
100 |
combo_determinationModifier = formFactory.createTermComboElement(DeterminationModifier.class, element, "Modifier", null, style); |
|
101 |
} |
|
102 |
|
|
103 |
/* |
|
104 |
* (non-Javadoc) |
|
105 |
* |
|
106 |
* @see |
|
107 |
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent |
|
108 |
* (java.lang.Object) |
|
109 |
*/ |
|
110 |
/** {@inheritDoc} */ |
|
111 |
@Override |
|
112 |
public void handleEvent(Object eventSource) { |
|
113 |
if (eventSource == combo_determinationModifier) { |
|
114 |
getEntity().setModifier(combo_determinationModifier.getSelection()); |
|
115 |
} else if (eventSource == checkbox_preferredFlag) { |
|
116 |
getEntity().setPreferredFlag(checkbox_preferredFlag.getSelection()); |
|
117 |
} else if (eventSource == selection_taxonBase) { |
|
118 |
getEntity().setTaxon(selection_taxonBase.getSelection()); |
|
119 |
} |
|
120 |
// else if(eventSource == TODO set of references){ |
|
121 |
// |
|
122 |
// } |
|
123 |
else if (eventSource == selection_agent) { |
|
124 |
getEntity().setDeterminer(selection_agent.getSelection()); |
|
125 |
} else if (eventSource == text_description) { |
|
126 |
getEntity().setDescription(text_description.getText()); |
|
127 |
} else if (eventSource == element_timePeriod) { |
|
128 |
getEntity().setTimeperiod(element_timePeriod.getTimePeriod()); |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GatheringEventDetailElementComposite.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
|
35 | 35 |
|
36 |
private final CdmNumberField absoluteElevationError;
|
|
37 |
private final CdmNumberField number_absoluteElevationMinimum;
|
|
38 |
private final CdmNumberField number_absoluteElevationMaximum;
|
|
39 |
private final CdmTextField collectingMethod;
|
|
40 |
private final CdmNumberField number_distanceToGround;
|
|
41 |
private final CdmNumberField number_distanceToWaterSurface;
|
|
42 |
private final CdmTextField gatheringEventDescription;
|
|
43 |
// private CollectingAreasDetailSection section_collectingAreas;
|
|
36 |
private final CdmNumberField absoluteElevationError; |
|
37 |
private final CdmNumberField number_absoluteElevationMinimum; |
|
38 |
private final CdmNumberField number_absoluteElevationMaximum; |
|
39 |
private final CdmTextField collectingMethod; |
|
40 |
private final CdmNumberField number_distanceToGround; |
|
41 |
private final CdmNumberField number_distanceToWaterSurface; |
|
42 |
private final CdmTextField gatheringEventDescription; |
|
43 |
private CollectingAreasDetailSection section_collectingAreas; |
|
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* <p> |
... | ... | |
61 | 61 |
formFactory.adapt(lblNewLabel_4, true, true); |
62 | 62 |
lblNewLabel_4.setText("Elevation Error"); |
63 | 63 |
|
64 |
absoluteElevationError = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
64 |
absoluteElevationError = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
|
|
65 | 65 |
((TableWrapData) absoluteElevationError.getMainControl().getLayoutData()).grabVertical = false; |
66 | 66 |
TableWrapData twd_cdmNumberField = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
67 | 67 |
twd_cdmNumberField.grabHorizontal = true; |
... | ... | |
73 | 73 |
formFactory.adapt(lblNewLabel_3, true, true); |
74 | 74 |
lblNewLabel_3.setText("Elevation Error Minumum (m)"); |
75 | 75 |
|
76 |
number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
76 |
number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
|
|
77 | 77 |
TableWrapData tableWrapData = (TableWrapData) number_absoluteElevationMinimum.getMainControl().getLayoutData(); |
78 | 78 |
tableWrapData.valign = TableWrapData.TOP; |
79 | 79 |
tableWrapData.grabVertical = false; |
... | ... | |
86 | 86 |
formFactory.adapt(lblNewLabel_2, true, true); |
87 | 87 |
lblNewLabel_2.setText("Elevation Maximum (m)"); |
88 | 88 |
|
89 |
number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
89 |
number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
|
|
90 | 90 |
TableWrapData twd_cdmNumberField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
91 | 91 |
twd_cdmNumberField_2.grabHorizontal = true; |
92 | 92 |
number_absoluteElevationMaximum.setLayoutData(twd_cdmNumberField_2); |
... | ... | |
97 | 97 |
formFactory.adapt(lblTestLabel, true, true); |
98 | 98 |
lblTestLabel.setText("Collecting Method"); |
99 | 99 |
|
100 |
collectingMethod = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0);
|
|
100 |
collectingMethod = CdmElementFactory.createCdmTextField(getLayoutComposite(), formFactory, this, (String) null, (Integer) null, 0);
|
|
101 | 101 |
TableWrapData twd_cdmTextField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
102 | 102 |
twd_cdmTextField_1.grabHorizontal = true; |
103 | 103 |
collectingMethod.setLayoutData(twd_cdmTextField_1); |
... | ... | |
108 | 108 |
formFactory.adapt(lblNewLabel_5, true, true); |
109 | 109 |
lblNewLabel_5.setText("Distance To Ground (m)"); |
110 | 110 |
|
111 |
number_distanceToGround = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
111 |
number_distanceToGround = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
|
|
112 | 112 |
TableWrapData twd_cdmNumberField_3 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
113 | 113 |
twd_cdmNumberField_3.grabHorizontal = true; |
114 | 114 |
number_distanceToGround.setLayoutData(twd_cdmNumberField_3); |
... | ... | |
119 | 119 |
formFactory.adapt(lblNewLabel_6, true, true); |
120 | 120 |
lblNewLabel_6.setText("Distance To Water Surface"); |
121 | 121 |
|
122 |
number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
|
|
122 |
number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
|
|
123 | 123 |
TableWrapData twd_cdmNumberField_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
124 | 124 |
twd_cdmNumberField_4.grabHorizontal = true; |
125 | 125 |
number_distanceToWaterSurface.setLayoutData(twd_cdmNumberField_4); |
... | ... | |
130 | 130 |
formFactory.adapt(lblNewLabel, true, true); |
131 | 131 |
lblNewLabel.setText("Gathering Event Description"); |
132 | 132 |
|
133 |
gatheringEventDescription = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0);
|
|
133 |
gatheringEventDescription = CdmElementFactory.createCdmTextField(getLayoutComposite(), formFactory, this, (String) null, (Integer) null, 0);
|
|
134 | 134 |
TableWrapData twd_cdmTextField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); |
135 | 135 |
twd_cdmTextField_2.grabHorizontal = true; |
136 | 136 |
gatheringEventDescription.setLayoutData(twd_cdmTextField_2); |
... | ... | |
151 | 151 |
number_distanceToWaterSurface.setText(String.valueOf(entity.getDistanceToWaterSurface())); |
152 | 152 |
gatheringEventDescription.setText(entity.getGatheringEventDescription()); |
153 | 153 |
|
154 |
// collectingArea |
|
155 |
// number_absoluteElevationError = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Error", entity.getAbsoluteElevationError(), style); |
|
156 |
// number_absoluteElevationMinimum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Minimum (m)", entity.getAbsoluteElevationMinimum(), style); |
|
157 |
// number_absoluteElevationMaximum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Maximum (m)", entity.getAbsoluteElevationMaximum(), style); |
|
158 |
|
|
159 |
// text_collectingMethod = formFactory.createTextWithLabelElement(formElement, "Collecting Method", entity.getCollectingMethod(), style); |
|
160 |
|
|
161 |
// number_distanceToGround = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Ground (m)", entity.getDistanceToGround(), style); |
|
162 |
// number_distanceToWaterSurface = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Water Surface (m)", entity.getDistanceToWaterSurface(), style); |
|
163 |
// exactLocation |
|
164 |
// text_gatheringEventDescription = formFactory.createTextWithLabelElement(formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style); |
|
165 |
|
|
166 | 154 |
// section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE); |
167 | 155 |
// section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
168 | 156 |
// section_collectingAreas.setEntity(entity); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.ui.selection; |
|
2 |
|
|
3 |
import org.eclipse.swt.SWT; |
|
4 |
import org.eclipse.swt.events.SelectionAdapter; |
|
5 |
import org.eclipse.swt.events.SelectionEvent; |
|
6 |
import org.eclipse.swt.events.SelectionListener; |
|
7 |
import org.eclipse.swt.graphics.Color; |
|
8 |
import org.eclipse.swt.widgets.Button; |
|
9 |
import org.eclipse.swt.widgets.Composite; |
|
10 |
import org.eclipse.swt.widgets.Label; |
|
11 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
12 |
import org.eclipse.wb.swt.ResourceManager; |
|
13 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
14 |
import org.springframework.security.core.GrantedAuthority; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
17 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
18 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
19 |
import eu.etaxonomy.cdm.model.common.Group; |
|
20 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
21 |
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; |
|
22 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
23 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
24 |
import eu.etaxonomy.taxeditor.preference.Resources; |
|
25 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory; |
|
26 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElementComposite; |
|
27 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
28 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
|
29 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
30 |
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; |
|
31 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
|
32 |
import eu.etaxonomy.taxeditor.ui.element.ILabeledElement; |
|
33 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
|
34 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
35 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
|
36 |
|
|
37 |
/** |
|
38 |
* package eu.etaxonomy.taxeditor.ui.selection; |
|
39 |
* |
|
40 |
* import org.eclipse.core.runtime.IStatus; |
|
41 |
* |
|
42 |
* /** |
|
43 |
* <p> |
|
44 |
* Abstract AbstractSelectionElement class. |
|
45 |
* </p> |
|
46 |
* |
|
47 |
* @author n.hoffmann |
|
48 |
* @created Nov 17, 2009 |
|
49 |
* @version 1.0 |
|
50 |
* @param <T> |
|
51 |
*/ |
|
52 |
public class EntitySelectionElementComposite<T extends ICdmBase> extends AbstractCdmFormElementComposite implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled { |
|
53 |
|
|
54 |
/** |
|
55 |
* Bitmask for configuring functionality of selection element |
|
56 |
*/ |
|
57 |
public static final int NOTHING = 0; // 000 |
|
58 |
public static final int EDITABLE = 1 << 0; // 001 |
|
59 |
public static final int DELETABLE = 1 << 1; // 010 |
|
60 |
public static final int SELECTABLE = 1 << 2; // 100 |
|
61 |
public static final int ALL = EDITABLE | DELETABLE | SELECTABLE; // 111 |
|
62 |
|
|
63 |
protected T entity; |
|
64 |
|
|
65 |
protected Label label; |
|
66 |
protected Label text; |
|
67 |
protected Button button_selection; |
|
68 |
|
|
69 |
private SelectionArbitrator selectionArbitrator; |
|
70 |
|
|
71 |
protected Button button_edit; |
|
72 |
|
|
73 |
private final String labelString; |
|
74 |
|
|
75 |
private final Composite selectableComposite; |
|
76 |
|
|
77 |
private Button button_remove; |
|
78 |
|
|
79 |
private final boolean isEditable; |
|
80 |
|
|
81 |
private final boolean isDeletable; |
|
82 |
|
|
83 |
private final ConversationHolder conversation; |
|
84 |
private Class<T> clazz; |
|
85 |
|
|
86 |
/** |
|
87 |
* <p> |
|
88 |
* Constructor for AbstractSelectionElement. |
|
89 |
* </p> |
|
90 |
* |
|
91 |
* @param formFactory |
|
92 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
|
93 |
* object. |
|
94 |
* @param conversation |
|
95 |
* TODO |
|
96 |
* @param parentElement |
|
97 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
|
98 |
* object. |
|
99 |
* @param labelString |
|
100 |
* a {@link java.lang.String} object. |
|
101 |
* @param entity |
|
102 |
* a T object. |
|
103 |
* @param isEditable |
|
104 |
* a boolean. |
|
105 |
* @param isSelectable |
|
106 |
* a boolean. |
|
107 |
* @param isDeletable |
|
108 |
* a boolean. |
|
109 |
* @param style |
|
110 |
* a int. |
|
111 |
* @param <T> |
|
112 |
* a T object. |
|
113 |
*/ |
|
114 |
public EntitySelectionElementComposite(Composite parent, FormToolkit formFactory, ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T entity, int mode, int style) { |
|
115 |
super(parent, formFactory, parentElement, style); |
|
116 |
|
|
117 |
this.isEditable = (mode & EDITABLE) == EDITABLE; |
|
118 |
this.isDeletable = (mode & DELETABLE) == DELETABLE; |
|
119 |
boolean isSelectable = (mode & SELECTABLE) == SELECTABLE; |
|
120 |
|
|
121 |
this.labelString = labelString; |
|
122 |
|
|
123 |
this.conversation = conversation; |
|
124 |
|
|
125 |
if (isSelectable && formFactory instanceof CdmFormFactory && ((CdmFormFactory) formFactory).getSelectionProvider() != null) { |
|
126 |
selectionArbitrator = ((CdmFormFactory) formFactory).createSelectionArbitrator(this); |
|
127 |
} |
|
128 |
|
|
129 |
//only for WindowBuilder |
|
130 |
Composite parentComposite = this; |
|
131 |
if(parentElement!=null){ |
|
132 |
parentComposite = parentElement.getLayoutComposite(); |
|
133 |
} |
|
134 |
|
|
135 |
label = formFactory.createLabel(parentComposite, labelString, SWT.NULL); |
|
136 |
|
|
137 |
addControl(label); |
|
138 |
|
|
139 |
selectableComposite = formFactory.createComposite(parentComposite, style); |
|
140 |
|
|
141 |
int columns = 2; |
|
142 |
if (isEditable) { |
|
143 |
columns += 1; |
|
144 |
} |
|
145 |
if (isDeletable) { |
|
146 |
columns += 1; |
|
147 |
} |
|
148 |
|
|
149 |
selectableComposite.setLayout(LayoutConstants.LAYOUT(columns, false)); |
|
150 |
selectableComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
151 |
|
|
152 |
addControl(selectableComposite); |
|
153 |
|
|
154 |
text = formFactory.createLabel(selectableComposite, null, SWT.WRAP); |
|
155 |
addControl(text); |
|
156 |
|
|
157 |
text.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
158 |
|
|
159 |
button_selection = formFactory.createButton(selectableComposite, null, SWT.PUSH); |
|
160 |
button_selection.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif")); |
Also available in: Unified diff