Adjustments to recent changes in LibrAlign.
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / media / MediaSpecimenGeneralDetailSection.java
1 // $Id$
2 /**
3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.ui.section.occurrence.media;
11
12 import org.eclipse.jface.action.Action;
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.action.ToolBarManager;
15 import org.eclipse.jface.viewers.ISelectionProvider;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.widgets.Control;
18
19 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
20 import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
21 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
25 import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
26
27 /**
28 * @author pplitzner
29 * @date 12.12.2013
30 *
31 */
32 public class MediaSpecimenGeneralDetailSection extends AbstractCdmDetailSection<MediaSpecimen> {
33
34 private MediaSpecimenGeneralDetailElement mediaSpecimenGeneralDetailElement;
35
36 /**
37 * @param formFactory
38 * @param conversation
39 * @param parentElement
40 * @param selectionProvider
41 * @param style
42 */
43 public MediaSpecimenGeneralDetailSection(CdmFormFactory formFactory,
44 ConversationHolder conversation, ICdmFormElement parentElement,
45 ISelectionProvider selectionProvider, int style) {
46 super(formFactory, conversation, parentElement, selectionProvider, style);
47 }
48
49
50 /* (non-Javadoc)
51 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
52 */
53 @Override
54 public String getHeading() {
55 return "General Media Specimen";
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.ui.forms.widgets.ExpandableComposite#setText(java.lang.String)
60 */
61 @Override
62 public void setText(String title) {
63 String text = null;
64 if(getEntity()!=null && getEntity().getKindOfUnit()!=null){
65 if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getArtworkTerm())){
66 text = "Artwork";
67 }
68 else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getLivingPlantPhotoTerm())){
69 text = "Living Plant Photo";
70 }
71 else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getSpecimenScanTerm())){
72 text = "Specimen Scan";
73 }
74 else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getDetailImageTerm())){
75 text = "Detail Image";
76 }
77 }
78 if(text!=null){
79 super.setText(text);
80 }
81 else{
82 super.setText(title);
83 }
84 }
85
86 @Override
87 protected Control createToolbar() {
88 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
89
90 String actionLabel = "Change View Type";
91 Action addAction = new Action(actionLabel, IAction.AS_PUSH_BUTTON) {
92 /* (non-Javadoc)
93 * @see org.eclipse.jface.action.Action#run()
94 */
95 @Override
96 public void run() {
97 mediaSpecimenGeneralDetailElement.toogleAdvancedMediaView();
98 }
99 };
100 addAction.setToolTipText(actionLabel);
101
102 toolBarManager.add(addAction);
103
104 return toolBarManager.createControl(this);
105 }
106
107 /* (non-Javadoc)
108 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
109 */
110 @Override
111 protected AbstractCdmDetailElement<MediaSpecimen> createCdmDetailElement(AbstractCdmDetailSection<MediaSpecimen> parentElement, int style) {
112 mediaSpecimenGeneralDetailElement = formFactory.createMediaSpecimenGeneralDetailElement(parentElement);
113 return mediaSpecimenGeneralDetailElement;
114 }
115 }