Project

General

Profile

« Previous | Next » 

Revision 4719d4fd

Added by Patrick Plitzner over 6 years ago

ref #6597 fix selection handling

View differences:

eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java
12 12

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

  
17 18
/**
......
30 31
     * @return the wrapped legacy part or <code>null</code>
31 32
     */
32 33
    public static Object getE4WrappedPart(Object activePart){
33
        //FIXME can be removed when E4 migration is complete
34
        //FIXME E4 can be removed when E4 migration is complete
34 35

  
35
        Object object = null;
36
        Object object = activePart;
37
        if(object instanceof MPart){
38
            object = ((MPart) activePart).getObject();
39
        }
36 40
        try {
37
            if(activePart instanceof E4PartWrapper){
38
                Field field = activePart.getClass().getDeclaredField("wrappedPart");
41
            if(object instanceof E4PartWrapper){
42
                Field field = object.getClass().getDeclaredField("wrappedPart");
39 43
                field.setAccessible(true);
40
                object = field.get(activePart);
44
                object = field.get(object);
41 45
            }
42
            else if(activePart instanceof CompatibilityView){
43
                Field field = activePart.getClass().getSuperclass().getDeclaredField("wrapped");
46
            else if(object instanceof CompatibilityView || object instanceof CompatibilityEditor){
47
                Field field = object.getClass().getSuperclass().getDeclaredField("wrapped");
44 48
                field.setAccessible(true);
45
                object = field.get(activePart);
49
                object = field.get(object);
46 50
            }
47 51
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
48 52
            e.printStackTrace();
49 53
        }
54
        //TODO can this still happen??
50 55
        if(object instanceof MPart){
51 56
            object =((MPart) object).getObject();
52 57
        }

Also available in: Unified diff