Project

General

Profile

Download (4.19 KB) Statistics
| Branch: | Tag: | Revision:
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
        final String label;
91

    
92
        if(mediaSpecimenGeneralDetailElement.isAdvancedMediaView()){
93
            label = "Use simple media view";
94
        }
95
        else{
96
            label = "Use advanced media view";
97
        }
98
        Action addAction = new Action("Use advanced media view", IAction.AS_PUSH_BUTTON) {
99
            /* (non-Javadoc)
100
             * @see org.eclipse.jface.action.Action#run()
101
             */
102
            @Override
103
            public void run() {
104
                mediaSpecimenGeneralDetailElement.toogleAdvancedMediaView();
105
            }
106
        };
107
        addAction.setToolTipText(label);
108

    
109
        toolBarManager.add(addAction);
110

    
111
        return toolBarManager.createControl(this);
112
    }
113

    
114
    /* (non-Javadoc)
115
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
116
     */
117
    @Override
118
    protected AbstractCdmDetailElement<MediaSpecimen> createCdmDetailElement(AbstractCdmDetailSection<MediaSpecimen> parentElement, int style) {
119
        mediaSpecimenGeneralDetailElement = formFactory.createMediaSpecimenGeneralDetailElement(parentElement);
120
        return mediaSpecimenGeneralDetailElement;
121
    }
122
}
(4-4/6)