Project

General

Profile

Download (7.44 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 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

    
11
package eu.etaxonomy.taxeditor.view.supplementaldata;
12

    
13
import org.eclipse.jface.viewers.ISelection;
14
import org.eclipse.jface.viewers.ISelectionChangedListener;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.SelectionChangedEvent;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.ui.forms.widgets.ExpandableComposite;
20

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

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

    
55
	private boolean showDebug;
56

    
57

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

    
68

    
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.jface.viewers.Viewer#getSelection()
71
	 */
72
	/** {@inheritDoc} */
73
	@Override
74
	public ISelection getSelection() {
75
		return null;
76
	}
77

    
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
80
	 */
81
	/** {@inheritDoc} */
82
	@Override
83
	public void setSelection(ISelection selection, boolean reveal) {
84

    
85
	}
86

    
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
89
	 */
90
	/** {@inheritDoc} */
91
	@Override
92
	protected void showParts() {
93

    
94
		showDebug = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
95

    
96
		Object input;
97

    
98
		if(getInput() instanceof IElementHasDetails){
99
			input = ((IElementHasDetails) getInput()).getData();
100
		}else{
101
			input = getInput();
102
		}
103

    
104
		destroySections();
105
		//1. Headline
106
		createHeadlineSection(rootElement);
107
		//2. Annotatable entitiy
108
		if(input instanceof AnnotatableEntity){
109
				createAnnotationSections(rootElement);
110
		}
111
		//3. Identifiable entity
112
		if(input instanceof IdentifiableEntity){
113
			createIdentifiableSections(rootElement);
114
		}
115
		//4. Identifiable media entity
116
		if(input instanceof IdentifiableMediaEntity){
117
			createIdentifiableMediaSections(rootElement);
118
		}
119
		//5. Versionable
120
		if(input instanceof VersionableEntity){
121
				createVersionSection(rootElement);
122
		}
123
		//6. CdmBase
124
		if(showDebug){
125
			createCdmBaseSection(rootElement);
126
		}
127

    
128
		layout();
129
	}
130

    
131

    
132

    
133
	private void createHeadlineSection(RootElement parent){
134
		HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
135
		addPart(headlineSection);
136
	}
137

    
138
    private void createAnnotationSections(RootElement parent) {
139
        AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
140

    
141
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
142

    
143
        MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
144

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

    
147
        addPart(annotationSection);
148
        addPart(markerSection);
149
    }
150

    
151
    private void createIdentifiableSections(RootElement parent) {
152
        CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
153

    
154
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
155

    
156
        ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
157

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

    
160
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
161

    
162
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
163

    
164
        SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
165

    
166
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
167

    
168
        IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
169
        
170
        addPart(creditSection);
171
        addPart(extensionSection);
172
        addPart(rightsSection);
173
        addPart(sourceSection);
174
        addPart(identifierSection);
175

    
176
	}
177

    
178
    private void createIdentifiableMediaSections(RootElement parent) {
179
        MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
180

    
181
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
182

    
183
        addPart(mediaSection);
184
    }
185

    
186
	private void createVersionSection(RootElement parent){
187
		VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
188
		addPart(versionSection);
189
	}
190

    
191
	/**
192
	 * @param rootElement
193
	 */
194
	private void createCdmBaseSection(RootElement parent) {
195

    
196
		CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
197
		addPart(cdmBaseSection);
198
	}
199

    
200
	/*
201
	 * (non-Javadoc)
202
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
203
	 */
204
	/** {@inheritDoc} */
205
	@Override
206
    public void selectionChanged(SelectionChangedEvent event) {
207
		if(event.getSource() instanceof DetailsViewer){
208
			if(event.getSelection() == CdmFormFactory.EMPTY_SELECTION){
209
				setInput(null);
210
				return;
211
			}
212

    
213
			IStructuredSelection selection = (IStructuredSelection) event.getSelection();
214
			setInput(selection.getFirstElement());
215
		}
216
	}
217
	
218
	@Override
219
	public void update(CdmDataChangeMap arg0) {
220
	}
221
}
(2-2/2)