1 |
87f9934d
|
n.hoffmann
|
// $Id$
|
2 |
|
|
/**
|
3 |
|
|
* Copyright (C) 2007 EDIT
|
4 |
e4428955
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
5 |
87f9934d
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
6 |
e4428955
|
Patric Plitzner
|
*
|
7 |
87f9934d
|
n.hoffmann
|
* 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.
|
9 |
|
|
*/
|
10 |
|
|
|
11 |
|
|
package eu.etaxonomy.taxeditor.ui.section.occurrence;
|
12 |
|
|
|
13 |
|
|
import java.util.Arrays;
|
14 |
|
|
import java.util.Collection;
|
15 |
|
|
|
16 |
7cf1f544
|
n.hoffmann
|
import org.eclipse.jface.action.Action;
|
17 |
e4428955
|
Patric Plitzner
|
import org.eclipse.jface.action.IAction;
|
18 |
7cf1f544
|
n.hoffmann
|
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;
|
23 |
|
|
|
24 |
87f9934d
|
n.hoffmann
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
25 |
|
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
26 |
|
|
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
|
27 |
7cf1f544
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
28 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
29 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
30 |
87f9934d
|
n.hoffmann
|
|
31 |
|
|
/**
|
32 |
|
|
* @author n.hoffmann
|
33 |
|
|
* @created May 11, 2011
|
34 |
|
|
* @version 1.0
|
35 |
|
|
*/
|
36 |
|
|
public class CurrentDeterminationDetailSection extends
|
37 |
|
|
AbstractDeterminationEventDetailSection {
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* @param formFactory
|
41 |
|
|
* @param conversation
|
42 |
|
|
* @param parentElement
|
43 |
|
|
* @param style
|
44 |
|
|
*/
|
45 |
|
|
public CurrentDeterminationDetailSection(CdmFormFactory formFactory,
|
46 |
|
|
ConversationHolder conversation, ICdmFormElement parentElement,
|
47 |
|
|
int style) {
|
48 |
|
|
super(formFactory, conversation, parentElement, "Current Determination", style);
|
49 |
|
|
}
|
50 |
e4428955
|
Patric Plitzner
|
|
51 |
7cf1f544
|
n.hoffmann
|
@Override
|
52 |
|
|
protected Control createToolbar() {
|
53 |
|
|
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
|
54 |
e4428955
|
Patric Plitzner
|
|
55 |
|
|
Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
|
56 |
7cf1f544
|
n.hoffmann
|
/* (non-Javadoc)
|
57 |
|
|
* @see org.eclipse.jface.action.Action#run()
|
58 |
|
|
*/
|
59 |
|
|
@Override
|
60 |
|
|
public void run() {
|
61 |
|
|
DeterminationEvent element = createNewElement();
|
62 |
e4428955
|
Patric Plitzner
|
|
63 |
7cf1f544
|
n.hoffmann
|
// set as preferred determination
|
64 |
|
|
getEntity().setPreferredDetermination(element);
|
65 |
e4428955
|
Patric Plitzner
|
|
66 |
7cf1f544
|
n.hoffmann
|
if(element != null){
|
67 |
e4428955
|
Patric Plitzner
|
if(! getSection().isExpanded()) {
|
68 |
|
|
getSection().setExpanded(true);
|
69 |
|
|
}
|
70 |
|
|
internalUpdateSection(true);
|
71 |
7cf1f544
|
n.hoffmann
|
}
|
72 |
|
|
}
|
73 |
|
|
};
|
74 |
|
|
addAction.setImageDescriptor(new ImageDescriptor() {
|
75 |
e4428955
|
Patric Plitzner
|
|
76 |
7cf1f544
|
n.hoffmann
|
@Override
|
77 |
|
|
public ImageData getImageData() {
|
78 |
|
|
return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
|
79 |
|
|
}
|
80 |
|
|
});
|
81 |
|
|
addAction.setToolTipText(getTooltipString());
|
82 |
e4428955
|
Patric Plitzner
|
|
83 |
7cf1f544
|
n.hoffmann
|
toolBarManager.add(addAction);
|
84 |
e4428955
|
Patric Plitzner
|
|
85 |
7cf1f544
|
n.hoffmann
|
return toolBarManager.createControl(this);
|
86 |
|
|
}
|
87 |
e4428955
|
Patric Plitzner
|
|
88 |
7cf1f544
|
n.hoffmann
|
@Override
|
89 |
|
|
public void refresh() {
|
90 |
|
|
internalUpdateSection(false);
|
91 |
|
|
}
|
92 |
87f9934d
|
n.hoffmann
|
|
93 |
|
|
/* (non-Javadoc)
|
94 |
|
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
|
95 |
|
|
*/
|
96 |
|
|
@Override
|
97 |
|
|
public Collection<DeterminationEvent> getCollection(DerivedUnitFacade entity) {
|
98 |
|
|
DeterminationEvent preferredDetermination = entity.getPreferredDetermination();
|
99 |
|
|
return preferredDetermination != null ? Arrays.asList(new DeterminationEvent[]{preferredDetermination}) : null;
|
100 |
|
|
}
|
101 |
e4428955
|
Patric Plitzner
|
|
102 |
87f9934d
|
n.hoffmann
|
/* (non-Javadoc)
|
103 |
|
|
* @see eu.etaxonomy.taxeditor.ui.section.occurrence.AbstractDeterminationEventDetailSection#createNewElement()
|
104 |
|
|
*/
|
105 |
|
|
@Override
|
106 |
|
|
public DeterminationEvent createNewElement() {
|
107 |
|
|
DeterminationEvent newElement = super.createNewElement();
|
108 |
|
|
newElement.setPreferredFlag(true);
|
109 |
|
|
return newElement;
|
110 |
|
|
}
|
111 |
e4428955
|
Patric Plitzner
|
|
112 |
3d466a77
|
n.hoffmann
|
|
113 |
|
|
/* (non-Javadoc)
|
114 |
|
|
* @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
|
115 |
|
|
*/
|
116 |
|
|
/** {@inheritDoc} */
|
117 |
|
|
@Override
|
118 |
|
|
protected String getTooltipString() {
|
119 |
|
|
return "Create new current determination event";
|
120 |
|
|
}
|
121 |
87f9934d
|
n.hoffmann
|
|
122 |
|
|
}
|