--- /dev/null
+/**
+* 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.molecular.editor.e4.handler;
+
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.inject.Named;
+
+import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
+import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
+import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
+import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
+
+
+
+/**
+ * Handler that loads an additional read into the contig alignment displayed by an instance of {@link AlignmentEditor}.
+ *
+ * @author Ben Stöver
+ * @author pplitzner
+ */
+public class LoadPherogramHandlerE4 {
+ //TODO Change so that also URIs which do not point to files can be specified.
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+ AlignmentEditorE4 alignmentEditor = (AlignmentEditorE4) activePart.getObject();
+
+ FileDialog fileDialog = new FileDialog(shell);
+ fileDialog.setText(Messages.LoadPherogramHandler_IMPORT_PHEROGRAM);
+ fileDialog.setFilterNames(new String[]{Messages.LoadPherogramHandler_ALL_FORMATS, Messages.LoadPherogramHandler_AB1, Messages.LoadPherogramHandler_SCF, Messages.LoadPherogramHandler_ALL});
+ fileDialog.setFilterExtensions(new String[]{"*.ab1;*.scf", "*.ab1", "*.scf", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ String path = fileDialog.open();
+ if (path != null) {
+ try {
+ alignmentEditor.addRead(new File(path).toURI(), false);
+ }
+ catch (UnsupportedChromatogramFormatException e) {
+ MessagingUtils.errorDialog(Messages.LoadPherogramHandler_UNSUPPORTED_FORMAT, this,
+ String.format(Messages.LoadPherogramHandler_UNSUPPORTED_FORMAT_MESSAGE, path), TaxeditorMolecularPlugin.PLUGIN_ID, e, false); //TODO set pluginID
+ }
+ catch (IOException e) {
+ MessagingUtils.errorDialog(Messages.LoadPherogramHandler_UNSUPPORTED_FORMAT_FILE, this,
+ Messages.LoadPherogramHandler_UNSUPPORTED_FORMAT_FILE_MESSAGE + path,
+ TaxeditorMolecularPlugin.PLUGIN_ID, e, false); //TODO set pluginID
+ }
+ }
+ }
+}