import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author pplitzner
@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
MPart thisPart){
- if(activePart==thisPart){
+ if(activePart==thisPart || selection==null){
return;
}
- if(selection instanceof IStructuredSelection){
- showViewer((IStructuredSelection) selection, activePart, thisPart);
+
+ Object partObject = activePart;
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
+ if(wrappedPart!=null){
+ partObject = wrappedPart;
+ }
+
+ IStructuredSelection structuredSelection;
+ if(!(selection instanceof IStructuredSelection)){
+ structuredSelection = new StructuredSelection(selection);
}
else{
- showViewer(new StructuredSelection(selection), activePart, thisPart);
+ structuredSelection = (IStructuredSelection) selection;
}
+ if((partObject instanceof IEditorPart) || (partObject instanceof IPartContentHasDetails)) {
+ showViewer(structuredSelection);
+ selectionProvidingPart = activePart;
+ }
+ }
+
+ public void showEmptyPage() {
+ viewer.setSelection(null);
}
protected String getViewName(){
public void dispose() {
}
- public void showViewer(IStructuredSelection selection, MPart activePart, MPart thisPart){
+ public void showViewer(IStructuredSelection selection){
if(getViewer()!=null){
Object element = selection.getFirstElement();
if(selection.getFirstElement()!=null){
getViewer().setInput(element);
- selectionProvidingPart = activePart;
}
}
}
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.ui.internal.E4PartWrapper;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor;
import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
/**
* @return the wrapped legacy part or <code>null</code>
*/
public static Object getE4WrappedPart(Object activePart){
- //FIXME can be removed when E4 migration is complete
+ //FIXME E4 can be removed when E4 migration is complete
- Object object = null;
+ Object object = activePart;
+ if(object instanceof MPart){
+ object = ((MPart) activePart).getObject();
+ }
try {
- if(activePart instanceof E4PartWrapper){
- Field field = activePart.getClass().getDeclaredField("wrappedPart");
+ if(object instanceof E4PartWrapper){
+ Field field = object.getClass().getDeclaredField("wrappedPart");
field.setAccessible(true);
- object = field.get(activePart);
+ object = field.get(object);
}
- else if(activePart instanceof CompatibilityView){
- Field field = activePart.getClass().getSuperclass().getDeclaredField("wrapped");
+ else if(object instanceof CompatibilityView || object instanceof CompatibilityEditor){
+ Field field = object.getClass().getSuperclass().getDeclaredField("wrapped");
field.setAccessible(true);
- object = field.get(activePart);
+ object = field.get(object);
}
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
+ //TODO can this still happen??
if(object instanceof MPart){
object =((MPart) object).getObject();
}