*/
package eu.etaxonomy.taxeditor.view.e4;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import org.eclipse.e4.ui.di.PersistState;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Composite;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
/**
* @author pplitzner
* @since Aug 10, 2017
*
*/
-public abstract class AbstractCdmEditorPartE4 implements IConversationEnabled, IDirtyMarkable{
+public abstract class AbstractCdmEditorPartE4 implements IConversationEnabled, IDirtyMarkable, ISelectionElementEditingPart{
protected AbstractCdmDataViewerE4 viewer;
protected MPart selectionProvidingPart;
- @PostConstruct
- public void create(Composite parent) {
- viewer = createViewer(parent);
- }
-
/** {@inheritDoc} */
@Override
public void changed(Object object) {
}
}
- public void showViewer(IStructuredSelection selection, MPart activePart){
+ protected void showViewer(IStructuredSelection selection, MPart activePart){
if(viewer!=null){
Object element = selection.getFirstElement();
if(selection.getFirstElement()!=null){
}
}
- public void showEmptyPage() {
+ protected Object createPartObject(MPart activePart) {
+ Object partObject = activePart;
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
+ if(wrappedPart!=null){
+ partObject = wrappedPart;
+ }
+ return partObject;
+ }
+
+ protected IStructuredSelection createSelection(Object selection) {
+ if(selection==null){
+ return null;
+ }
+ IStructuredSelection structuredSelection;
+ if(!(selection instanceof IStructuredSelection)){
+ structuredSelection = new StructuredSelection(selection);
+ }
+ else{
+ structuredSelection = (IStructuredSelection) selection;
+ }
+ return structuredSelection;
+ }
+
+ protected void showEmptyPage() {
if(viewer!=null){
viewer.showEmptyPage();
}
return null;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getSelectionProvidingPart() {
+ return selectionProvidingPart;
+ }
+
@PreDestroy
- public void dispose() {
+ private void dispose() {
+ }
+
+ @PersistState
+ private void persistState(){
+
}
/**
protected abstract String getViewName();
- protected abstract AbstractCdmDataViewerE4 createViewer(Composite parent);
}