Project

General

Profile

« Previous | Next » 

Revision 5062284f

Added by Patrick Plitzner almost 7 years ago

ref #6597 Propagate editing events

View differences:

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

  
24 26
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
25 27
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
26 28
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
27 29
import eu.etaxonomy.taxeditor.l10n.Messages;
30
import eu.etaxonomy.taxeditor.model.AbstractUtility;
31
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
28 32

  
29 33
/**
30 34
 * @author pplitzner
31 35
 * @date 18.07.2017
32 36
 *
33 37
 */
34
public class DetailsPartE4 implements IConversationEnabled{
38
public class DetailsPartE4 implements IConversationEnabled, IDirtyMarkable{
35 39

  
36 40
    private DetailsViewerE4 viewer;
37 41

  
42
    private MPart selectionProvidingPart;
43

  
38 44
    @Inject
39 45
    public DetailsPartE4() {
40 46
    }
41 47

  
42 48
    @PostConstruct
43 49
    public void create(Composite parent) {
44
        viewer = new DetailsViewerE4(parent);
50
        viewer = new DetailsViewerE4(parent, this);
45 51
    }
46 52

  
47 53
    @Inject
48 54
    @Optional
49 55
    public void selectionChanged(
50
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
56
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
51 57
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
52 58
            MPart thisPart){
53
        showViewer(selection, activePart, thisPart);
59
        if(activePart==thisPart){
60
            return;
61
        }
62
        if(selection instanceof IStructuredSelection){
63
            showViewer((IStructuredSelection) selection, activePart, thisPart);
64
        }
65
        else{
66
            showViewer(new StructuredSelection(selection), activePart, thisPart);
67
        }
54 68
    }
55 69

  
56 70
    protected String getViewName(){
......
71 85
            Object element = selection.getFirstElement();
72 86
            if(selection.getFirstElement()!=null){
73 87
                getViewer().setInput(element);
88
                selectionProvidingPart = activePart;
74 89
            }
75 90
        }
76 91
    }
......
89 104
     */
90 105
    @Override
91 106
    public ConversationHolder getConversationHolder() {
107
        if(selectionProvidingPart != null && selectionProvidingPart instanceof IConversationEnabled) {
108
            return ((IConversationEnabled) selectionProvidingPart).getConversationHolder();
109
        }
92 110
        return null;
93 111
    }
112

  
113
    /** {@inheritDoc} */
114
    @Override
115
    public void changed(Object object) {
116
        Object part = selectionProvidingPart.getObject();
117
        if(part instanceof IDirtyMarkable){
118
            ((IDirtyMarkable) part).changed(object);
119
        }
120
        else {
121
            IEditorPart editor = AbstractUtility.getActiveEditor();
122
            if (editor != null && editor instanceof IDirtyMarkable) {
123
                ((IDirtyMarkable) editor).changed(object);
124
            }
125
        }
126
    }
127

  
128
    /**
129
     * {@inheritDoc}
130
     */
131
    @Override
132
    public void forceDirty() {
133
        // TODO Auto-generated method stub
134

  
135
    }
94 136
}

Also available in: Unified diff