merge-update from trunk
[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
26 /**
27 * @author pplitzner
28 * @date 12.12.2013
29 *
30 */
31 public class MediaSpecimenGeneralDetailSection extends AbstractCdmDetailSection<MediaSpecimen> {
32
33 private MediaSpecimenGeneralDetailElement mediaSpecimenGeneralDetailElement;
34
35 /**
36 * @param formFactory
37 * @param conversation
38 * @param parentElement
39 * @param selectionProvider
40 * @param style
41 */
42 public MediaSpecimenGeneralDetailSection(CdmFormFactory formFactory,
43 ConversationHolder conversation, ICdmFormElement parentElement,
44 ISelectionProvider selectionProvider, int style) {
45 super(formFactory, conversation, parentElement, selectionProvider, style);
46 }
47
48
49 /* (non-Javadoc)
50 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
51 */
52 @Override
53 public String getHeading() {
54 return "General";
55 }
56
57 /* (non-Javadoc)
58 * @see org.eclipse.ui.forms.widgets.ExpandableComposite#setText(java.lang.String)
59 */
60 @Override
61 public void setText(String title) {
62 // String text = null;
63 // if(getEntity()!=null && getEntity().getKindOfUnit()!=null){
64 // if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getArtworkTerm())){
65 // text = "Artwork";
66 // }
67 // else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getLivingPlantPhotoTerm())){
68 // text = "Living Plant Photo";
69 // }
70 // else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getSpecimenScanTerm())){
71 // text = "Specimen Scan";
72 // }
73 // else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getDetailImageTerm())){
74 // text = "Detail Image";
75 // }
76 // }
77 // if(text!=null){
78 // super.setText(text);
79 // }
80 // else{
81 super.setText(title);
82 // }
83 }
84
85 @Override
86 protected Control createToolbar() {
87 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
88
89 String actionLabel = "Change View Type";
90 Action addAction = new Action(actionLabel, IAction.AS_PUSH_BUTTON) {
91 /* (non-Javadoc)
92 * @see org.eclipse.jface.action.Action#run()
93 */
94 @Override
95 public void run() {
96 mediaSpecimenGeneralDetailElement.toogleAdvancedMediaView();
97 }
98 };
99 addAction.setToolTipText(actionLabel);
100
101 toolBarManager.add(addAction);
102
103 return toolBarManager.createControl(this);
104 }
105
106 /* (non-Javadoc)
107 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
108 */
109 @Override
110 protected AbstractCdmDetailElement<MediaSpecimen> createCdmDetailElement(AbstractCdmDetailSection<MediaSpecimen> parentElement, int style) {
111 mediaSpecimenGeneralDetailElement = formFactory.createMediaSpecimenGeneralDetailElement(parentElement);
112 return mediaSpecimenGeneralDetailElement;
113 }
114 }