Revision bc330e88
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.workbench; |
10 | 10 |
|
11 |
import java.lang.reflect.Field; |
|
12 |
|
|
13 | 11 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
14 |
import org.eclipse.ui.ISaveablePart; |
|
15 |
import org.eclipse.ui.internal.E4PartWrapper; |
|
16 |
import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor; |
|
17 |
import org.eclipse.ui.internal.e4.compatibility.CompatibilityView; |
|
18 | 12 |
|
19 | 13 |
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart; |
20 | 14 |
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart; |
... | ... | |
41 | 35 |
if(object instanceof MPart){ |
42 | 36 |
object = ((MPart) activePart).getObject(); |
43 | 37 |
} |
44 |
try { |
|
45 |
if(object instanceof E4PartWrapper){ |
|
46 |
Field field = object.getClass().getDeclaredField("wrappedPart"); |
|
47 |
field.setAccessible(true); |
|
48 |
object = field.get(object); |
|
49 |
} |
|
50 |
else if(object instanceof CompatibilityView || object instanceof CompatibilityEditor){ |
|
51 |
Field field = object.getClass().getSuperclass().getDeclaredField("wrapped"); |
|
52 |
field.setAccessible(true); |
|
53 |
object = field.get(object); |
|
54 |
} |
|
55 |
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { |
|
56 |
e.printStackTrace(); |
|
57 |
} |
|
58 |
//TODO can this still happen?? |
|
59 |
if(object instanceof MPart){ |
|
60 |
object =((MPart) object).getObject(); |
|
61 |
} |
|
62 | 38 |
return object; |
63 | 39 |
} |
64 | 40 |
|
... | ... | |
67 | 43 |
if(selectionProvidingPart instanceof ISelectionElementEditingPart){ |
68 | 44 |
return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart); |
69 | 45 |
} |
70 |
else if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){
|
|
46 |
else if(selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){ |
|
71 | 47 |
return selectionProvidingPart; |
72 | 48 |
} |
73 | 49 |
return null; |
Also available in: Unified diff
ref #6925 Refactor NavigationUtil.isDirty()