2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.molecular
.handler
;
13 import java
.io
.IOException
;
15 import org
.biojava
.bio
.chromatogram
.UnsupportedChromatogramFormatException
;
16 import org
.eclipse
.core
.commands
.AbstractHandler
;
17 import org
.eclipse
.core
.commands
.ExecutionEvent
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.swt
.widgets
.FileDialog
;
20 import org
.eclipse
.ui
.IEditorPart
;
22 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
23 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
24 import eu
.etaxonomy
.taxeditor
.molecular
.TaxeditorMolecularPlugin
;
25 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditor
;
30 * Handler that loads an additional read into the contig alignment displayed by an instance of {@link AlignmentEditor}.
35 public class LoadPherogramHandler
extends AbstractHandler
{
36 //TODO Change so that also URIs which do not point to files can be specified.
39 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
42 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
43 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
44 if (activeEditor
instanceof AlignmentEditor
) {
45 AlignmentEditor alignmentEditor
= (AlignmentEditor
)activeEditor
;
47 FileDialog fileDialog
= new FileDialog(alignmentEditor
.getSite().getShell());
48 fileDialog
.setText("Import pherogram into contig alignment");
49 fileDialog
.setFilterNames(new String
[]{"All supported formats", "AB1 pherogram files", "SCF pherogram files", "All files"});
50 fileDialog
.setFilterExtensions(new String
[]{"*.ab1;*.scf", "*.ab1", "*.scf", "*.*"});
52 String path
= fileDialog
.open();
55 alignmentEditor
.addRead(new File(path
).toURI(), false);
57 catch (UnsupportedChromatogramFormatException e
) {
58 MessagingUtils
.errorDialog("Unsupported format", this, "The format of the pherogram file \"" + path
+
59 "\" is not supported. (Only AB1 and SCF are supported.)", TaxeditorMolecularPlugin
.PLUGIN_ID
, e
, false); //TODO set pluginID
61 catch (IOException e
) {
62 MessagingUtils
.errorDialog("Unsupported format", this,
63 "An IO error occurred while trying to read the file \"" + path
+ "\".",
64 TaxeditorMolecularPlugin
.PLUGIN_ID
, e
, false); //TODO set pluginID