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
.editor
.e4
.handler
;
13 import java
.io
.IOException
;
15 import javax
.inject
.Named
;
17 import org
.biojava
.bio
.chromatogram
.UnsupportedChromatogramFormatException
;
18 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
19 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
20 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
21 import org
.eclipse
.swt
.widgets
.FileDialog
;
22 import org
.eclipse
.swt
.widgets
.Shell
;
24 import eu
.etaxonomy
.cdm
.common
.URI
;
25 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
26 import eu
.etaxonomy
.taxeditor
.molecular
.TaxeditorMolecularPlugin
;
27 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.e4
.AlignmentEditorE4
;
28 import eu
.etaxonomy
.taxeditor
.molecular
.l10n
.Messages
;
33 * Handler that loads an additional read into the contig alignment displayed by an instance of {@link AlignmentEditorE4}.
38 public class LoadPherogramHandlerE4
{
39 //TODO Change so that also URIs which do not point to files can be specified.
42 public void execute(@Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
43 @Named(IServiceConstants
.ACTIVE_SHELL
)Shell shell
) {
44 AlignmentEditorE4 alignmentEditor
= (AlignmentEditorE4
) activePart
.getObject();
46 FileDialog fileDialog
= new FileDialog(shell
);
47 fileDialog
.setText(Messages
.LoadPherogramHandler_IMPORT_PHEROGRAM
);
48 fileDialog
.setFilterNames(new String
[]{Messages
.LoadPherogramHandler_ALL_FORMATS
, Messages
.LoadPherogramHandler_AB1
, Messages
.LoadPherogramHandler_SCF
, Messages
.LoadPherogramHandler_ALL
});
49 fileDialog
.setFilterExtensions(new String
[]{"*.ab1;*.scf", "*.ab1", "*.scf", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
51 String path
= fileDialog
.open();
54 alignmentEditor
.addRead(URI
.fromFile(new File(path
)), false);
56 catch (UnsupportedChromatogramFormatException e
) {
57 MessagingUtils
.errorDialog(Messages
.LoadPherogramHandler_UNSUPPORTED_FORMAT
, this,
58 String
.format(Messages
.LoadPherogramHandler_UNSUPPORTED_FORMAT_MESSAGE
, path
), TaxeditorMolecularPlugin
.PLUGIN_ID
, e
, false); //TODO set pluginID
60 catch (IOException e
) {
61 MessagingUtils
.errorDialog(Messages
.LoadPherogramHandler_UNSUPPORTED_FORMAT_FILE
, this,
62 Messages
.LoadPherogramHandler_UNSUPPORTED_FORMAT_FILE_MESSAGE
+ path
,
63 TaxeditorMolecularPlugin
.PLUGIN_ID
, e
, false); //TODO set pluginID