Project

General

Profile

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

    
12
import javax.annotation.PostConstruct;
13
import javax.inject.Inject;
14
import javax.inject.Named;
15

    
16
import org.eclipse.e4.core.di.annotations.Optional;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.services.IServiceConstants;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.swt.widgets.Composite;
21

    
22
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
23
import eu.etaxonomy.cdm.model.description.Feature;
24
import eu.etaxonomy.taxeditor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
26
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
27
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
28

    
29
/**
30
 * @author pplitzner
31
 * @date 18.07.2017
32
 *
33
 */
34
public class DetailsPartE4 extends AbstractCdmEditorPartE4{
35

    
36
    @Inject
37
    public DetailsPartE4() {
38
    }
39

    
40
    @PostConstruct
41
    public void create(Composite parent) {
42
        viewer = new DetailsViewerE4(parent, this);
43
    }
44

    
45
    @Inject
46
    @Optional
47
    public void selectionChanged(
48
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
49
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
50
            MPart thisPart){
51
        if(activePart==thisPart){
52
            return;
53
        }
54

    
55
        Object partObject = createPartObject(activePart);
56

    
57
        if(partObject instanceof IPartContentHasDetails){
58
            IStructuredSelection structuredSelection = createSelection(selection);
59
            if(structuredSelection==null || structuredSelection.isEmpty()){
60
                showEmptyPage();
61
                return;
62
            }
63
            if(partObject instanceof IConversationEnabled && ((IConversationEnabled) partObject).getConversationHolder()==null) {
64
                //TODO show specific message (refactor EmptyElement to allow specific messages)
65
                showEmptyPage();
66
                return;
67
            }
68
            // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
69
            if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
70
                // do show the map for distributions
71
                Feature feature = ((FeatureNodeContainer) structuredSelection.getFirstElement()).getFeature();
72
                if(!feature.equals(Feature.DISTRIBUTION())){
73
                    showEmptyPage();
74
                    return;
75
                }
76
            }
77
            showViewer(structuredSelection, activePart, viewer);
78
            return;
79
        }
80
        else if(selectionProvidingPart!=null && selectionProvidingPart.isVisible()){
81
            return;
82
        }
83
        else{
84
            showEmptyPage();
85
            return;
86
        }
87
    }
88

    
89
//    protected void showEmptyPage() {
90
//        super.showEmptyPage();
91
//        if(viewer!=null){
92
//            viewer.showEmptyPage();
93
//        }
94
//        selectionProvidingPart = null;
95
//    }
96

    
97
    @Override
98
    protected String getViewName(){
99
        return Messages.DetailsViewPart_VIEWER_NAME;
100
    }
101

    
102
}
(1-1/2)