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
.occurrence
;
13 import java
.util
.Arrays
;
14 import java
.util
.Collection
;
16 import org
.eclipse
.jface
.action
.Action
;
17 import org
.eclipse
.jface
.action
.IAction
;
18 import org
.eclipse
.jface
.action
.ToolBarManager
;
19 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
20 import org
.eclipse
.swt
.SWT
;
21 import org
.eclipse
.swt
.graphics
.ImageData
;
22 import org
.eclipse
.swt
.widgets
.Control
;
24 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
25 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
26 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
27 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
29 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
33 * @created May 11, 2011
36 public class CurrentDeterminationDetailSection
extends
37 AbstractDeterminationEventDetailSection
{
42 * @param parentElement
45 public CurrentDeterminationDetailSection(CdmFormFactory formFactory
,
46 ConversationHolder conversation
, ICdmFormElement parentElement
,
48 super(formFactory
, conversation
, parentElement
, "Current Determination", style
);
52 protected Control
createToolbar() {
53 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
55 Action addAction
= new Action("add", IAction
.AS_PUSH_BUTTON
){
57 * @see org.eclipse.jface.action.Action#run()
61 DeterminationEvent element
= createNewElement();
63 // set as preferred determination
64 getEntity().setPreferredDetermination(element
);
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 public void refresh() {
90 internalUpdateSection(false);
94 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
97 public Collection
<DeterminationEvent
> getCollection(DerivedUnitFacade entity
) {
98 DeterminationEvent preferredDetermination
= entity
.getPreferredDetermination();
99 return preferredDetermination
!= null ? Arrays
.asList(new DeterminationEvent
[]{preferredDetermination
}) : null;
103 * @see eu.etaxonomy.taxeditor.ui.section.occurrence.AbstractDeterminationEventDetailSection#createNewElement()
106 public DeterminationEvent
createNewElement() {
107 DeterminationEvent newElement
= super.createNewElement();
108 newElement
.setPreferredFlag(true);
114 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
118 protected String
getTooltipString() {
119 return "Create new current determination event";