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
.editor
.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
.editor
.molecular
.AlignmentEditor
;
23 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
24 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
29 * Handler that loads an additional read into the contig alignment displayed by an instance of {@link AlignmentEditor}.
34 public class LoadPherogramHandler
extends AbstractHandler
{
35 //TODO Change so that also URIs which do not point to files can be specified.
38 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
41 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
42 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
43 if (activeEditor
instanceof AlignmentEditor
) {
44 AlignmentEditor alignmentEditor
= (AlignmentEditor
)activeEditor
;
46 FileDialog fileDialog
= new FileDialog(alignmentEditor
.getSite().getShell());
47 fileDialog
.setText("Import pherogram into contig alignment");
48 fileDialog
.setFilterNames(new String
[]{"All supported formats", "AB1 pherogram files", "SCF pherogram files", "All files"});
49 fileDialog
.setFilterExtensions(new String
[]{"*.ab1;*.scf", "*.ab1", "*.scf", "*.*"});
51 String path
= fileDialog
.open();
54 alignmentEditor
.addRead(new File(path
).toURI(), false);
56 catch (UnsupportedChromatogramFormatException e
) {
57 MessagingUtils
.errorDialog("Unsupported format", this, "The format of the pherogram file \"" + path
+
58 "\" is not supported. (Only AB1 and SCF are supported.)", "eu.etaxonomy.taxeditor.editor", e
, false); //TODO set pluginID
60 catch (IOException e
) {
61 MessagingUtils
.errorDialog("Unsupported format", this,
62 "An IO error occurred while trying to read the file \"" + path
+ "\".",
63 "/eu.etaxonomy.taxeditor.editor", e
, false); //TODO set pluginID