4 package eu
.etaxonomy
.taxeditor
.forms
;
8 import org
.eclipse
.jface
.action
.Action
;
9 import org
.eclipse
.jface
.action
.IAction
;
10 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
11 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.events
.SelectionAdapter
;
14 import org
.eclipse
.swt
.events
.SelectionEvent
;
15 import org
.eclipse
.swt
.widgets
.Button
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.ui
.forms
.widgets
.Section
;
19 import eu
.etaxonomy
.cdm
.model
.common
.DescriptionElementSource
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
26 public class OriginalSourceSection
extends AbstractEntitySetSection
<DescriptionElementBase
> implements IPropertyChangeListener
{
29 public OriginalSourceSection(Composite parent
, DescriptionElementBase entity
, int style
){
30 super(parent
, entity
, Section
.TWISTIE
| Section
.COMPACT
| style
);
38 public void createDynamicContents() {
40 Set
<DescriptionElementSource
> sources
= null;
41 if(getEntity() != null){
42 sources
= getEntity().getSources();
45 if(sources
== null || sources
.size() == 0){
46 toolkit
.createLabel(container
, "No citations yet.");
48 for(DescriptionElementSource source
: sources
){
49 DescriptionElementSourceComposite descriptionElementSourceComposite
= toolkit
.createDescriptionElementSourceComposite(container
, source
, SWT
.NULL
);
50 descriptionElementSourceComposite
.addPropertyChangeListener(this);
52 Button button_remove
= toolkit
.createButton(container
, "Remove", SWT
.PUSH
);
53 button_remove
.addSelectionListener(new RemoveListener(source
));
58 private class RemoveListener
extends SelectionAdapter
{
59 private DescriptionElementSource source
;
61 public RemoveListener(DescriptionElementSource source
){
66 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
69 public void widgetSelected(SelectionEvent e
) {
70 getEntity().removeSource(source
);
71 internalUpdateSection(true);
76 * @see eu.etaxonomy.taxeditor.forms.AbstractEntitySetSection#getAddAction()
79 protected IAction
getAddAction() {
80 Action addCitation
= new Action("add", Action
.AS_PUSH_BUTTON
){
82 * @see org.eclipse.jface.action.Action#run()
86 getEntity().addSource(DescriptionElementSource
.NewInstance());
87 if(! getSection().isExpanded())
88 getSection().setExpanded(true);
89 internalUpdateSection(true);
92 addCitation
.setToolTipText("Create a new citation");
97 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
99 public void propertyChange(PropertyChangeEvent event
) {
100 firePropertyChangeEvent(event
);