Project

General

Profile

Revision 8c9c3c81

ID8c9c3c81127bf18caac0765fe2bffaea439507ab
Parent d8f12b25
Child 595bbde7

Added by Patrick Plitzner over 1 year ago

ref #6913 Remove details and supplemental view

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
57 57
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
58 58
import eu.etaxonomy.taxeditor.model.ImageResources;
59 59
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
60
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
61
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
62 60
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
63 61

  
64 62
/**
......
175 173
		    return;
176 174
		}
177 175

  
178
        if (partObject instanceof DetailsViewPart || partObject instanceof SupplementalDataViewPart
179
                || partObject instanceof MediaViewPartE4) {
176
        if (partObject instanceof MediaViewPartE4) {
180 177
            // do not show empty page as these views are also used to edit the
181 178
            // description selected in this view
182 179
            return;
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
69 69
 eu.etaxonomy.taxeditor.view.e4.details,
70 70
 eu.etaxonomy.taxeditor.view.e4.supplementaldata,
71 71
 eu.etaxonomy.taxeditor.view.specimenSearch,
72
 eu.etaxonomy.taxeditor.view.supplementaldata,
73 72
 org.eclipse.wb.swt
74 73
Require-Bundle: org.eclipse.osgi,
75 74
 org.eclipse.ui,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
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.detail;
11

  
12
import java.util.Collection;
13
import java.util.Set;
14

  
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
17
import org.eclipse.e4.ui.workbench.modeling.EPartService;
18
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.jface.viewers.TreeNode;
21
import org.eclipse.jface.viewers.Viewer;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.ui.IEditorPart;
24
import org.eclipse.ui.IMemento;
25
import org.eclipse.ui.IWorkbenchPart;
26
import org.eclipse.ui.internal.e4.compatibility.CompatibilityPart;
27

  
28
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
29
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
30
import eu.etaxonomy.cdm.model.common.CdmBase;
31
import eu.etaxonomy.cdm.model.description.Feature;
32
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
33
import eu.etaxonomy.cdm.model.taxon.Taxon;
34
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
35
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
36
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
37
import eu.etaxonomy.taxeditor.l10n.Messages;
38
import eu.etaxonomy.taxeditor.model.AbstractUtility;
39
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
40
import eu.etaxonomy.taxeditor.model.IContextListener;
41
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
42
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
43
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
44
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
45
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
46

  
47
/**
48
 * <p>DetailsViewPart class.</p>
49
 *
50
 * @author n.hoffmann
51
 * @created Jun 10, 2010
52
 * @version 1.0
53
 */
54
public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData, IContextListener{
55

  
56
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
57
	public static String ID = "eu.etaxonomy.taxeditor.view.detail"; //$NON-NLS-1$
58

  
59
	private DetailsViewer viewer;
60

  
61
	private CdmBase lastObject;
62
	private Object lastPart;
63

  
64
	/** {@inheritDoc} */
65
	@Override
66
	public void createViewer(Composite parent) {
67

  
68
		viewer = new DetailsViewer(parent, this);
69
		getSite().setSelectionProvider(viewer);
70
	}
71

  
72
	@Override
73
    protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection){
74
	    Object partObject = workbenchPart;
75
	    Object wrappedPart = WorkbenchUtility.getE4WrappedPart(partObject);
76
	    if(wrappedPart!=null){
77
	        partObject = wrappedPart;
78
	    }
79
	    if(AbstractUtility.getActiveEditor() == null && !(AbstractUtility.getActivePart() instanceof IConversationEnabled)){
80
            showEmptyPage();
81
            return;
82
        }
83

  
84
	    //special case where the details view still open with details about the closed object #5495
85
	    try{
86
	        boolean isSelectionProvidingPartStillActive = false;
87
	        if(selectionProvidingPart!=null){
88
	            EPartService partService = TaxeditorStorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
89
	            Collection<MPart> parts = partService.getParts();
90
	            for (MPart mPart : parts) {
91
	                Object object = mPart.getObject();
92
	                if(object instanceof CompatibilityPart){
93
	                    object = ((CompatibilityPart) object).getPart();
94
	                }
95
	                if(selectionProvidingPart.equals(object)){
96
	                    isSelectionProvidingPartStillActive = true;
97
	                    break;
98
	                }
99
	            }
100
	            if(!isSelectionProvidingPartStillActive &&
101
	                    selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() !=null){
102
	                showEmptyPage();
103
	                return;
104
	            }
105
	        }
106
	    }catch(IllegalStateException e){
107
	        //nothing
108
	    }
109

  
110
	    if(partObject == this){
111
	        return;
112
	    }
113

  
114
        if(!(selection instanceof IStructuredSelection)){
115
            return;
116
        }
117

  
118
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
119

  
120
        if((partObject instanceof IEditorPart) || (partObject instanceof IPartContentHasDetails)) {
121
            if(structuredSelection.size() != 1){
122
                showEmptyPage();
123
                return;
124
            }
125

  
126
            // do not show details for feature nodes TODO really?
127
            if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
128
                // do show the map for distributions
129
                Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
130
                if(!feature.equals(Feature.DISTRIBUTION())){
131
                    showEmptyPage();
132
                    return;
133
                }
134
            }
135
            showViewer(partObject, structuredSelection);
136
        }else{
137
            showEmptyPage();
138
        }
139
	}
140

  
141
	@Override
142
	protected String getViewName(){
143
	    return Messages.DetailsViewPart_VIEWER_NAME;
144
	}
145

  
146
	@Override
147
	protected String createPartTitle(Object selectedObject){
148
	    if(selectedObject!=null){
149
	        if(selectedObject instanceof TreeNode){
150
	            selectedObject = ((TreeNode) selectedObject).getValue();
151
	        }
152
	        if(selectedObject instanceof SpecimenOrObservationBase){
153
	            return getViewName()+": "+HibernateProxyHelper.deproxy(selectedObject, SpecimenOrObservationBase.class).getRecordBasis(); //$NON-NLS-1$
154
	        }
155
	        if(selectedObject instanceof CdmBase){
156
	            return getViewName()+": "+HibernateProxyHelper.deproxy(selectedObject, CdmBase.class).getClass().getSimpleName(); //$NON-NLS-1$
157
	        }
158
	        return getViewName()+": "+selectedObject.getClass().getSimpleName(); //$NON-NLS-1$
159
	    }
160
	    return getViewName();
161
	}
162

  
163
	@Override
164
	public void showEmptyPage() {
165
	    viewer.setSelection(null);
166

  
167
	    super.showEmptyPage();
168
	}
169

  
170
	/** {@inheritDoc} */
171
	@Override
172
	public boolean postOperation(CdmBase objectAffectedByOperation) {
173

  
174
		viewer.setInput(objectAffectedByOperation);
175

  
176
		return super.postOperation(objectAffectedByOperation);
177
	}
178

  
179

  
180
	/** {@inheritDoc} */
181
	@Override
182
	public Viewer getViewer() {
183
		return viewer;
184
	}
185

  
186

  
187
	/** {@inheritDoc} */
188
	@Override
189
	public void dispose() {
190
		selectionService.removePostSelectionListener(this);
191
		super.dispose();
192

  
193
	}
194

  
195
	@Override
196
    public boolean onComplete() {
197
		return true;
198
	}
199

  
200
    /**
201
     * {@inheritDoc}
202
     */
203
    @Override
204
    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
205
    }
206

  
207
    /**
208
     * {@inheritDoc}
209
     */
210
    @Override
211
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
212
        showEmptyPage();
213
    }
214

  
215
    /**
216
     * {@inheritDoc}
217
     */
218
    @Override
219
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
220
    }
221

  
222
    /**
223
     * {@inheritDoc}
224
     */
225
    @Override
226
    public void contextRefresh(IProgressMonitor monitor) {
227
    }
228

  
229
    /**
230
     * {@inheritDoc}
231
     */
232
    @Override
233
    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
234
    }
235
    @Override
236
    public void showViewer(Object part, IStructuredSelection selection){
237

  
238

  
239

  
240
    	this.part = part;
241

  
242
        Object element = selection.getFirstElement();
243

  
244
//        if (part == lastPart && element == lastObject ){
245
//        	getViewer().setInput(element);
246
//        	return;
247
//        }else{
248
//        	lastPart = part;
249
//        	if (element instanceof CdmBase){
250
//        		lastObject = (CdmBase)element;
251
//        	}else{
252
//        		lastObject = null;
253
//        	}
254
//        }
255
      //avoid widget is disposed exceptions
256
        if (getViewer().getControl()==null || getViewer().getControl().isDisposed() ){
257
            return;
258
        }
259

  
260
        setPartName(createPartTitle(element));
261
        if (element instanceof Taxon){
262
        	Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class);
263
        	if (taxon.isMisapplication()){
264

  
265
        		if (part instanceof ITaxonEditor){
266
        			Taxon accepted= ((ITaxonEditor)part).getTaxon();
267
        			Set<TaxonRelationship> rels =  taxon.getTaxonRelations(accepted);
268

  
269
        			 if (rels.iterator().hasNext()){
270
        				 TaxonRelationship rel = rels.iterator().next();
271
        				 if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
272
	        				 getViewer().setInput(rel);
273
	        				 showViewer();
274
	        				 return;
275
        				 }
276
        			 }
277
        		}
278

  
279

  
280
        	}
281
        }
282
        if (element instanceof Object[] && ((Object[])element).length == 0){
283
        	return;
284
        }
285
        getViewer().setInput(element);
286
        super.showViewer(part, selection);
287
    }
288
}
289

  
290

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
1
/**
2
 * Copyright (C) 2011 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.detail;
11

  
12
import java.util.Set;
13

  
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.SelectionChangedEvent;
16
import org.eclipse.jface.viewers.TreeNode;
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.api.facade.DerivedUnitFacade;
22
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
23
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
24
import eu.etaxonomy.cdm.model.agent.Person;
25
import eu.etaxonomy.cdm.model.agent.Team;
26
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
27
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
28
import eu.etaxonomy.cdm.model.common.Group;
29
import eu.etaxonomy.cdm.model.common.Marker;
30
import eu.etaxonomy.cdm.model.common.TermVocabulary;
31
import eu.etaxonomy.cdm.model.common.User;
32
import eu.etaxonomy.cdm.model.description.CategoricalData;
33
import eu.etaxonomy.cdm.model.description.DescriptionBase;
34
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
35
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
36
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
37
import eu.etaxonomy.cdm.model.media.Media;
38
import eu.etaxonomy.cdm.model.molecular.DnaSample;
39
import eu.etaxonomy.cdm.model.molecular.Sequence;
40
import eu.etaxonomy.cdm.model.molecular.SingleRead;
41
import eu.etaxonomy.cdm.model.name.TaxonName;
42
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
43
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
44
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
45
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
46
import eu.etaxonomy.cdm.model.reference.Reference;
47
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
48
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
49
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
50
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
51
import eu.etaxonomy.taxeditor.model.AbstractUtility;
52
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
53
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
54
import eu.etaxonomy.taxeditor.model.MessagingUtils;
55
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
56
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
57
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
58
import eu.etaxonomy.taxeditor.store.UsageTermCollection;
59
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
60
import eu.etaxonomy.taxeditor.ui.element.RootElement;
61
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
62
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
63
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
64
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
65
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
66
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
67
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
68
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
69
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
70
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
71
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
72
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
73
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
74
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
75
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
76
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
77
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
78
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
79
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
80
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
81
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
82
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
83
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
84
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
85
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
86
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
87
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
88
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
89
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
90
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
91
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
92
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
93
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
94
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
95
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
96
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
97
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
98
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
99
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
100
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
101
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
102
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
103
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
104
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
105
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
106
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
107
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
108
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
109
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
110
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
111
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
112
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
113
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
114
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
115
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
116
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
117

  
118
/**
119
 *
120
 * The DetailsViewer handles the content of the details view (
121
 * {@link DetailsViewPart}).<br>
122
 * Depending on the type of the selected element the section of the details view
123
 * are created.
124
 *
125
 * @author n.hoffmann
126
 * @created Feb 12, 2010
127
 * @version 1.0
128
 */
129
public class DetailsViewer extends AbstractCdmDataViewer {
130

  
131
    private ISelection selection;
132

  
133
    public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
134
        super(parent, viewPart);
135
    }
136

  
137
    // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
138
    // since we are getting implementations of DerivedUnitBase from the bulk
139
    // editor
140
    // and not derived unit facade objects,
141

  
142
    @Override
143
    public void setInput(Object input) {
144

  
145
        if(input instanceof TreeNode){
146
            input = ((TreeNode) input).getValue();
147
        }
148
        if(input instanceof GbifResponse){
149
            input = ((GbifResponse) input).getDerivedUnitFacade();
150
        }
151
        if (input.getClass().equals(DerivedUnit.class)) {
152
            DerivedUnit derivedUnit = (DerivedUnit)input;
153
            try {
154
                input = DerivedUnitFacade.NewInstance(derivedUnit,
155
                        PreferencesUtil.getDerivedUnitConfigurator());
156
            } catch (DerivedUnitFacadeNotSupportedException e) {
157
//                MessagingUtils.error(getClass(), e); //nothing should happen, later on the Details View will show an according information that it is not possible to open this data
158
            }
159
        }
160
        else if(input instanceof FieldUnit){
161
            input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input);
162
        }
163
        super.setInput(input);
164
    }
165

  
166
    @Override
167
    protected void markViewPartDirty() {
168
        if (getInput() instanceof DerivedUnitFacade) {
169
            DerivedUnitFacade facade = (DerivedUnitFacade) getInput();
170
            if(facade.innerDerivedUnit()!=null){
171
                getViewPart().changed(facade.innerDerivedUnit());
172
            }
173
            else if(facade.innerFieldUnit()!=null){
174
                getViewPart().changed(facade.innerFieldUnit());
175
            }
176
        }
177
        else{
178
            super.markViewPartDirty();
179
        }
180
    }
181

  
182
    // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
183

  
184

  
185
    /** {@inheritDoc} */
186
    @Override
187
    protected void showParts() {
188
        // FIXME (CM) : Need to clean out this code.
189
        // Too much type checking to decide which detail view to display.
190
        // Need to build in a mechanism where navigators / editors are 'aware'
191
        // of the corresponding detail viewer.
192

  
193
        Object input = getInput();
194

  
195
        destroySections();
196
        if (input instanceof TaxonBase) {
197
            if(((TaxonBase) input).getName()==null){
198
                createEmptySection(rootElement);
199
            }
200
            else{
201
                createTaxonSections(rootElement);
202
            }
203

  
204
        } else if (input instanceof TaxonName) {
205
            createNameSections(rootElement);
206

  
207
        } else if (input instanceof Reference) {
208
            createReferenceSections(rootElement);
209

  
210
        } else if (input instanceof Team) {
211
            createTeamDetailSection(rootElement);
212

  
213
        } else if (input instanceof Person) {
214
            createPersonDetailSection(rootElement);
215

  
216
        } else if (input instanceof TeamOrPersonBase) {
217
            createTeamOrPersonBaseDetailSection(rootElement);
218

  
219
        } else if (input instanceof DescriptionBase) {
220
            if(input instanceof SpecimenDescription){
221
                //TODO: add more sections to DetailsView for SpecimenDescription
222
                createSpecimenDescriptionSection(rootElement);
223
            }
224
            else{
225
                Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
226

  
227
                Boolean isUseDescription = false;
228
                for (Marker marker : descriptionMarkers) {
229
                    if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
230
                        isUseDescription = true;
231
                    }
232
                }
233
                if (((DescriptionBase<?>) input).isImageGallery()) {
234
                    createImageGallerySection(rootElement);
235

  
236
                } else if (isUseDescription) {
237
                    createUseDescriptionSection(rootElement);
238
                } else {
239
                    createDescriptionSection(rootElement);
240

  
241
                }
242
            }
243
        } else if (input instanceof DescriptionElementBase) {
244
            Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
245

  
246
            Boolean isUseDescription = false;
247
            for (Marker marker : descriptionMarkers) {
248
                if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
249
                    isUseDescription = true;
250
                }
251
            }
252

  
253
            if (isUseDescription == true && input instanceof CategoricalData) {
254
                createUseRecordSection(rootElement);
255
            } else {
256
                createDescriptionElementSection(rootElement);
257
            }
258

  
259
        } else if (input instanceof Media) {
260
            createMediaElementSection(rootElement);
261

  
262
        } else if (input instanceof DerivedUnitFacade) {
263
            if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.FieldUnit){
264
                if(((DerivedUnitFacade) input).innerFieldUnit()==null){
265
                    MessagingUtils.error(DetailsViewer.class, "FieldUnit of facade is null", null);
266
                }
267
                else{
268
                    createFieldUnitSection(rootElement);
269
                }
270
            }
271
            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.PreservedSpecimen){
272
                if(((DerivedUnitFacade) input).innerDerivedUnit()==null){
273
                    MessagingUtils.error(DetailsViewer.class, "DerivedUnit of facade is null", null);
274
                }
275
                else{
276
                    createDerivedUnitBaseElementSection(rootElement);
277
                }
278
            }
279
            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.TissueSample){
280
                //TissueSample should only be created by using it's own class
281
                //in future using only one class with different SpecimenOrObservationTypes is desired
282
                createTissueSampleSection(rootElement);
283
            }
284
            else{
285
                createDerivedUnitBaseElementSection(rootElement);
286
            }
287
        } else if (input instanceof DnaSample){
288
            DnaSample dnaSample = (DnaSample)input;
289
            if(dnaSample.getRecordBasis()==SpecimenOrObservationType.TissueSample){
290
                createTissueSampleSection(rootElement);
291
            }
292
            else if(dnaSample.getRecordBasis()==SpecimenOrObservationType.DnaSample){
293
                createDnaSampleSection(rootElement);
294
            }
295
        } else if (input instanceof MediaSpecimen){
296
            createMediaSpecimenSection(rootElement);
297
        }
298
        else if(input instanceof Sequence){
299
            createSequenceSection(rootElement);
300
        }
301
        else if(input instanceof SingleRead){
302
            createSingleReadSection(rootElement);
303
        }
304
        else if (input instanceof FeatureNodeContainer) {
305
            createFeatureDistributionSection(rootElement);
306

  
307
        }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
308
            createPolytomousKeyNodeSection(rootElement);
309
        } else if (input instanceof User) {
310
            createUserSection(rootElement);
311
        } else if (input instanceof Group) {
312
            createGroupSection(rootElement);
313
        } else if (input instanceof TaxonRelationship && ((TaxonRelationship)input).getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {
314
            createMisappliedNameSection(rootElement);
315
        }else if (input instanceof TaxonRelationship ) {
316
            createTaxonRelationshipSection(rootElement);
317
        } else if (input instanceof TermVocabulary) {
318
            createTermVocabularySection(rootElement);
319
        } else if (input instanceof DefinedTermBase) {
320
            createDefinedTermSection(rootElement);
321
        }
322
        else {
323
            createEmptySection(rootElement);
324
        }
325
        layout();
326

  
327
    }
328

  
329

  
330
    private void createEmptySection(RootElement parent) {
331
        destroySections();
332

  
333
        EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE);
334

  
335
        addPart(emptySection);
336
    }
337

  
338
    private void createGroupSection(RootElement parent) {
339
        destroySections();
340

  
341
        GroupDetailSection groupDetailSection = formFactory.createGroupDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED);
342
        MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
343
        GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
344

  
345
        addPart(groupDetailSection);
346
        addPart(memberDetailSection);
347
        addPart(grantedAuthorityDetailSection);
348
    }
349

  
350
    /** {@inheritDoc} */
351
    @Override
352
    public ISelection getSelection() {
353
        return selection;
354
    }
355

  
356
    /** {@inheritDoc} */
357
    @Override
358
    public void setSelection(ISelection selection, boolean reveal) {
359

  
360
    		this.selection = selection;
361

  
362
	        if(this.selection!=null){
363
	            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
364
	            fireSelectionChanged(selectionChangedEvent);
365
	        }
366

  
367
    }
368

  
369
    private void createTaxonSections(RootElement parent) {
370
        destroySections();
371

  
372
        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
373
                ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
374
        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
375
        	TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
376
	        ExpandableComposite.TWISTIE	| ExpandableComposite.EXPANDED);
377
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
378
	        addPart(taxonBaseDetailSection);
379
        }else{
380
        	if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON)){
381
	            TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
382
	            		ExpandableComposite.TWISTIE	| ExpandableComposite.EXPANDED);
383
	            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
384

  
385
	            addPart(taxonBaseDetailSection);
386
        	}
387
        }
388
        NonViralNameDetailSection nonViralNameSection = formFactory
389
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
390
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
391
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
392
        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE))){
393
	            NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
394
	            		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
395
	            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
396
	            addPart(referenceDetailSection);
397

  
398
        }
399
        if ( !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS))){
400
	            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
401
	            		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
402
	            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
403
	            addPart(nomenclaturalStatusSection);
404
        }
405

  
406
    	if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE))){
407
    		ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
408
    		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
409
    		addPart(protologSection);
410
    	}
411

  
412
    	if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) &&  PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION))){
413
    		TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
414
    		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
415
    		addPart(typeDesignationSection);
416
    	}
417

  
418
    	if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP))){
419
    		NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
420
    		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
421
    		addPart(nameRelationshipSection);
422
    	}
423

  
424

  
425
        addPart(parsingMessagesSection);
426

  
427
        addPart(nonViralNameSection);
428

  
429
    }
430

  
431
    private void createNameSections(RootElement parent) {
432
        destroySections();
433
        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(
434
                getConversationHolder(), parent, this, false, ExpandableComposite.TWISTIE
435
                        | ExpandableComposite.EXPANDED);
436
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
437

  
438
        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
439
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
440
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
441

  
442
        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
443
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
444
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
445

  
446
        addPart(nonViralNameSection);
447
        addPart(nomenclaturalStatusSection);
448
        addPart(referenceDetailSection);
449

  
450
		ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
451
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
452

  
453
        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
454
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
455

  
456
        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
457
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
458
        addPart(protologSection);
459
        addPart(typeDesignationSection);
460
        addPart(nameRelationshipSection);
461

  
462
    }
463

  
464
    private void createReferenceSections(RootElement parent) {
465
        destroySections();
466

  
467
        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
468
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
469

  
470
        addPart(referenceDetailSection);
471
    }
472

  
473
    private void createTeamOrPersonBaseDetailSection(RootElement parent) {
474
        destroySections();
475
        TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
476

  
477
        addPart(teamOrPersonBaseDetailSection);
478
    }
479

  
480
    private void createTeamDetailSection(RootElement parent) {
481
        destroySections();
482
        TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
483

  
484
        addPart(teamDetailSection);
485
    }
486

  
487
    private void createPersonDetailSection(RootElement parent) {
488
        destroySections();
489
        PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
490
        addPart(personDetailSection);
491
    }
492

  
493
    private void createDescriptionElementSection(RootElement parent) {
494
        destroySections();
495

  
496
        DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
497

  
498
      //  IntextReferenceSection intextReferenceSection = formFactory.createIntextReferenceSection(getConversationHolder(), parent,  ExpandableComposite.TWISTIE);
499

  
500
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
501

  
502
        DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
503

  
504
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
505

  
506
        DescriptionElementMediaSection descriptionElementMediaSection = formFactory.createDescriptionElementMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
507

  
508
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
509

  
510
        addPart(descriptionElementDetailSection);
511
        addPart(descriptionElementSourceSection);
512
        addPart(descriptionElementMediaSection);
513
    }
514

  
515
    private void createDescriptionSection(RootElement parent) {
516
        destroySections();
517
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
518

  
519
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
520

  
521
        NaturalLanguageSection naturalLanguageSection = formFactory.createNaturalLanguageSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
522

  
523
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
524

  
525
//        DescribedSpecimenSection describedSpecimenSection = formFactory.createDescribedSpecimenSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
526
//
527
//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
528

  
529
        //		DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
530
        //				.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
531
        //						getConversationHolder(), parent, Section.TWISTIE);
532
        //
533
        //		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
534

  
535
        ScopeSection scopeSection = formFactory.createScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
536

  
537
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
538

  
539
        addPart(descriptionDetailSection);
540
        addPart(naturalLanguageSection);
541
//        addPart(describedSpecimenSection);
542
        //		addPart(descriptionSourceSection);
543
        addPart(scopeSection);
544
    }
545

  
546
    private void createSpecimenDescriptionSection(RootElement parent) {
547
        destroySections();
548
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
549
        addPart(descriptionDetailSection);
550
    }
551

  
552
    private void createUseDescriptionSection(RootElement parent) {
553
        destroySections();
554
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
555

  
556
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
557

  
558
        DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
559

  
560
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
561

  
562
        addPart(descriptionDetailSection);
563
        addPart(descriptionSourceSection);
564

  
565
    }
566

  
567
    private void createImageGallerySection(RootElement parent) {
568
        destroySections();
569
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
570

  
571
        addPart(descriptionDetailSection);
572
    }
573

  
574
    private void createMediaElementSection(RootElement parent) {
575
        destroySections();
576

  
577
        MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
578

  
579
        addPart(mediaDetailSection);
580
    }
581

  
582
    private void createDerivedUnitBaseElementSection(RootElement parent) {
583
        destroySections();
584

  
585
        DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
586
        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
587
//        if(!(AbstractUtility.getActiveE4Part() instanceof IDerivedUnitFacadePart)){
588
//            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
589
//        }
590
        addPart(derivedUnitGeneralDetailSection);
591

  
592
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
593

  
594
        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
595
        addPart(derivedUnitBaseDetailSection);
596

  
597
        //for editors working with facades
598
        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
599
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
600
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
601
            addPart(gatheringEventDetailSection);
602

  
603
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
604
            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
605
            addPart(fieldUnitDetailSection);
606
        }
607
        else{
608

  
609
            if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){
610
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
611
                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
612
                addPart(taxonAssociationDetailSection);
613
            }
614
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
615
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
616
            addPart(identifierDetailSection);
617
        }
618
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
619
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
620
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
621
            addPart(determinationDetailSection);
622
        }
623

  
624
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
625
        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
626
        addPart(derivedUnitTypeDesignationSection);
627

  
628
    }
629

  
630
    private void createFieldUnitSection(RootElement parent) {
631
        destroySections();
632

  
633
        FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
634

  
635
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
636

  
637
        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
638

  
639
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
640

  
641
        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
642

  
643
        addPart(fielUnitGeneralDetailSection);
644
        addPart(gatheringEventDetailSection);
645
        addPart(fieldUnitDetailSection);
646

  
647
        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
648
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
649
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
650
            addPart(determinationDetailSection);
651
        }
652
    }
653

  
654
    private void createTissueSampleSection(RootElement parent) {
655
        destroySections();
656

  
657
        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
658

  
659
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
660

  
661
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
662

  
663
        addPart(section);
664
        addPart(sampleDesignationDetailSection);
665
    }
666

  
667
    private void createDnaSampleSection(RootElement parent) {
668
        destroySections();
669

  
670
        DnaSampleGeneralDetailSection section = formFactory.createDnaSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
671

  
672
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
673

  
674
        DnaSamplePreparationPreservationSection preparationPreservationSection = formFactory.createDnaSamplePreparationPreservationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
675

  
676
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
677

  
678
        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
679

  
680
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
681

  
682
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
683

  
684
        addPart(section);
685
        addPart(preparationPreservationSection);
686
        addPart(qualitySection);
687
        addPart(sampleDesignationDetailSection);
688
    }
689

  
690
    private void createSequenceSection(RootElement parent) {
691
        destroySections();
692

  
693
        SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
694

  
695
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
696

  
697
        SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
698

  
699
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
700

  
701
        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
702

  
703

  
704
        addPart(section);
705
        addPart(referenceSection);
706
        addPart(contigFileSection);
707
    }
708

  
709
    private void createSingleReadSection(RootElement parent) {
710
        destroySections();
711

  
712
        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
713
        addPart(section);
714

  
715
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
716

  
717
        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
718
        addPart(pherogramSection);
719

  
720
    }
721

  
722
    private void createMediaSpecimenSection(RootElement parent) {
723
        destroySections();
724

  
725
        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
726
        addPart(generalSection);
727

  
728
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
729

  
730
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
731
        addPart(rightsSection);
732

  
733
    }
734

  
735
    private void createFeatureDistributionSection(RootElement parent) {
736
        destroySections();
737

  
738
        FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
739

  
740
        addPart(featureDistributionSection);
741
    }
742

  
743
    private void createPolytomousKeyNodeSection(RootElement parent) {
744
        destroySections();
745

  
746
        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
747

  
748
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
749

  
750
        PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
751

  
752
        addPart(polytomousKeyDetailSection);
753
        addPart(polytomousKeyNodeDetailSection);
754

  
755
    }
756

  
757
    private void createUseRecordSection(RootElement parent) {
758
        destroySections();
759

  
760
        UseRecordDetailSection descriptionUseRecordSection = formFactory.createUseRecordDetailSection(getConversationHolder(), parent, this,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
761

  
762
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
763

  
764
        addPart(descriptionUseRecordSection);
765

  
766

  
767
    }
768

  
769
    private void createUserSection(RootElement parent) {
770
        destroySections();
771

  
772
        UserDetailSection userDetailSection = formFactory.createUserDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
773

  
774
        GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
775

  
776
        addPart(userDetailSection);
777
        addPart(groupByUserDetailSection);
778
    }
779

  
780
    private void createMisappliedNameSection(RootElement parent) {
781
        destroySections();
782

  
783
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
784

  
785
       // ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
786
        addPart(taxonRelationshipDetailSection);
787
        //addPart(referencedEntityBaseDetailSection);
788

  
789
        NonViralNameDetailSection nonViralNameSection = formFactory
790
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
791
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
792
        addPart(nonViralNameSection);
793
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
794
        //if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE))){
795
        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
796
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
797
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
798
        addPart(referenceDetailSection);
799

  
800
        //if ( !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS))){
801
            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
802
            		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
803
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
804
            addPart(nomenclaturalStatusSection);
805
    //}
806

  
807
	//if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE))){
808
		ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
809
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
810
		addPart(protologSection);
811
	//}
812

  
813
	//if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) &&  PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION))){
814
		TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
815
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
816
		addPart(typeDesignationSection);
817
	//}
818

  
819
	//if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) || (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION) && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP))){
820
		NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
821
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
822
		addPart(nameRelationshipSection);
823
	//}
824

  
825

  
826
        //}
827
    }
828

  
829
    private void createTaxonRelationshipSection(RootElement parent) {
830
    	destroySections();
831

  
832
    	TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
833

  
834
        ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
835
        addPart(taxonRelationshipDetailSection);
836
        addPart(referencedEntityBaseDetailSection);
837
    }
838
    private void createTermVocabularySection(RootElement parent) {
839
        destroySections();
840

  
841
        TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
842
        addPart(termVocabularyDetailSection);
843
    }
844

  
845
    private void createDefinedTermSection(RootElement parent) {
846
        destroySections();
847

  
848
        AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
849
        addPart(definedTermDetailSection);
850
    }
851

  
852
	@Override
853
	public void update(CdmDataChangeMap arg0) {
854

  
855
	}
856

  
857
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
125 125
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
126 126
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
127 127
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
128
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
129 128
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
130 129

  
131 130
/**
132 131
 *
133 132
 * The DetailsViewer handles the content of the details view (
134
 * {@link DetailsViewPart}).<br>
133
 * {@link DetailsViewerE4}).<br>
135 134
 * Depending on the type of the selected element the section of the details view
136 135
 * are created.
137 136
 *
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java
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 java.util.Set;
13

  
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.jface.viewers.StructuredViewerInternals;
18
import org.eclipse.jface.viewers.TreeNode;
19
import org.eclipse.jface.viewers.Viewer;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.part.EditorPart;
23

  
24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
25
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
26
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
27
import eu.etaxonomy.cdm.model.taxon.Taxon;
28
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
29
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
30
import eu.etaxonomy.taxeditor.l10n.Messages;
31
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
33
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
34
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
35
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
36

  
37

  
38
/**
39
 * <p>SupplementalDataViewPart class.</p>
40
 *
41
 * @author n.hoffmann
42
 * @created Jun 10, 2010
43
 * @version 1.0
44
 */
45
public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
46

  
47
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
48
	public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData"; //$NON-NLS-1$
49

  
50
	private SupplementalDataViewer viewer;
51

  
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
54
	 */
55
	/** {@inheritDoc} */
56
	@Override
57
	public void createViewer(Composite parent) {
58
		viewer = new SupplementalDataViewer(parent, this);
59
	}
60

  
61

  
62
	/** {@inheritDoc} */
63
	@Override
64
	protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
65
	    Object partObject = workbenchPart;
66
        Object wrappedPart = WorkbenchUtility.getE4WrappedPart(partObject);
67
        if(wrappedPart!=null){
68
            partObject = wrappedPart;
69
        }
70
		if(AbstractUtility.getActiveEditor() == null){
71
			showEmptyPage();
72
			return;
73
		}
74

  
75
        if(partObject == this){
76
            return;
77
        }
78

  
79
        if(!(selection instanceof IStructuredSelection)){
80
            return;
81
        }
82

  
83
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
84
        
85
		if((partObject instanceof EditorPart || partObject instanceof IPartContentHasSupplementalData)) {
86
			if(structuredSelection.size() != 1){
87
				showEmptyPage();
88
				return;
89
			}
90
		if (partObject instanceof ITaxonEditor && structuredSelection.getFirstElement() instanceof Taxon ){
91
			if (((ITaxonEditor)partObject).getTaxon() != structuredSelection.getFirstElement() && ((Taxon)structuredSelection.getFirstElement()).isMisapplication()){
92
				Set<TaxonRelationship> rels =((Taxon)structuredSelection.getFirstElement()).getTaxonRelations(((ITaxonEditor)partObject).getTaxon());
93
				if (rels.size() == 1){
94
					 structuredSelection = new StructuredSelection(rels.iterator().next());
95
				}else{
96
					showEmptyPage();
97
					return;
98
				}
99
				
100
			}
101
		}
102
			// do not show supplemental data for feature nodes
103
			if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
104
				showEmptyPage();
105
				return;
106
			}
107
			else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
108
				return;
109
			}
110
			else if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
111
			    structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey());
112
            }
113
			else if(structuredSelection.getFirstElement() instanceof TreeNode){
114
				structuredSelection = new StructuredSelection(((TreeNode)structuredSelection.getFirstElement()).getValue());
115
			}
116
			else if(structuredSelection.getFirstElement() instanceof GbifResponse){
117
			    structuredSelection = new StructuredSelection(((GbifResponse)structuredSelection.getFirstElement()).getDerivedUnitFacade().innerDerivedUnit());
118
			} 
119
			
120
			showViewer(partObject, structuredSelection);
121
		}else{
122
			showEmptyPage();
123
		}
124
	}
125

  
126
	/** {@inheritDoc} */
127
	@Override
128
	public void dispose() {
129
		super.dispose();
130
		selectionService.removePostSelectionListener(this);
131
	}
132

  
133

  
134
	/** {@inheritDoc} */
135
	@Override
136
	public Viewer getViewer() {
137
		return viewer;
138
	}
139

  
140
	/**
141
	 * <p>onComplete</p>
142
	 *
143
	 * @return a boolean.
144
	 */
145
	@Override
146
    public boolean onComplete() {
147
		// TODO Auto-generated method stub
148
		return false;
149
	}
150

  
151

  
152
	@Override
153
	protected String getViewName() {
154
		return Messages.SupplementalDataViewPart_VIEWER_NAME;
155
	}
156
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java
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);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)