Revision d89cdff1
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java | ||
---|---|---|
16 | 16 |
import org.eclipse.swt.graphics.Color; |
17 | 17 |
import org.eclipse.swt.widgets.Button; |
18 | 18 |
import org.eclipse.swt.widgets.Composite; |
19 |
import org.eclipse.swt.widgets.Event; |
|
20 |
import org.eclipse.swt.widgets.Listener; |
|
21 | 19 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
22 | 20 |
|
23 | 21 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
59 | 57 |
|
60 | 58 |
private Color backgroundColor; |
61 | 59 |
|
62 |
public AbstractEntityCollectionElement(CdmFormFactory formFactory, |
|
63 |
AbstractFormSection section, ENTITY entity, |
|
64 |
SelectionListener removeListener, Color backgroundColor, int style) { |
|
65 |
this(formFactory, section, entity, removeListener, false, backgroundColor, style); |
|
66 |
} |
|
67 | 60 |
public AbstractEntityCollectionElement(CdmFormFactory formFactory, |
68 | 61 |
AbstractFormSection section, ENTITY entity, SelectionListener removeListener, |
69 |
boolean isChoosableEntity, Color backgroundColor, int style) {
|
|
62 |
Color backgroundColor, int style) { |
|
70 | 63 |
super(formFactory, (ICdmFormElement) section); |
71 | 64 |
this.entity = entity; |
72 | 65 |
|
... | ... | |
97 | 90 |
container.setLayout(containerLayout); |
98 | 91 |
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
99 | 92 |
|
100 |
if(isChoosableEntity){ |
|
101 |
btnChooseEntity = formFactory.createButton(box, null, SWT.PUSH); |
|
102 |
addControl(btnChooseEntity); |
|
103 |
|
|
104 |
btnChooseEntity.setLayoutData(LayoutConstants.RIGHT()); |
|
105 |
btnChooseEntity.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON)); |
|
106 |
btnChooseEntity.setToolTipText("Browse"); |
|
107 |
btnChooseEntity.addListener(SWT.Selection, new Listener() { |
|
108 |
|
|
109 |
@Override |
|
110 |
public void handleEvent(Event event) { |
|
111 |
ENTITY entity = selectFromDialog(); |
|
112 |
if(entity!=null){ |
|
113 |
if(getParentElement() instanceof AbstractEntityCollectionSection){ |
|
114 |
((AbstractEntityCollectionSection)getParentElement()).removeElement(getEntity()); |
|
115 |
((AbstractEntityCollectionSection)getParentElement()).addElement(entity); |
|
116 |
} |
|
117 |
firePropertyChangeEvent(this); |
|
118 |
} |
|
119 |
} |
|
120 |
}); |
|
121 |
} |
|
122 |
|
|
123 | 93 |
if (removeListener != null) { |
124 | 94 |
btnRemove = formFactory.createButton(box, null, SWT.PUSH); |
125 | 95 |
addControl(btnRemove); |
Also available in: Unified diff
ref #6333 Remove framework for exchanging an element in the details view