commit bcb823d549bac3d3d764afbcfdaa38da5c7063ea
Author: b.stoever <stoever@bioinfweb.info>
Date:   Mon Nov 14 19:34:40 2016 +0100

    Missing dependency Apache commons.lang added to molecular.lib.
    Single read alignment export feature now makes use of wizard. (Selecting which sequences to export is not yet supported.)

diff --git a/eu.etaxonomy.taxeditor.molecular.lib/.classpath b/eu.etaxonomy.taxeditor.molecular.lib/.classpath
index 42448a1f3..1a0a9d05b 100644
--- a/eu.etaxonomy.taxeditor.molecular.lib/.classpath
+++ b/eu.etaxonomy.taxeditor.molecular.lib/.classpath
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.5.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry exported="true" kind="lib" path="lib/owlapi-xmlutils-4.1.4.jar"/>
@@ -12,7 +13,7 @@
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.commons.swt/bin"/>
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.tic.core/bin"/>
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.tic.swt/bin"/>
-	<classpathentry exported="true" kind="lib" path="lib/JPhyloIO/bin" sourcepath="lib/JPhyloIO/bin"/>
+	<classpathentry exported="true" kind="lib" path="lib/JPhyloIO/bin" sourcepath="/JPhyloIO/src"/>
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.core/bin"/>
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.io/bin"/>
 	<classpathentry exported="true" kind="lib" path="lib/info.bioinfweb.libralign.swt/bin"/>
diff --git a/eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF
index c4412bdd3..fe5ddeee3 100644
--- a/eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF
+++ b/eu.etaxonomy.taxeditor.molecular.lib/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@ Bundle-ClassPath: .,
  lib/info.bioinfweb.libralign.core/bin/,
  lib/info.bioinfweb.libralign.io/bin/,
  lib/info.bioinfweb.libralign.swt/bin/,
- lib/info.bioinfweb.libralign.biojava1/bin/
+ lib/info.bioinfweb.libralign.biojava1/bin/,
+ lib/commons-lang3-3.5.jar
 Export-Package: info.bioinfweb.commons,
  info.bioinfweb.commons.appversion,
  info.bioinfweb.commons.beans,
@@ -37,8 +38,8 @@ Export-Package: info.bioinfweb.commons,
  info.bioinfweb.jphyloio,
  info.bioinfweb.jphyloio.dataadapters,
  info.bioinfweb.jphyloio.dataadapters.implementations,
- info.bioinfweb.jphyloio.dataadapters.implementations.store,
  info.bioinfweb.jphyloio.dataadapters.implementations.receivers,
+ info.bioinfweb.jphyloio.dataadapters.implementations.store,
  info.bioinfweb.jphyloio.events,
  info.bioinfweb.jphyloio.events.meta,
  info.bioinfweb.jphyloio.events.type,
@@ -65,9 +66,9 @@ Export-Package: info.bioinfweb.commons,
  info.bioinfweb.jphyloio.formats.text,
  info.bioinfweb.jphyloio.formats.xml,
  info.bioinfweb.jphyloio.formats.xtg,
- info.bioinfweb.jphyloio.utils,
  info.bioinfweb.jphyloio.objecttranslation,
  info.bioinfweb.jphyloio.objecttranslation.implementations,
+ info.bioinfweb.jphyloio.utils,
  info.bioinfweb.libralign,
  info.bioinfweb.libralign.actions,
  info.bioinfweb.libralign.alignmentarea,
@@ -130,6 +131,18 @@ Export-Package: info.bioinfweb.commons,
  org.apache.commons.collections4.splitmap,
  org.apache.commons.collections4.trie,
  org.apache.commons.collections4.trie.analyzer,
+ org.apache.commons.lang3,
+ org.apache.commons.lang3.builder,
+ org.apache.commons.lang3.concurrent,
+ org.apache.commons.lang3.event,
+ org.apache.commons.lang3.exception,
+ org.apache.commons.lang3.math,
+ org.apache.commons.lang3.mutable,
+ org.apache.commons.lang3.reflect,
+ org.apache.commons.lang3.text,
+ org.apache.commons.lang3.text.translate,
+ org.apache.commons.lang3.time,
+ org.apache.commons.lang3.tuple,
  org.biojava.bibliography,
  org.biojava.bio,
  org.biojava.bio.alignment,
diff --git a/eu.etaxonomy.taxeditor.molecular.lib/build.properties b/eu.etaxonomy.taxeditor.molecular.lib/build.properties
index 4cd6b0385..9cf63ec4f 100644
--- a/eu.etaxonomy.taxeditor.molecular.lib/build.properties
+++ b/eu.etaxonomy.taxeditor.molecular.lib/build.properties
@@ -13,6 +13,7 @@ bin.includes = META-INF/,\
                lib/info.bioinfweb.tic.core/bin/,\
                lib/info.bioinfweb.tic.swt/bin/,\
                lib/JPhyloIO/bin/,\
-               lib/info.bioinfweb.libralign.biojava1/bin/
+               lib/info.bioinfweb.libralign.biojava1/bin/,\
+               lib/commons-lang3-3.5.jar
                lib/jphyloio-core-0-SNAPSHOT.jar,\
                lib/owlapi-xmlutils-4.1.4.jar
diff --git a/eu.etaxonomy.taxeditor.molecular.lib/pom.xml b/eu.etaxonomy.taxeditor.molecular.lib/pom.xml
index 3458f1c6f..0b8be0240 100644
--- a/eu.etaxonomy.taxeditor.molecular.lib/pom.xml
+++ b/eu.etaxonomy.taxeditor.molecular.lib/pom.xml
@@ -28,7 +28,8 @@
                 bioinfweb-commons-swt, bioinfweb-commons-core,
                 bioinfweb-commons-bio, bioinfweb-commons-swing,
                 tic-core, libralign-biojava1, core, sequencing, 
-                tic-swt, jphyloio-core, owlapi-xmlutils, commons-collections4</includeArtifactIds>
+                tic-swt, jphyloio-core, owlapi-xmlutils, 
+                commons-lang3, commons-collections4</includeArtifactIds>
               <outputDirectory>lib</outputDirectory>
               <overWriteReleases>true</overWriteReleases>
               <overWriteSnapshots>true</overWriteSnapshots>
@@ -179,6 +180,11 @@
       <version>1.9.2</version>
     </dependency>
     <!-- Apache commons -->
+    <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-lang3</artifactId>
+        <version>3.5</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-collections4</artifactId>
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
index 8e3aa3e26..41bed7e08 100644
--- a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
+++ b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
@@ -15,17 +15,17 @@ import info.bioinfweb.jphyloio.ReadWriteParameterMap;
 import info.bioinfweb.jphyloio.ReadWriteParameterNames;
 import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;
 import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
-import info.bioinfweb.jphyloio.formats.JPhyloIOFormatIDs;
 import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;
 
-import java.io.File;
 import java.io.IOException;
 
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.model.molecular.Sequence;
@@ -35,6 +35,7 @@ import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
 import eu.etaxonomy.taxeditor.molecular.io.CDMPherogramAlignmentObjectTranslator;
 import eu.etaxonomy.taxeditor.molecular.io.CDMSequenceMatrixAdapter;
 import eu.etaxonomy.taxeditor.molecular.io.SingleReadAlignmentRDFXMLConstants;
+import eu.etaxonomy.taxeditor.molecular.io.wizard.ExportSingleReadAlignmentWizard;
 
 
 
@@ -56,31 +57,32 @@ public class ExportSequenceToFileHandler extends AbstractHandler {
         if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence) {
             Sequence sequence = (Sequence)treeNodeOfSelection.getValue();
 
-            //TODO Collect the following information using a wizard.
-            File targetFile = new File("O:\\Projects\\Bereich BBI\\EDIT Campanula\\Testdaten\\NeXMLExport.xml");
-            String formatID = JPhyloIOFormatIDs.NEXML_FORMAT_ID;
+            final ExportSingleReadAlignmentWizard wizard = new ExportSingleReadAlignmentWizard();
+            final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+            if (dialog.open() == IStatus.OK) {  //TODO Is the window disposed?
+                // Prepare writer parameters:
+                ReadWriteParameterMap parameters = new ReadWriteParameterMap();
+                ObjectTranslatorFactory translatorFactory = new ObjectTranslatorFactory();
+                translatorFactory.addXSDTranslators(true);
+                translatorFactory.addTranslator(new CDMPherogramAlignmentObjectTranslator(), true, SingleReadAlignmentRDFXMLConstants.DATA_TYPE_PHERORAGM_ALIGNMENT);
+                parameters.put(ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY, translatorFactory);
 
-            ReadWriteParameterMap parameters = new ReadWriteParameterMap();
-            ObjectTranslatorFactory translatorFactory = new ObjectTranslatorFactory();
-            translatorFactory.addXSDTranslators(true);
-            translatorFactory.addTranslator(new CDMPherogramAlignmentObjectTranslator(), true, SingleReadAlignmentRDFXMLConstants.DATA_TYPE_PHERORAGM_ALIGNMENT);
-            parameters.put(ReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORY, translatorFactory);
+                // Create writer and document adapters:
+                JPhyloIOEventWriter writer = factory.getWriter(wizard.getSelectedFormat());
+                ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter();
+                document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, wizard.getConsensusSequenceLabel()));
 
-            String consensusSequenceLabel = "Consensus sequence";
-            JPhyloIOEventWriter writer = factory.getWriter(formatID);
-
-            ListBasedDocumentDataAdapter document = new ListBasedDocumentDataAdapter();
-            document.getMatrices().add(new CDMSequenceMatrixAdapter(sequence, consensusSequenceLabel));
-
-            try {
-                writer.writeDocument(document, targetFile, parameters);
-            }
-            catch (IOException e) {
-                e.printStackTrace();
-                MessagingUtils.errorDialog("IO error", this,
-                        "An error occured when trying to export a consensus sequence alignment to the file \"" +
-                        targetFile.getAbsolutePath() + "\".", TaxeditorMolecularPlugin.PLUGIN_ID, e, false);  //TODO set pluginID
-                        //TODO Use multi language error message.
+                // Write document:
+                try {
+                    writer.writeDocument(document, wizard.getSelectedFile(), parameters);
+                }
+                catch (IOException e) {
+                    e.printStackTrace();
+                    MessagingUtils.errorDialog("IO error", this,
+                            "An error occured when trying to export a consensus sequence alignment to the file \"" +
+                            wizard.getSelectedFile().getAbsolutePath() + "\".", TaxeditorMolecularPlugin.PLUGIN_ID, e, false);  //TODO set pluginID
+                            //TODO Use multi language error message.
+                }
             }
         }
         return null;
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java
index 8f9c1c284..bc66be939 100644
--- a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java
+++ b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizard.java
@@ -10,6 +10,8 @@
 package eu.etaxonomy.taxeditor.molecular.io.wizard;
 
 
+import java.io.File;
+
 import org.eclipse.jface.wizard.Wizard;
 
 
@@ -21,6 +23,13 @@ import org.eclipse.jface.wizard.Wizard;
  * @date 23.06.2016
  */
 public class ExportSingleReadAlignmentWizard extends Wizard {
+    private ExportSingleReadAlignmentWizardPage page;
+
+    private String selectedFormat = null;
+    private File selectedFile = null;
+    private String consensusSequenceLabel = null;
+
+
     public ExportSingleReadAlignmentWizard() {
         setWindowTitle("Export single read alignment");  //TODO Use multi languange message
     }
@@ -28,12 +37,36 @@ public class ExportSingleReadAlignmentWizard extends Wizard {
 
     @Override
     public void addPages() {
-        addPage(new ExportSingleReadAlignmentWizardPage());
+        page = new ExportSingleReadAlignmentWizardPage();
+        addPage(page);
     }
 
 
     @Override
     public boolean performFinish() {
-        return true;  //TODO Check inputs
+        if (!page.getConsensusSequenceLabel().isEmpty()) {
+            selectedFormat = page.getSelectedFormat();
+            selectedFile = page.getSelectedFile();
+            consensusSequenceLabel = page.getConsensusSequenceLabel();
+            return true;
+        }
+        else {
+            return false;  //TODO Display according error message in wizard heading, as long as valid inputs are not completed.
+        }
+    }
+
+
+    public String getSelectedFormat() {
+        return selectedFormat;
+    }
+
+
+    public File getSelectedFile() {
+        return selectedFile;
+    }
+
+
+    public String getConsensusSequenceLabel() {
+        return consensusSequenceLabel;
     }
 }
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java
index 8213d4f8b..3b6405f22 100644
--- a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java
+++ b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/io/wizard/ExportSingleReadAlignmentWizardPage.java
@@ -14,6 +14,7 @@ import info.bioinfweb.jphyloio.events.type.EventContentType;
 import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
 import info.bioinfweb.jphyloio.formatinfo.JPhyloIOFormatInfo;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -158,7 +159,7 @@ public class ExportSingleReadAlignmentWizardPage extends WizardPage {
         btnBrowse.setLayoutData(fd_btnBrowse);
         btnBrowse.setText("Browse...");
 
-        formatComboBox = new Combo(container, SWT.NONE);
+        formatComboBox = new Combo(container, SWT.READ_ONLY);
         for (JPhyloIOFormatInfo formatInfo : FORMATS) {
             formatComboBox.add(formatInfo.getFormatName());
         }
@@ -168,6 +169,7 @@ public class ExportSingleReadAlignmentWizardPage extends WizardPage {
         fd_formatComboBox.top = new FormAttachment(lblFormat, 6);
         fd_formatComboBox.left = new FormAttachment(exportSingleReadsCB, 0, SWT.LEFT);
         formatComboBox.setLayoutData(fd_formatComboBox);
+        formatComboBox.select(0);
     }
 
 
@@ -180,9 +182,29 @@ public class ExportSingleReadAlignmentWizardPage extends WizardPage {
         if (formatComboBox != null) {
             int index = formatComboBox.getSelectionIndex();
             if (index > -1) {
-                FORMATS.get(index).getFormatID();
+                return FORMATS.get(index).getFormatID();
             }
         }
         return null;
     }
+
+
+    public File getSelectedFile() {
+        if (fileTextField !=  null) {
+            return new File(fileTextField.getText());
+        }
+        else {
+            return null;
+        }
+    }
+
+
+    public String getConsensusSequenceLabel() {
+        if (consensusSequenceNameTextField != null) {
+            return consensusSequenceNameTextField.getText();
+        }
+        else {
+            return null;
+        }
+    }
 }
