Project

General

Profile

« Previous | Next » 

Revision 7e65b368

Added by Patrick Plitzner over 7 years ago

Add identifer section to supplemental data view #5898

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailElement.java
23 23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
24 24

  
25 25
/**
26
 * <p>
27
 * CollectionDetailElement class.
28
 * </p>
26
 * 
27
 * @author pplitzner
29 28
 *
30
 * @author n.hoffmann
31
 * @created Oct 13, 2010
32
 * @version 1.0
33 29
 */
34 30
public class IdentifierDetailElement extends AbstractEntityCollectionElement<Identifier> {
35 31

  
......
37 33

  
38 34
	private TermComboElement<DefinedTerm> comboIdentifierType;
39 35

  
40
	/**
41
     * <p>
42
     * Constructor for CollectingAreasDetailElement.
43
     * </p>
44
     *
45
     * @param formFactory
46
     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
47
     *            object.
48
     * @param section
49
     *            a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
50
     *            object.
51
     * @param entity
52
     *            a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
53
     * @param removeListener
54
     *            a {@link org.eclipse.swt.events.SelectionListener} object.
55
     * @param style
56
     *            a int.
57
     */
58 36
    public IdentifierDetailElement(CdmFormFactory formFactory,
59 37
            AbstractFormSection section, Identifier entity,
60 38
            SelectionListener removeListener, int style) {
61 39
        super(formFactory, section, entity, removeListener, null, style);
62 40
    }
63 41

  
64
    /*
65
     * (non-Javadoc)
66
     *
67
     * @see
68
     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
69
     * (java.lang.Object)
70
     */
71 42
    /** {@inheritDoc} */
72 43
    @Override
73 44
    public void setEntity(Identifier entity) {
......
76 47
        comboIdentifierType.setSelection(entity.getType());
77 48
    }
78 49

  
79
	/*
80
	 * (non-Javadoc)
81
	 *
82
	 * @see
83
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
84
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
85
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
86
	 */
87 50
	/** {@inheritDoc} */
88 51
	@Override
89 52
    public void createControls(ICdmFormElement formElement, int style) {
......
91 54
		comboIdentifierType = formFactory.createDefinedTermComboElement(TermType.IdentifierType, formElement, "Type", null, style);
92 55
	}
93 56

  
94
	/*
95
	 * (non-Javadoc)
96
	 *
97
	 * @see
98
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
99
	 * .lang.Object)
100
	 */
101
	/** {@inheritDoc} */
102 57
	@Override
103 58
	public void handleEvent(Object eventSource) {
104 59
		if (eventSource == textIdentifier) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/identifier/IdentifierDetailSection.java
12 12

  
13 13
import java.util.Collection;
14 14

  
15
import org.eclipse.jface.action.Action;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.ToolBarManager;
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.graphics.ImageData;
21
import org.eclipse.swt.widgets.Control;
22

  
23 15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
16
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
25 17
import eu.etaxonomy.cdm.model.common.Identifier;
26
import eu.etaxonomy.taxeditor.model.ImageResources;
27 18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
28 19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
29 20
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
30 21

  
31 22
/**
32
 * <p>
33
 * CollectingAreasDetailSection class.
34
 * </p>
23
 * 
24
 * @author pplitzner
35 25
 *
36
 * @author n.hoffmann
37
 * @created Oct 14, 2010
38
 * @version 1.0
39 26
 */
40
public class IdentifierDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, Identifier> {
27
public class IdentifierDetailSection extends AbstractEntityCollectionSection<IdentifiableEntity, Identifier> {
41 28

  
42
	/**
43
	 * <p>Constructor for CollectingAreasDetailSection.</p>
44
	 *
45
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
46
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
47
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
48
	 * @param style a int.
49
	 */
50 29
	public IdentifierDetailSection(CdmFormFactory formFactory,
51 30
			ConversationHolder conversation, ICdmFormElement parentElement, int style) {
52 31
		super(formFactory, conversation, parentElement, "Identifiers", style);
53 32
	}
54 33

  
55
	@Override
56
    protected Control createToolbar() {
57
        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
58

  
59
        Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
60
            /* (non-Javadoc)
61
             * @see org.eclipse.jface.action.Action#run()
62
             */
63
            @Override
64
            public void run() {
65
                Identifier element = createNewElement();
66
                if(element != null){
67
                    if(! getSection().isExpanded()) {
68
                        getSection().setExpanded(true);
69
                    }
70
                    internalUpdateSection(true);
71
                }
72
            }
73
        };
74
        addAction.setImageDescriptor(new ImageDescriptor() {
75

  
76
            @Override
77
            public ImageData getImageData() {
78
                return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
79
            }
80
        });
81
        addAction.setToolTipText(getTooltipString());
82

  
83
        toolBarManager.add(addAction);
84

  
85
        return toolBarManager.createControl(this);
86
    }
87

  
88
	/* (non-Javadoc)
89
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
90
	 */
91 34
	/** {@inheritDoc} */
92 35
	@Override
93
	public Collection<Identifier> getCollection(DerivedUnitFacade entity) {
36
	public Collection<Identifier> getCollection(IdentifiableEntity entity) {
94 37
		return entity.getIdentifiers();
95 38
	}
96 39

  
97
	/* (non-Javadoc)
98
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
99
	 */
100 40
	/** {@inheritDoc} */
101 41
	@Override
102 42
	public Identifier createNewElement() {
103
		return Identifier.NewInstance(getEntity().baseUnit(), null, null);
43
		return Identifier.NewInstance(null, null);
104 44
	}
105 45

  
106
	/* (non-Javadoc)
107
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
108
	 */
109 46
	/** {@inheritDoc} */
110 47
	@Override
111 48
	public void addElement(Identifier element) {
112 49
		getEntity().addIdentifier(element);
113 50
	}
114 51

  
115
	/* (non-Javadoc)
116
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
117
	 */
118 52
	/** {@inheritDoc} */
119 53
	@Override
120 54
	public void removeElement(Identifier element) {
121
	    getEntity().removeIdentifier(getEntity().getIdentifiers().get(0));
55
	    getEntity().removeIdentifier(element);
122 56
	    getConversationHolder().commit();
123 57
	}
124 58

  
125
	/* (non-Javadoc)
126
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
127
	 */
128 59
	/** {@inheritDoc} */
129 60
	@Override
130 61
	public String getEmptyString() {
131 62
		return "No identifiers yet.";
132 63
	}
133 64

  
134
	/* (non-Javadoc)
135
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
136
	 */
137 65
	/** {@inheritDoc} */
138 66
	@Override
139 67
	protected String getTooltipString() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java
27 27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28 28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29 29
import eu.etaxonomy.taxeditor.ui.element.RootElement;
30
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
30 31
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
31 32
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
32 33
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
......
163 164

  
164 165
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
165 166

  
167
        IdentifierDetailSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
168
        
169
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
170

  
166 171
        addPart(creditSection);
167 172
        addPart(extensionSection);
168 173
        addPart(rightsSection);
169 174
        addPart(sourceSection);
175
        addPart(identifierSection);
170 176

  
171 177
	}
172 178

  

Also available in: Unified diff