package eu.etaxonomy.taxeditor.model;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
-import org.eclipse.ui.internal.E4PartWrapper;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.ui.progress.IProgressService;
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
*
IWorkbenchPage activePage = getActivePage();
if(activePage!=null){
IWorkbenchPart activePart = activePage.getActivePart();
- Object e4WrappedPart = getE4WrappedPart(activePart);
+ Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
return e4WrappedPart!=null?e4WrappedPart:activePart;
}
return null;
}
- public static Object getE4WrappedPart(Object activePart){
- if(activePart instanceof E4PartWrapper){
- //FIXME can be removed when E4 migration is complete
- try {
- Field field = activePart.getClass().getDeclaredField("wrappedPart");
- field.setAccessible(true);
- Object object = field.get(activePart);
- if(object instanceof MPart){
- return ((MPart) object).getObject();
- }
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
public static IWorkbench getWorkbench() {
return TaxeditorStorePlugin.getDefault().getWorkbench();
}
public static Object getActiveE4Editor() {
if(getActivePage()!=null){
IEditorPart activeEditor = getActivePage().getActiveEditor();
- Object wrappedPart = getE4WrappedPart(getActivePage().getActivePart());
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(getActivePage().getActivePart());
return wrappedPart!=null?wrappedPart:activeEditor;
}
return null;