Project

General

Profile

Revision a4980826

IDa49808268ab4e0a76254dd8a9592ddec0c1ff2dc
Parent 6f5407a6
Child 3c2b5bba

Added by Patrick Plitzner over 2 years ago

ref #6905, #6597 refactor selectionChanged() method

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
13 13

  
14 14
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
15 15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.StructuredSelection;
16 17
import org.eclipse.swt.widgets.Composite;
17 18
import org.eclipse.ui.IEditorPart;
18 19

  
......
21 22
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
22 23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23 24
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
25
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
24 26
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
25 27

  
26 28
/**
......
66 68
        }
67 69
    }
68 70

  
71
    protected Object createPartObject(MPart activePart) {
72
        Object partObject = activePart;
73
        Object wrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
74
        if(wrappedPart!=null){
75
            partObject = wrappedPart;
76
        }
77
        return partObject;
78
    }
79

  
80
    protected IStructuredSelection createSelection(Object selection) {
81
        if(selection==null){
82
            return null;
83
        }
84
        IStructuredSelection structuredSelection;
85
        if(!(selection instanceof IStructuredSelection)){
86
            structuredSelection = new StructuredSelection(selection);
87
        }
88
        else{
89
            structuredSelection = (IStructuredSelection) selection;
90
        }
91
        return structuredSelection;
92
    }
93

  
69 94
    public void showEmptyPage() {
70 95
        if(viewer!=null){
71 96
            viewer.showEmptyPage();
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;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java
21 21
import org.eclipse.jface.viewers.StructuredSelection;
22 22
import org.eclipse.jface.viewers.TreeNode;
23 23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.ui.part.EditorPart;
25 24

  
26 25
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
27 26
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
......
34 33
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
35 34
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
36 35
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
37
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
38 36

  
39 37

  
40 38
/**
......
63 61
	    if(activePart==thisPart){
64 62
	        return;
65 63
	    }
66
	    if(selection==null){
67
	        showEmptyPage();
68
	        return;
69
	    }
70

  
71
	    Object partObject = activePart;
72
	    Object wrappedPart = WorkbenchUtility.getE4WrappedPart(partObject);
73
	    if(wrappedPart!=null){
74
	        partObject = wrappedPart;
75
	    }
76 64

  
77
	    IStructuredSelection structuredSelection;
78
	    if(!(selection instanceof IStructuredSelection)){
79
	        structuredSelection = new StructuredSelection(selection);
80
	    }
81
	    else{
82
	        structuredSelection = (IStructuredSelection) selection;
83
	    }
65
	    IStructuredSelection structuredSelection = createSelection(selection);
84 66
	    if(structuredSelection.isEmpty()){
85 67
	        showEmptyPage();
86 68
	        return;
87 69
	    }
88 70

  
89
	    if((partObject instanceof EditorPart || partObject instanceof IPartContentHasSupplementalData)) {
71
        Object partObject = createPartObject(activePart);
72

  
73
	    if(partObject instanceof IPartContentHasSupplementalData) {
90 74
	        if(structuredSelection.size() != 1){
91 75
	            showEmptyPage();
92 76
	            return;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)