org.eclipse.ui.forms,
eu.etaxonomy.taxeditor.store,
eu.etaxonomy.taxeditor.bulkeditor,
+ eu.etaxonomy.taxeditor.workbench,
org.eclipse.zest.core,
org.eclipse.zest.layouts,
eu.etaxonomy.taxeditor.cdmlib,
IEditorInput input = ((IEditorPart) part).getEditorInput();
showViewer(part, new StructuredSelection(input));
}
- showViewer();
}
}
package eu.etaxonomy.taxeditor.editor.view.descriptive;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.e4.ui.di.Persist;
-import org.eclipse.e4.ui.model.application.ui.MDirtyable;
-import org.eclipse.e4.ui.workbench.UIEvents.Dirtyable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.internal.E4PartWrapper;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author n.hoffmann
protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
private DescriptiveContentProvider provider;
-
-
+
+
/** {@inheritDoc} */
@Override
public void createViewer(Composite parent) {
showEmptyPage();
}
}
-
+
@Override
protected String getViewName(){
return Messages.DescriptiveViewPart_FACTUAL_DATA;
((BulkEditor) part).forceDirty();
IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
((BulkEditor) part).changed(selection.getFirstElement());
-
+
}
-
+
if (part instanceof E4PartWrapper){
- part = AbstractUtility.getE4WrappedPart(part);
+ part = WorkbenchUtility.getE4WrappedPart(part);
if (part instanceof IDirtyMarkable){
StructuredSelection selection = new StructuredSelection(object);
((IDirtyMarkable)part).changed(selection.getFirstElement());
}
}
-
+
super.changed(object);
}
provider.toggleShowOnlyIndividualAssociations();
viewer.refresh();
}
-
-
+
+
}
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISaveablePart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.internal.E4PartWrapper;
-import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
import eu.etaxonomy.cdm.model.description.IDescribable;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author n.hoffmann
// showEmptyPage();
// return;
// }
-
+
if (part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart
|| part instanceof DescriptiveViewPart) {
}
}
}
-
+
showEmptyPage();
}
}
if (part instanceof E4PartWrapper){
- part = AbstractUtility.getE4WrappedPart(part);
+ part = WorkbenchUtility.getE4WrappedPart(part);
if (part instanceof IDirtyMarkable){
StructuredSelection selection = new StructuredSelection(object);
((IDirtyMarkable)part).changed(selection.getFirstElement());
}
}
-
-
+
+
super.changed(object);
}
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;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* <p>DetailsViewPart class.</p>
@Override
protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection){
Object part = workbenchPart;
- Object wrappedPart = AbstractUtility.getE4WrappedPart(part);
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
if(wrappedPart!=null){
part = wrappedPart;
}
TaxonRelationship rel = rels.iterator().next();
if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
getViewer().setInput(rel);
- showViewer();
+ showViewer();
+// super.showViewer(part, selection);
return;
}
}
}
getViewer().setInput(element);
showViewer();
+// super.showViewer(part, selection);
}
}
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
@Override
protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
Object part = workbenchPart;
- Object wrappedPart = AbstractUtility.getE4WrappedPart(part);
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
if(wrappedPart!=null){
part = wrappedPart;
}
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.inject;version="1.0.0"
Bundle-ActivationPolicy: lazy
-Export-Package: eu.etaxonomy.taxeditor.workbench.part
+Export-Package: eu.etaxonomy.taxeditor.workbench,
+ eu.etaxonomy.taxeditor.workbench.part
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.workbench;
+
+import java.lang.reflect.Field;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.ui.internal.E4PartWrapper;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
+
+/**
+ * Utility class for e4 workbench related operations
+ * @author pplitzner
+ * @since Jun 27, 2017
+ *
+ */
+public class WorkbenchUtility {
+
+ /**
+ * Checks if the activePart is an E4 wrapper for a legacy part and returns
+ * that part
+ *
+ * @param activePart the e4 wrapper
+ * @return the wrapped legacy part or <code>null</code>
+ */
+ public static Object getE4WrappedPart(Object activePart){
+ //FIXME can be removed when E4 migration is complete
+
+ Object object = null;
+ try {
+ if(activePart instanceof E4PartWrapper){
+ Field field = activePart.getClass().getDeclaredField("wrappedPart");
+ field.setAccessible(true);
+ object = field.get(activePart);
+ }
+ else if(activePart instanceof CompatibilityView){
+ Field field = activePart.getClass().getSuperclass().getDeclaredField("wrapped");
+ field.setAccessible(true);
+ object = field.get(activePart);
+ }
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ if(object instanceof MPart){
+ object =((MPart) object).getObject();
+ }
+ return object;
+ }
+}