Project

General

Profile

« Previous | Next » 

Revision da0bf48a

Added by Patrick Plitzner over 6 years ago

ref #6911, #6925 Clear views when selection providing editor is closed

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/ConceptViewPartE4.java
35 35
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
36 36
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptContentProvider;
37 37
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptLabelProvider;
38
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
39
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
38 40
import eu.etaxonomy.taxeditor.model.AbstractUtility;
39 41
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
40 42
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
......
65 67

  
66 68
        Object partObject = createPartObject(activePart);
67 69

  
68
        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4) {
70
        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
71
                || partObject instanceof FactualDataPartE4|| partObject instanceof MediaViewPartE4) {
69 72
            // do not show empty page as these views are also used to edit the
70 73
            // description selected in this view
71 74
            return;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
47 47
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
48 48
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
49 49
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
50
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
50 51
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
51 52
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
52 53
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
......
142 143
        Object partObject = createPartObject(activePart);
143 144

  
144 145
        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
145
                || partObject instanceof MediaViewPartE4) {
146
                || partObject instanceof MediaViewPartE4 || partObject instanceof ConceptViewPartE4) {
146 147
            // do not show empty page as these views are also used to edit the
147 148
            // description selected in this view
148 149
            return;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java
28 28
import eu.etaxonomy.cdm.model.description.IDescribable;
29 29
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
30 30
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
31
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
31 32
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
32 33
import eu.etaxonomy.taxeditor.editor.view.media.MediaContentProvider;
33 34
import eu.etaxonomy.taxeditor.editor.view.media.MediaLabelProvider;
......
82 83
	    Object partObject = createPartObject(activePart);
83 84

  
84 85
	    if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
85
	            || partObject instanceof FactualDataPartE4) {
86
	            || partObject instanceof FactualDataPartE4 || partObject instanceof ConceptViewPartE4) {
86 87
	        // do not show empty page as these views are also used to edit the
87 88
	        // description selected in this view
88 89
	        return;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
149 149

  
150 150
	protected abstract void showParts();
151 151

  
152
	protected void destroySections() {
152
	public void destroySections() {
153 153
		for (IFormPart formPart : managedForm.getParts()){
154 154
			removePart((CdmSectionPart<?>) formPart);
155 155
		}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
103 103
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
104 104
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
105 105
            MPart thisPart){
106
        Object savablePart = WorkbenchUtility.findSavablePart(this);
107
        if(savablePart==null){
108
            showEmptyPage();
109
        }
106 110
        if(delaySelection==null){
107 111
            delaySelection = new DelaySelection(selection, activePart, thisPart);
108 112
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
85 85
            showViewer(structuredSelection, activePart, viewer);
86 86
            return;
87 87
        }
88
        else if(selectionProvidingPart!=null && selectionProvidingPart.isVisible()){
89
            return;
90
        }
91 88
        else{
92 89
            showEmptyPage();
93 90
            return;
94 91
        }
95 92
    }
96 93

  
97
//    protected void showEmptyPage() {
98
//        super.showEmptyPage();
99
//        if(viewer!=null){
100
//            viewer.showEmptyPage();
101
//        }
102
//        selectionProvidingPart = null;
103
//    }
94
    @Override
95
    protected void showEmptyPage() {
96
        super.showEmptyPage();
97
        if(viewer!=null && !viewer.getControl().isDisposed()){
98
            ((DetailsViewerE4)viewer).destroySections();
99
        }
100
    }
104 101

  
105 102
    @Override
106 103
    protected String getViewName(){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java
106 106
	        showViewer(structuredSelection, activePart, viewer);
107 107
	        return;
108 108
	    }
109
        else if(selectionProvidingPart!=null && selectionProvidingPart.isVisible()){
110
            return;
111
        }
112 109
        else{
113 110
	        showEmptyPage();
114 111
	        return;
115 112
	    }
116 113
	}
117 114

  
115
    /**
116
     * {@inheritDoc}
117
     */
118
    @Override
119
    protected void showEmptyPage() {
120
        super.showEmptyPage();
121
        if(viewer!=null && !viewer.getControl().isDisposed()){
122
            ((SupplementalDataViewerE4)viewer).destroySections();
123
        }
124
    }
125

  
118 126
	@Override
119 127
    protected String getViewName() {
120 128
		return Messages.SupplementalDataViewPart_VIEWER_NAME;
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/SaveHandler.java
32 32
            Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(activePart.getObject());
33 33
            if(e4WrappedPart instanceof ISelectionElementEditingPart){
34 34
                ISelectionElementEditingPart editingPart = (ISelectionElementEditingPart)e4WrappedPart;
35
                Object savablePart = findSavablePart(editingPart);
35
                Object savablePart = WorkbenchUtility.findSavablePart(editingPart);
36 36
                if(savablePart instanceof ISaveablePart){
37 37
                    ((ISaveablePart) savablePart).doSave(new NullProgressMonitor());
38 38
                }
......
46 46
        }
47 47
	}
48 48

  
49
	private Object findSavablePart(ISelectionElementEditingPart part){
50
	    Object selectionProvidingPart = WorkbenchUtility.getE4WrappedPart(part.getSelectionProvidingPart());
51
	    if(selectionProvidingPart instanceof ISelectionElementEditingPart){
52
	        return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart);
53
	    }
54
	    else if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){
55
	        return selectionProvidingPart;
56
	    }
57
	    return null;
58
	}
59

  
60

  
61
    private void savePart(EPartService partService, ECommandService commandService, EHandlerService handlerService,
49
	private void savePart(EPartService partService, ECommandService commandService, EHandlerService handlerService,
62 50
            MPart mPart) {
63 51
        if(mPart.getObject() instanceof CompatibilityPart){
64 52
            //FIXME E4 remove when fully migrated
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java
11 11
import java.lang.reflect.Field;
12 12

  
13 13
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
14
import org.eclipse.ui.ISaveablePart;
14 15
import org.eclipse.ui.internal.E4PartWrapper;
15 16
import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor;
16 17
import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
17 18

  
19
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
20
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
21

  
18 22
/**
19 23
 * Utility class for e4 workbench related operations
20 24
 * @author pplitzner
......
57 61
        }
58 62
        return object;
59 63
    }
64

  
65
    public static Object findSavablePart(ISelectionElementEditingPart part){
66
        Object selectionProvidingPart = getE4WrappedPart(part.getSelectionProvidingPart());
67
        if(selectionProvidingPart instanceof ISelectionElementEditingPart){
68
            return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart);
69
        }
70
        else if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){
71
            return selectionProvidingPart;
72
        }
73
        return null;
74
    }
60 75
}

Also available in: Unified diff