commit 24fd14265efeb518ef24f0414770e4d7ada0bc59
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Jun 1 08:39:20 2018 +0200

    ref #7362 Add vocabulary chooser when importing term into feature tree

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureNodeDropAdapter.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureNodeDropAdapter.java
index 0ee6f8992..28534b5d5 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureNodeDropAdapter.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureNodeDropAdapter.java
@@ -22,6 +22,7 @@ import org.eclipse.jface.viewers.ViewerDropAdapter;
 import org.eclipse.swt.dnd.TransferData;
 
 import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureNode;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
@@ -30,6 +31,7 @@ import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TermVocabularySelectionDialog;
 import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
 
 public class FeatureNodeDropAdapter extends ViewerDropAdapter {
@@ -51,10 +53,6 @@ public class FeatureNodeDropAdapter extends ViewerDropAdapter {
 		else if(currentTarget instanceof FeatureNode){
 		    target = (FeatureNode) currentTarget;
 		}
-		else{
-		    MessagingUtils.warningDialog(Messages.FeatureNodeDropAdapter_INVALID_TARGET, this, Messages.FeatureNodeDropAdapter_INVALID_TARGET_MESSAGE);
-		    return false;
-		}
 		int position = 0;
 
 		if (target != null) {
@@ -71,6 +69,11 @@ public class FeatureNodeDropAdapter extends ViewerDropAdapter {
 			}
 		}
 
+        if(target==null){
+            MessagingUtils.warningDialog(Messages.FeatureNodeDropAdapter_INVALID_TARGET, this, Messages.FeatureNodeDropAdapter_INVALID_TARGET_MESSAGE);
+            return false;
+        }
+
 		Collection<Object> droppedObjects = Collections.emptyList();
 		if(data instanceof Object[]){
 		    droppedObjects = Arrays.asList((Object[])data);
@@ -98,9 +101,14 @@ public class FeatureNodeDropAdapter extends ViewerDropAdapter {
 		    }
 		    else if(droppedObject instanceof OntologyTermWrapper){
 		        OntologyTermWrapper wrapper = (OntologyTermWrapper)droppedObject;
-		        Feature feature = Feature.NewInstance(wrapper.getLabel(), wrapper.getLabel(), wrapper.getLabel());
-		        feature.setUri(URI.create(wrapper.getUri()));
-		        CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(target, feature);
+		        TermVocabulary vocabulary = TermVocabularySelectionDialog.select(
+		                "Choose vocabulary for import", viewer.getControl().getShell(), null);
+		        if(vocabulary!=null){
+		            Feature feature = Feature.NewInstance(wrapper.getLabel(), wrapper.getLabel(), wrapper.getLabel());
+		            feature.setUri(URI.create(wrapper.getUri()));
+		            vocabulary.addTerm(feature);
+		            CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(target, feature);
+		        }
 		    }
 		}
 		dirtyable.setDirty(true);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
new file mode 100644
index 000000000..d2e195fdf
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
@@ -0,0 +1,86 @@
+/**
+* Copyright (C) 2007 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.ui.dialog.selection;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @since Jun 1, 2018
+ *
+ */
+public class TermVocabularySelectionDialog extends
+		AbstractFilteredCdmResourceSelectionDialog<TermVocabulary> {
+
+    public static TermVocabulary select(String dialogTitle, Shell shell, TermVocabulary voc){
+        return select_internal(dialogTitle, shell, voc);
+    }
+
+    public static TermVocabulary select(Shell shell, TermVocabulary voc){
+        return select_internal("Choose Vocabulary", shell, voc);
+    }
+
+	private static TermVocabulary select_internal(String dialogTitle, Shell shell, TermVocabulary voc){
+		TermVocabularySelectionDialog dialog = new TermVocabularySelectionDialog(shell,
+				dialogTitle!=null?dialogTitle:"Choose Vocabulary",
+				false,
+				TermVocabularySelectionDialog.class.getCanonicalName(),
+				voc);
+		return getSelectionFromDialog(dialog);
+	}
+
+	protected TermVocabularySelectionDialog(Shell shell,
+			 String title, boolean multi,
+			String settings, TermVocabulary cdmObject) {
+		super(shell, title, multi, settings, cdmObject);
+	}
+
+	@Override
+	protected TermVocabulary getPersistentObject(UUID uuid) {
+		return CdmStore.getService(IVocabularyService.class).load(uuid);
+	}
+
+	@Override
+	protected void callService(String pattern) {
+		List<TermVocabulary> vocabularies = CdmStore.getService(IVocabularyService.class).list(TermVocabulary.class, null, null, null, null);
+
+		List<UuidAndTitleCache<TermVocabulary>> featureUuidAndTitleCache = new ArrayList<>();
+
+		for(TermVocabulary voc : vocabularies){
+			UuidAndTitleCache<TermVocabulary> uuidAndTitleCache = new UuidAndTitleCache<>(TermVocabulary.class, voc.getUuid(), voc.getId(), voc.getTitleCache());
+			if (pattern == null || uuidAndTitleCache.getTitleCache().matches("(?i)"+pattern + ".*")) {
+                featureUuidAndTitleCache.add(uuidAndTitleCache);
+            }
+		}
+		model =  featureUuidAndTitleCache;
+	}
+
+	@Override
+	protected String[] getNewWizardText() {
+		return null;
+	}
+
+	@Override
+	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
+		return null;
+	}
+
+}
