Project

General

Profile

Download (7.14 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.supplementaldata;
11

    
12
import org.eclipse.jface.viewers.ISelection;
13
import org.eclipse.jface.viewers.ISelectionChangedListener;
14
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.SelectionChangedEvent;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.widgets.Composite;
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.media.IdentifiableMediaEntity;
24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
26
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29
import eu.etaxonomy.taxeditor.ui.element.RootElement;
30
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
31
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
32
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
33
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
34
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
35
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
36
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
37
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
38
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
39
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
40
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
41
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
42
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
43
import eu.etaxonomy.taxeditor.view.detail.DetailsViewer;
44

    
45
/**
46
 * <p>SupplementalDataViewer class.</p>
47
 *
48
 * @author n.hoffmann
49
 * @created Feb 12, 2010
50
 * @version 1.0
51
 */
52
public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISelectionChangedListener {
53

    
54
	private boolean showDebug;
55

    
56

    
57
	/**
58
	 * <p>Constructor for SupplementalDataViewer.</p>
59
	 *
60
	 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
61
	 * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
62
	 */
63
	public SupplementalDataViewer(Composite parent, AbstractCdmViewPart viewPart) {
64
		super(parent, viewPart);
65
	}
66

    
67
	/** {@inheritDoc} */
68
	@Override
69
	public ISelection getSelection() {
70
		return null;
71
	}
72

    
73
	/** {@inheritDoc} */
74
	@Override
75
	public void setSelection(ISelection selection, boolean reveal) {
76

    
77
	}
78

    
79
	/** {@inheritDoc} */
80
	@Override
81
	protected void showParts() {
82

    
83
		showDebug = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
84

    
85
		Object input;
86

    
87
		if(getInput() instanceof IElementHasDetails){
88
			input = ((IElementHasDetails) getInput()).getData();
89
		}else{
90
			input = getInput();
91
		}
92

    
93
		destroySections();
94
		//1. Headline
95
		createHeadlineSection(rootElement);
96
		//2. Annotatable entitiy
97
		if(input instanceof AnnotatableEntity){
98
				createAnnotationSections(rootElement);
99
		}
100
		//3. Identifiable entity
101
		if(input instanceof IdentifiableEntity){
102
			createIdentifiableSections(rootElement);
103
		}
104
		//4. Identifiable media entity
105
		if(input instanceof IdentifiableMediaEntity){
106
			createIdentifiableMediaSections(rootElement);
107
		}
108
		//5. Versionable
109
		if(input instanceof VersionableEntity){
110
				createVersionSection(rootElement);
111
		}
112
		//6. CdmBase
113
		if(showDebug){
114
			createCdmBaseSection(rootElement);
115
		}
116

    
117
		layout();
118
	}
119

    
120

    
121

    
122
	private void createHeadlineSection(RootElement parent){
123
		HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
124
		addPart(headlineSection);
125
	}
126

    
127
    private void createAnnotationSections(RootElement parent) {
128
        AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
129

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

    
132
        MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
133

    
134
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
135

    
136
        addPart(annotationSection);
137
        addPart(markerSection);
138
    }
139

    
140
    private void createIdentifiableSections(RootElement parent) {
141

    
142
        ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
143

    
144
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
145

    
146
        SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
147

    
148
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
149

    
150
        IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
151

    
152
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
153

    
154
        CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
155

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

    
158
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
159

    
160
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
161

    
162
        addPart(sourceSection);
163
        addPart(identifierSection);
164
        addPart(extensionSection);
165
        addPart(creditSection);
166
        addPart(rightsSection);
167

    
168
	}
169

    
170
    private void createIdentifiableMediaSections(RootElement parent) {
171
        MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
172

    
173
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
174

    
175
        addPart(mediaSection);
176
    }
177

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

    
183
	/**
184
	 * @param rootElement
185
	 */
186
	private void createCdmBaseSection(RootElement parent) {
187

    
188
		CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
189
		addPart(cdmBaseSection);
190
	}
191

    
192
	/*
193
	 * (non-Javadoc)
194
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
195
	 */
196
	/** {@inheritDoc} */
197
	@Override
198
    public void selectionChanged(SelectionChangedEvent event) {
199
		if(event.getSource() instanceof DetailsViewer){
200
			if(event.getSelection() == CdmFormFactory.EMPTY_SELECTION){
201
				setInput(null);
202
				return;
203
			}
204

    
205
			IStructuredSelection selection = (IStructuredSelection) event.getSelection();
206
			setInput(selection.getFirstElement());
207
		}
208
	}
209

    
210
	@Override
211
	public void update(CdmDataChangeMap arg0) {
212
	}
213
}
(2-2/2)