3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.identifier
;
13 import java
.util
.Collection
;
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
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
24 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
25 import eu
.etaxonomy
.cdm
.model
.common
.Identifier
;
26 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
33 * CollectingAreasDetailSection class.
37 * @created Oct 14, 2010
40 public class IdentifierDetailSection
extends AbstractEntityCollectionSection
<DerivedUnitFacade
, Identifier
> {
43 * <p>Constructor for CollectingAreasDetailSection.</p>
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.
50 public IdentifierDetailSection(CdmFormFactory formFactory
,
51 ConversationHolder conversation
, ICdmFormElement parentElement
, int style
) {
52 super(formFactory
, conversation
, parentElement
, "Identifiers", style
);
56 protected Control
createToolbar() {
57 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
59 Action addAction
= new Action("add", IAction
.AS_PUSH_BUTTON
){
61 * @see org.eclipse.jface.action.Action#run()
65 Identifier element
= createNewElement();
67 if(! getSection().isExpanded()) {
68 getSection().setExpanded(true);
70 internalUpdateSection(true);
74 addAction
.setImageDescriptor(new ImageDescriptor() {
77 public ImageData
getImageData() {
78 return ImageResources
.getImage(ImageResources
.ADD_ICON
).getImageData();
81 addAction
.setToolTipText(getTooltipString());
83 toolBarManager
.add(addAction
);
85 return toolBarManager
.createControl(this);
89 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
93 public Collection
<Identifier
> getCollection(DerivedUnitFacade entity
) {
94 return entity
.getIdentifiers();
98 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
102 public Identifier
createNewElement() {
103 return Identifier
.NewInstance(getEntity().baseUnit(), null, null);
107 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
111 public void addElement(Identifier element
) {
112 getEntity().addIdentifier(element
);
116 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
120 public void removeElement(Identifier element
) {
121 getEntity().removeIdentifier(getEntity().getIdentifiers().get(0));
122 getConversationHolder().commit();
123 System
.out
.println();
127 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
131 public String
getEmptyString() {
132 return "No identifiers yet.";
136 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
140 protected String
getTooltipString() {
141 return "Add an identifier";