ref #6913 Remove workbench and selection handling from edit/new wizards
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 12:02:45 +0000 (13:02 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 13:57:46 +0000 (14:57 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/AbstractEditWizard.java

index ffb2879bcb1797f6ab661d2195b243efc8714d6c..da293d6b107bc4265728d4d0e72777357e293662 100644 (file)
@@ -55,8 +55,6 @@ import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
 import org.eclipse.ui.progress.IProgressConstants;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
@@ -474,15 +472,6 @@ public abstract class AbstractUtility {
         newMonitor.worked(steps);
     }
 
-    public static IProgressService getProgressService() {
-        IWorkbench workbench = PlatformUI.getWorkbench();
-        return workbench.getProgressService();
-    }
-
-    public static IWorkbenchSiteProgressService getProgressService2() {
-        return (IWorkbenchSiteProgressService) getService(IWorkbenchSiteProgressService.class);
-    }
-
     public static String getPluginId() {
         return "eu.taxeditor";
     }
index 3424c61f9d773bdbde067149e75d53c6301b73c7..0f41b326693baaa312e96026f4a1840d58ce3978 100644 (file)
@@ -9,29 +9,25 @@
 
 package eu.etaxonomy.taxeditor.newWizard;
 
+import org.eclipse.e4.ui.workbench.IWorkbench;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbench;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 
 /**
- * <p>Abstract AbstractNewEntityWizard class.</p>
  *
  * @author n.hoffmann
  * @created Jun 1, 2010
  * @version 1.0
  */
 public abstract class AbstractNewEntityWizard<T> extends Wizard implements
-               INewWizard, IConversationEnabled {
+               IConversationEnabled {
 
        private ConversationHolder conversation;
 
@@ -39,15 +35,8 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
 
        private T entity;
 
-       private IWorkbench workbench;
-
        private IStructuredSelection selection;
 
-       /**
-        * <p>Constructor for AbstractNewEntityWizard.</p>
-        *
-        * @param <T> a T object.
-        */
        public AbstractNewEntityWizard(){
                setWindowTitle(String.format("New %s", getEntityName()));
        }
@@ -59,9 +48,6 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
         */
        protected abstract String getEntityName();
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.wizard.Wizard#performFinish()
-        */
        /** {@inheritDoc} */
        @Override
        public boolean performFinish() {
@@ -72,20 +58,10 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
                return true;
        }
 
-       /**
-        * <p>Getter for the field <code>entity</code>.</p>
-        *
-        * @return a T object.
-        */
        public T getEntity() {
                return entity;
        }
 
-       /**
-        * <p>Setter for the field <code>entity</code>.</p>
-        *
-        * @param entity a T object.
-        */
        public void setEntity(T entity){
                this.entity = entity;
        }
@@ -95,40 +71,17 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
         */
        protected abstract void saveEntity();
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
-        */
        /** {@inheritDoc} */
-       @Override
        public void init(IWorkbench workbench, IStructuredSelection selection) {
-               this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench();
-
-               if(selection == null){
-                       ISelectionService service = this.workbench.getActiveWorkbenchWindow().getSelectionService();
-                       if(service.getSelection() instanceof IStructuredSelection){
-                               selection = (IStructuredSelection) service.getSelection();
-                       }
-               }
-               this.selection = selection;
-
-               formFactory = new CdmFormFactory(Display.getCurrent(), null);
-               conversation = CdmStore.createConversation();
+           formFactory = new CdmFormFactory(Display.getCurrent(), null);
+           conversation = CdmStore.createConversation();
+           this.selection = selection;
                entity = createNewEntity();
 
        }
 
-       /**
-        * <p>createNewEntity</p>
-        *
-        * @return a T object.
-        */
        protected abstract T createNewEntity();
 
-       /**
-        * <p>getConversationHolder</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        */
        @Override
     public ConversationHolder getConversationHolder() {
                return conversation;
@@ -138,16 +91,6 @@ public abstract class AbstractNewEntityWizard<T> extends Wizard implements
        @Override
     public void update(CdmDataChangeMap changeEvents) {}
 
-       /**
-        * @return the workbench
-        */
-       public IWorkbench getWorkbench() {
-               return workbench;
-       }
-
-       /**
-        * @return the selection
-        */
        public IStructuredSelection getSelection() {
                return selection;
        }
index 6b204d17adb3ae5a341d7bd6ee832f05c752472a..aff83e4aaa2310d656471eed90db11011a4a2df9 100644 (file)
@@ -21,7 +21,6 @@ import org.eclipse.ui.IWorkbench;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 /**
@@ -38,8 +37,6 @@ INewWizard, IConversationEnabled{
 
     private T entity;
 
-    private IWorkbench workbench;
-
     @Inject
     private IEclipseContext context;
 
@@ -102,13 +99,8 @@ INewWizard, IConversationEnabled{
     /** {@inheritDoc} */
     @Override
     public void init(IWorkbench workbench, IStructuredSelection selection) {
-        this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench();
-
-
         formFactory = new CdmFormFactory(context.get(Shell.class).getDisplay());
         conversation = CdmStore.createConversation();
-
-
     }
 
 
@@ -127,13 +119,4 @@ INewWizard, IConversationEnabled{
     @Override
     public void update(CdmDataChangeMap changeEvents) {}
 
-    /**
-     * @return the workbench
-     */
-    public IWorkbench getWorkbench() {
-        return workbench;
-    }
-
-
-
 }