import jalview.datamodel.SequenceI;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
+ import jalview.gui.JvOptionPane;
import jalview.gui.OOMWarning;
import jalview.gui.UserDefinedColours;
+import jalview.io.DataSourceType;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.schemes.BuriedColourScheme;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
++import java.io.FileWriter;
++import java.io.IOException;
++import java.io.PrintWriter;
import javax.swing.JMenuItem;
- import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
{
try
{
-- java.io.PrintWriter out = new java.io.PrintWriter(
-- new java.io.FileWriter(chooser.getSelectedFile()));
++ PrintWriter out = new PrintWriter(new FileWriter(
++ chooser.getSelectedFile()));
out.print(getText());
out.close();
// TODO: identify feature, annotation or tree file and parse appropriately.
AlignmentI al = null;
- if (FormatAdapter.isValidFormat(format))
+ try
{
- try
- {
- FormatAdapter fa = new FormatAdapter(alignpanel);
- al = fa.readFile(getText(), "Paste", format);
- source = fa.getAlignFile();
+ FormatAdapter fa = new FormatAdapter(alignpanel);
+ al = fa.readFile(getText(), DataSourceType.PASTE, format);
+ source = fa.getAlignFile();
- } catch (java.io.IOException ex)
- } catch (java.io.IOException ex)
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.couldnt_read_pasted_text",
- new String[] { ex.toString() }), MessageManager
- .getString("label.error_parsing_text"),
- JvOptionPane.WARNING_MESSAGE);
- }
++ } catch (IOException ex)
+ {
- JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
++ JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage("label.couldnt_read_pasted_text", new String[]
+ { ex.toString() }), MessageManager
+ .getString("label.error_parsing_text"),
- JOptionPane.WARNING_MESSAGE);
++ JvOptionPane.WARNING_MESSAGE);
}
if (al != null && al.hasValidSequence())
}
else
{
- String format = new IdentifyFile().identify(url, FormatAdapter.URL);
+ FileFormatI format = null;
+ try
+ {
+ format = new IdentifyFile().identify(url, DataSourceType.URL);
+ } catch (FileFormatException e)
+ {
+ // TODO revise error handling, distinguish between
+ // URL not found and response not valid
+ }
- if (format.equals("URL NOT FOUND"))
+ if (format == null)
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
MessageManager.formatMessage("label.couldnt_locate",
new Object[] { url }), MessageManager
.getString("label.url_not_found"),
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.api.SplitContainerI;
import jalview.bin.Cache;
+ import jalview.gui.JvOptionPane;
import jalview.gui.JvSwingUtils;
import jalview.gui.Preferences;
+import jalview.io.FileFormat;
import jalview.schemes.ColourSchemeProperty;
import jalview.util.MessageManager;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.structure.StructureImportSettings;
import java.io.IOException;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import java.io.IOException;
import java.util.ArrayList;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import jalview.util.MapList;
import jalview.util.MappingUtils;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import java.io.IOException;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.util.List;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.util.Arrays;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.util.Arrays;
import java.util.BitSet;
import static org.testng.AssertJUnit.assertNull;
import jalview.analysis.AlignSeq;
+ import jalview.gui.JvOptionPane;
import jalview.io.AppletFormatAdapter;
+import jalview.io.FileFormat;
+ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AlignmentAnnotationTests
import static org.testng.AssertJUnit.assertTrue;
import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import jalview.util.MapList;
import jalview.datamodel.Alignment;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.FastaFile;
import jalview.io.FileParse;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import jalview.structure.StructureImportSettings;
import jalview.structure.StructureImportSettings.StructureParser;
package jalview.ext.jmol;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import java.io.File;
import java.io.IOException;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FastaFile;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+ import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
*/
package jalview.io;
-import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+ import jalview.gui.JvOptionPane;
+
import org.testng.Assert;
+ import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class IdentifyFileTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
@Test(groups = { "Functional" }, dataProvider = "identifyFiles")
- public void testIdentify(String data, String expectedFileType)
+ public void testIdentify(String data, FileFormatI expectedFileType)
+ throws FileFormatException
{
- String protocol = AppletFormatAdapter.FILE;
+ DataSourceType protocol = DataSourceType.FILE;
IdentifyFile ider = new IdentifyFile();
- String actualFiletype = ider.identify(data, protocol);
- Assert.assertEquals(actualFiletype, expectedFileType,
+ FileFormatI actualFiletype = ider.identify(data, protocol);
+ Assert.assertSame(actualFiletype, expectedFileType,
"File identification Failed!");
}
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.io.IOException;
import java.util.ArrayList;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.util.List;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+ import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import jalview.io.StructureFile;
import org.testng.Assert;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.FormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.util.MapList;
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.structure.AtomSpec;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel.SuperposeData;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import java.awt.Color;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+ import jalview.gui.JvOptionPane;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.AADisorderClient;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.gui.Jalview2XML;
+ import jalview.gui.JvOptionPane;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.JPred301Client;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.gui.Jalview2XML;
+ import jalview.gui.JvOptionPane;
import jalview.io.AnnotationFile;
-import jalview.io.FileLoader;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+ import jalview.gui.JvOptionPane;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.structure.StructureMapping;
import jalview.xml.binding.sifts.Entry.Entity;