Project

General

Profile

« Previous | Next » 

Revision a4980826

Added by Patrick Plitzner over 6 years ago

ref #6905, #6597 refactor selectionChanged() method

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
16 16
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
17 17
import org.eclipse.e4.ui.services.IServiceConstants;
18 18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.jface.viewers.StructuredSelection;
20 19
import org.eclipse.swt.widgets.Composite;
21 20

  
22 21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
26 25
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
27 26
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
28 27
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
29
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
30 28

  
31 29
/**
32 30
 * @author pplitzner
......
56 54
        if(activePart==thisPart){
57 55
            return;
58 56
        }
59
        if(selection==null){
60
            showEmptyPage();
61
            return;
62
        }
63 57

  
64
        Object partObject = activePart;
65
        Object wrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
66
        if(wrappedPart!=null){
67
            partObject = wrappedPart;
68
        }
69

  
70
        IStructuredSelection structuredSelection;
71
        if(!(selection instanceof IStructuredSelection)){
72
            structuredSelection = new StructuredSelection(selection);
73
        }
74
        else{
75
            structuredSelection = (IStructuredSelection) selection;
76
        }
58
        IStructuredSelection structuredSelection = createSelection(selection);
77 59
        if(structuredSelection.isEmpty()){
78 60
            showEmptyPage();
79 61
            return;
80 62
        }
63

  
64
        Object partObject = createPartObject(activePart);
65

  
81 66
        if(partObject instanceof IPartContentHasDetails){
82 67
            if(partObject instanceof IConversationEnabled && ((IConversationEnabled) partObject).getConversationHolder()==null) {
83 68
                //TODO show specific message (refactor EmptyElement to allow specific messages)
......
87 72
            // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
88 73
            if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
89 74
                // do show the map for distributions
90
                Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
75
                Feature feature = ((FeatureNodeContainer) structuredSelection.getFirstElement()).getFeature();
91 76
                if(!feature.equals(Feature.DISTRIBUTION())){
92 77
                    showEmptyPage();
93 78
                    return;
......
102 87
        }
103 88
    }
104 89

  
105

  
106 90
    @Override
107 91
    protected String getViewName(){
108 92
        return Messages.DetailsViewPart_VIEWER_NAME;

Also available in: Unified diff