Project

General

Profile

Download (7.21 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.view.e4.supplementaldata;
11

    
12
import javax.inject.Inject;
13

    
14
import org.eclipse.e4.core.di.annotations.Optional;
15
import org.eclipse.e4.ui.di.UIEventTopic;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.ui.forms.widgets.ExpandableComposite;
19

    
20
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
21
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
22
import eu.etaxonomy.cdm.model.common.VersionableEntity;
23
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
24
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
25
import eu.etaxonomy.cdm.model.reference.ISourceable;
26
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
27
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
28
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
29
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
30
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
31
import eu.etaxonomy.taxeditor.ui.element.RootElement;
32
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
33
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
34
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
35
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
36
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
37
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
38
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
39
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
40
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
41
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
42
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
43
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
44

    
45
/**
46
 *
47
 * @author pplitzner
48
 * @since Aug 10, 2017
49
 *
50
 */
51
public class SupplementalDataViewerE4 extends AbstractCdmDataViewerE4 {
52

    
53
	private boolean showDebug;
54

    
55
	/** {@inheritDoc} */
56
	@Override
57
	public ISelection getSelection() {
58
		return null;
59
	}
60

    
61
	/** {@inheritDoc} */
62
	@Override
63
	public void setSelection(ISelection selection, boolean reveal) {
64

    
65
	}
66

    
67
	/** {@inheritDoc} */
68
	@Override
69
	protected void showParts() {
70

    
71
		showDebug = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
72

    
73
		Object input;
74

    
75
		if(getInput() instanceof IElementHasDetails){
76
			input = ((IElementHasDetails) getInput()).getData();
77
		}else{
78
			input = getInput();
79
		}
80

    
81
		destroySections();
82
		//1. Headline
83
		createHeadlineSection(rootElement);
84
		//2. Annotatable entitiy
85
		if(input instanceof AnnotatableEntity){
86
				createAnnotationSections(rootElement);
87
		}
88
		//3. Identifiable entity
89
		if(input instanceof IdentifiableEntity){
90
			createIdentifiableSections(rootElement);
91
		}
92
		if(input instanceof ISourceable && !(input instanceof IdentifiableEntity) && !(input instanceof DescriptionElementBase)){
93
            createSourceSection(rootElement);
94
        }
95
		//4. Identifiable media entity
96
		if(input instanceof IdentifiableMediaEntity){
97
			createIdentifiableMediaSections(rootElement);
98
		}
99
		//5. Versionable
100
		if(input instanceof VersionableEntity){
101
				createVersionSection(rootElement);
102
		}
103
		//6. CdmBase
104
		if(showDebug){
105
			createCdmBaseSection(rootElement);
106
		}
107

    
108
		layout();
109
	}
110

    
111
	private void createHeadlineSection(RootElement parent){
112
		HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
113
		addPart(headlineSection);
114
	}
115

    
116
	private void createSourceSection(RootElement parent){
117
	    int expandStyle = getSectionStyle(SourceSection.class, false);
118
        SourceSection sourceSection =  formFactory.createSourceSection(getConversationHolder(), parent, expandStyle);
119
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
120
        addPart(sourceSection);
121
    }
122

    
123
    private void createAnnotationSections(RootElement parent) {
124
        int expandStyle = getSectionStyle(AnnotationSection.class, false);
125
        AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, expandStyle);
126

    
127
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
128
        expandStyle = getSectionStyle(MarkerSection.class, false);
129
        MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, expandStyle);
130

    
131
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
132

    
133
        addPart(annotationSection);
134
        addPart(markerSection);
135
    }
136

    
137
    private void createIdentifiableSections(RootElement parent) {
138
        int expandStyle = getSectionStyle(SourceSection.class, false);
139
        SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, expandStyle);
140

    
141
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
142
        expandStyle =  getSectionStyle(IdentifierSection.class, false);
143
        IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, expandStyle);
144

    
145
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
146
        expandStyle =  getSectionStyle(ExtensionSection.class, false);
147
        ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, expandStyle);
148

    
149
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
150
        expandStyle =  getSectionStyle(CreditSection.class, false);
151
        CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, expandStyle);
152

    
153
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
154
        expandStyle =  getSectionStyle(RightsSection.class, false);
155
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, expandStyle);
156

    
157
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
158

    
159
        addPart(sourceSection);
160
        addPart(identifierSection);
161
        addPart(extensionSection);
162
        addPart(creditSection);
163
        addPart(rightsSection);
164

    
165
	}
166

    
167
    private void createIdentifiableMediaSections(RootElement parent) {
168
        int expandStyle = getSectionStyle(MediaSection.class, false);
169
        MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, expandStyle);
170

    
171
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
172

    
173
        addPart(mediaSection);
174
    }
175

    
176
	private void createVersionSection(RootElement parent){
177
		VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
178
		addPart(versionSection);
179
	}
180

    
181
	private void createCdmBaseSection(RootElement parent) {
182

    
183
		CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
184
		addPart(cdmBaseSection);
185
	}
186

    
187
	@Override
188
	public void update(CdmDataChangeMap arg0) {
189
	}
190

    
191
	@Inject
192
    @Optional
193
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_SUPPLEMENTAL)boolean refresh){
194
        if(refresh){
195
            this.refresh();
196
        }
197
    }
198
}
(2-2/2)