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/section/campanula/EntitySelectionFieldController.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.ui.section.campanula; |
11 | 11 |
|
12 |
import org.eclipse.swt.SWT; |
|
12 |
import org.eclipse.core.runtime.IStatus; |
|
13 |
import org.eclipse.jface.wizard.WizardDialog; |
|
13 | 14 |
import org.eclipse.swt.events.SelectionAdapter; |
14 | 15 |
import org.eclipse.swt.events.SelectionEvent; |
15 |
import org.eclipse.swt.events.SelectionListener; |
|
16 | 16 |
import org.eclipse.swt.graphics.Color; |
17 | 17 |
import org.eclipse.swt.widgets.Button; |
18 | 18 |
import org.eclipse.swt.widgets.Composite; |
... | ... | |
21 | 21 |
import org.springframework.security.core.GrantedAuthority; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
24 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
25 | 24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
26 | 25 |
import eu.etaxonomy.cdm.model.common.Group; |
27 | 26 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
... | ... | |
35 | 34 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
36 | 35 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
37 | 36 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
38 |
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; |
|
39 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
|
40 |
import eu.etaxonomy.taxeditor.ui.element.ILabeledElement; |
|
41 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
|
42 | 37 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
43 | 38 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
44 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
|
39 |
import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.IEntitySelectionElement; |
|
40 |
import eu.etaxonomy.taxeditor.ui.selection.EditFromSelectionWizard; |
|
45 | 41 |
|
46 | 42 |
/** |
47 | 43 |
* @author pplitzner |
48 | 44 |
* @date 13.08.2013 |
49 | 45 |
* |
50 | 46 |
*/ |
51 |
public class EntitySelectionFieldController<T extends ICdmBase> extends AbstractCdmFormElement implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled {
|
|
47 |
public class EntitySelectionFieldController<T extends ICdmBase> extends AbstractCdmFormElement implements IEntitySelectionElement<T>{
|
|
52 | 48 |
|
53 | 49 |
/** |
54 | 50 |
* Bitmask for configuring functionality of selection element |
... | ... | |
129 | 125 |
selectionArbitrator = formFactory.createSelectionArbitrator(this); |
130 | 126 |
} |
131 | 127 |
|
132 |
createControls(getLayoutComposite(), entitySelectionField, SWT.NULL);
|
|
128 |
createControls(entitySelectionField);
|
|
133 | 129 |
|
134 | 130 |
setEntity(entity); |
135 | 131 |
} |
... | ... | |
139 | 135 |
this.clazz = clazz; |
140 | 136 |
} |
141 | 137 |
|
142 |
private void createControls(Composite parent, EntitySelectionField entitySelectionField, int style) {
|
|
138 |
private void createControls(EntitySelectionField entitySelectionField) {
|
|
143 | 139 |
|
144 | 140 |
// label = formFactory.createLabel(getLayoutComposite(), labelString, SWT.NULL); |
145 | 141 |
// |
146 | 142 |
// addControl(label); |
147 | 143 |
|
148 |
selectableComposite = entitySelectionField;//formFactory.createComposite(getLayoutComposite());
|
|
144 |
selectableComposite = entitySelectionField; |
|
149 | 145 |
|
150 | 146 |
int columns = 2; |
151 | 147 |
if (isEditable) { |
... | ... | |
160 | 156 |
|
161 | 157 |
addControl(selectableComposite); |
162 | 158 |
|
163 |
text = entitySelectionField.getText();//formFactory.createLabel(selectableComposite, null, SWT.WRAP);
|
|
159 |
text = entitySelectionField.getText(); |
|
164 | 160 |
addControl(text); |
165 | 161 |
|
166 | 162 |
text.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
167 | 163 |
text.setBackground(AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND)); |
168 | 164 |
|
169 |
button_selection = entitySelectionField.getButton_selection();//formFactory.createButton(selectableComposite, null, SWT.PUSH);
|
|
165 |
button_selection = entitySelectionField.getButton_selection(); |
|
170 | 166 |
button_selection.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON)); |
171 | 167 |
button_selection.setToolTipText("Browse existing"); |
172 | 168 |
|
173 | 169 |
addControl(button_selection); |
174 | 170 |
button_selection.addSelectionListener(this); |
175 | 171 |
|
172 |
button_edit = entitySelectionField.getButton_edit(); |
|
176 | 173 |
if (isEditable) { |
177 |
button_edit = entitySelectionField.getButton_edit();//formFactory.createButton(selectableComposite, null, SWT.PUSH); |
|
178 |
button_edit.setImage(ImageResources.getImage(ImageResources.EDIT_ICON)); |
|
179 |
button_edit.setToolTipText("Edit"); |
|
180 | 174 |
addControl(button_edit); |
181 |
// button_edit.addSelectionListener(new EditListener(this)); |
|
175 |
button_edit.addSelectionListener(new EditListener(this)); |
|
176 |
} |
|
177 |
else{ |
|
178 |
button_edit.setVisible(false); |
|
182 | 179 |
} |
183 | 180 |
|
181 |
button_remove = entitySelectionField.getButton_remove(); |
|
184 | 182 |
if (isDeletable) { |
185 |
button_remove = entitySelectionField.getButton_remove();//formFactory.createButton(selectableComposite, null, SWT.PUSH); |
|
186 |
button_remove.setImage(ImageResources.getImage(ImageResources.TRASH_ICON)); |
|
187 |
button_remove.setToolTipText("Remove"); |
|
188 | 183 |
addControl(button_remove); |
189 |
// button_remove.addSelectionListener(new DeleteListener(this)); |
|
184 |
button_remove.addSelectionListener(new DeleteListener(this)); |
|
185 |
} |
|
186 |
else{ |
|
187 |
button_remove.setVisible(false); |
|
190 | 188 |
} |
191 | 189 |
} |
192 | 190 |
|
... | ... | |
262 | 260 |
} |
263 | 261 |
} |
264 | 262 |
|
265 |
/** |
|
266 |
* <p> |
|
267 |
* updateFromWizard |
|
268 |
* </p> |
|
269 |
*/ |
|
270 |
protected void updateFromWizard() { |
|
263 |
@Override |
|
264 |
public void updateFromWizard() { |
|
271 | 265 |
updateElement(); |
272 | 266 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
273 | 267 |
} |
... | ... | |
334 | 328 |
return selectionArbitrator; |
335 | 329 |
} |
336 | 330 |
|
337 |
/** |
|
338 |
* Convenient access to current shell |
|
339 |
* |
|
340 |
* @return a {@link org.eclipse.swt.widgets.Shell} object. |
|
341 |
*/ |
|
342 |
protected Shell getShell() { |
|
331 |
@Override |
|
332 |
public Shell getShell() { |
|
343 | 333 |
return getLayoutComposite().getShell(); |
344 | 334 |
} |
345 | 335 |
|
... | ... | |
354 | 344 |
|
355 | 345 |
private class DeleteListener extends SelectionAdapter { |
356 | 346 |
|
357 |
private final EntitySelectionElement<T> selectionElement;
|
|
347 |
private final EntitySelectionFieldController<T> selectionElement;
|
|
358 | 348 |
|
359 |
public DeleteListener(EntitySelectionElement<T> selectionElement) {
|
|
349 |
public DeleteListener(EntitySelectionFieldController<T> selectionElement) {
|
|
360 | 350 |
this.selectionElement = selectionElement; |
361 | 351 |
} |
362 | 352 |
|
... | ... | |
369 | 359 |
|
370 | 360 |
private class EditListener extends SelectionAdapter { |
371 | 361 |
|
372 |
private final EntitySelectionElement<T> selectionElement; |
|
362 |
private final IEntitySelectionElement<T> selectionElement;
|
|
373 | 363 |
|
374 |
public EditListener(EntitySelectionElement<T> selectionElement) { |
|
364 |
public EditListener(IEntitySelectionElement<T> selectionElement) {
|
|
375 | 365 |
this.selectionElement = selectionElement; |
376 | 366 |
} |
377 | 367 |
|
378 | 368 |
/** {@inheritDoc} */ |
379 | 369 |
@Override |
380 | 370 |
public void widgetSelected(SelectionEvent e) { |
381 |
// WizardDialog dialog = new WizardDialog(selectionElement.getShell(), new EditFromSelectionWizard(selectionElement));
|
|
382 |
// if (dialog.open() == IStatus.OK) {
|
|
383 |
// selectionElement.updateFromWizard();
|
|
384 |
// }
|
|
371 |
WizardDialog dialog = new WizardDialog(selectionElement.getShell(), new EditFromSelectionWizard(selectionElement)); |
|
372 |
if (dialog.open() == IStatus.OK) { |
|
373 |
selectionElement.updateFromWizard(); |
|
374 |
} |
|
385 | 375 |
} |
386 | 376 |
} |
387 | 377 |
|
Also available in: Unified diff