fix #8703 Open term search and specimen (import) search to editor area
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 19 Nov 2019 13:46:23 +0000 (14:46 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 19 Nov 2019 13:46:23 +0000 (14:46 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/DataImportViewE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/e4/SpecimenSearchWizardE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/term/TermSearch.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenPartHandler.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/IE4SavablePart.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/IEditorAreaPart.java [new file with mode: 0644]

index 704e1aea5862756ff1725c9cf5743e8fda96f07e..386a3c5dae9619163d64bb6ed81566c662c87d7a 100644 (file)
@@ -52,6 +52,7 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
+import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart;
 
 /**
  * View which shows a list of "data" that can be imported into the CDM
@@ -61,7 +62,7 @@ import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
  * @param <T> the CDM type that will be handled by this view
  */
 public abstract class DataImportViewE4<T> implements IPartContentHasFactualData,
-IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, Listener{
+IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IContextListener, Listener, IEditorAreaPart{
 
     protected final Logger logger = Logger.getLogger(DataImportViewE4.class);
 
index b402637853f4607b7fd68772880cca2e20d349a4..6887282b3834dfdec2da6cb2a3c787fa8df72642 100644 (file)
@@ -19,7 +19,10 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.e4.core.contexts.ContextInjectionFactory;
 import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.MApplication;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 import org.eclipse.jface.wizard.Wizard;
@@ -36,6 +39,8 @@ import eu.etaxonomy.cdm.io.specimen.abcd206.in.UnitAssociationWrapper;
 import eu.etaxonomy.taxeditor.store.AppModelId;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.dataimport.QueryType;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart;
 
 /**
  * Wizard for querying specimen provider.
@@ -52,6 +57,12 @@ public class SpecimenSearchWizardE4 extends Wizard {
     @Inject
     private EPartService partService;
 
+    @Inject
+    private MApplication application;
+
+    @Inject
+    private EModelService modelService;
+
     private IEclipseContext context;
 
     /**
@@ -86,13 +97,13 @@ public class SpecimenSearchWizardE4 extends Wizard {
         try {
             serviceWrapper = providerSelectionPage.getQueryServiceWrapper();
             InputStream stream = null;
-
+            MPart part = null;
             if (providerSelectionPage.getQueryType().equals(QueryType.BIOCASE)){
                 stream =((BioCaseQueryServiceWrapper) serviceWrapper).query(query, configurator.getSourceUri());
                 SpecimenImportReport report = new SpecimenImportReport();
                 UnitAssociationWrapper unitNodesList = AbcdParseUtility.parseUnitsNodeList(stream, report);
 
-                MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_SPECIMENIMPORTVIEWE4);
+                part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_SPECIMENIMPORTVIEWE4);
                 part = partService.showPart(part, PartState.ACTIVATE);
                 SpecimenImportViewE4 specimenImportView = (SpecimenImportViewE4) part.getObject();
                 specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());
@@ -101,7 +112,7 @@ public class SpecimenSearchWizardE4 extends Wizard {
                 dataImportView = specimenImportView;
 
             } else{
-                MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_GBIFRESPONSEIMPORTVIEWE4);
+                part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_DATAIMPORT_E4_GBIFRESPONSEIMPORTVIEWE4);
                 part = partService.showPart(part, PartState.ACTIVATE);
                 GbifResponseImportViewE4 gbifImportView = (GbifResponseImportViewE4) part.getObject();
                 gbifImportView.setQuery(query);
@@ -109,6 +120,13 @@ public class SpecimenSearchWizardE4 extends Wizard {
                 dataImportView = gbifImportView;
 
             }
+            if(part.getObject() instanceof IEditorAreaPart){
+                MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
+                if(editorAreaPartStack!=null){
+                    editorAreaPartStack.getChildren().add(part);
+                }
+                part = partService.showPart(part, PartState.VISIBLE);
+            }
         } catch (IOException e) {
             e.printStackTrace();
         }
index ab9ba09fd1604d46615a86cd2be88a726597d0ab..8001df723fd06fe898624a88f02030ee695d74fe 100644 (file)
@@ -14,13 +14,14 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 
 import eu.etaxonomy.taxeditor.view.search.facet.SearchComposite;
+import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart;
 
 /**
  * @author pplitzner
  * @since Jan 22, 2019
  *
  */
-public class TermSearch {
+public class TermSearch implements IEditorAreaPart{
 
     @SuppressWarnings("unused")
     @PostConstruct
index 3e8ea8861b0e6f17321d1fd25de9b56f7faef93d..8a04d3b21299bc491c5ddb21839d5ce4e9f05924 100644 (file)
@@ -13,7 +13,7 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
 
-import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
+import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart;
 
 public class OpenPartHandler {
 
@@ -27,7 +27,7 @@ public class OpenPartHandler {
         String partId = parameterMap.get(AppModelId.COMMANDPARAMETER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_COMMANDPARAMETER_PARTNAME).toString();
         MPart part = partService.createPart(partId);
         part = partService.showPart(part, PartState.ACTIVATE);
-        if(part.getObject() instanceof IE4SavablePart){
+        if(part.getObject() instanceof IEditorAreaPart){
             MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
             if(editorAreaPartStack!=null){
                 editorAreaPartStack.getChildren().add(part);
index 2596bc243fd7c4dcf4a388b5f43a165db8f23f64..096bfdc9c9b455fc4432925726f49e628f3040e6 100644 (file)
@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
  * @since Jun 28, 2017
  *
  */
-public interface IE4SavablePart {
+public interface IE4SavablePart extends IEditorAreaPart{
     //FIXME E4
 
     /**
diff --git a/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/IEditorAreaPart.java b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/IEditorAreaPart.java
new file mode 100644 (file)
index 0000000..fe2cda3
--- /dev/null
@@ -0,0 +1,20 @@
+// $Id$
+/**
+* Copyright (C) 2019 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.part;
+
+/**
+ * Implementing parts will be opened in the editor area.
+ * @author pplitzner
+ * @date 19.11.2019
+ *
+ */
+public interface IEditorAreaPart {
+
+}