X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAppletFormatAdapter.java;h=e9c9ce2a7b4a7dd86045e5db71ca4ad5bbfd4c9c;hb=41b0e9331ac71787c1280aa1d809f54c575fbf97;hp=bc2465a8023da9a86f9ee163fe1e5adc56abb9cc;hpb=5969ead0fd401f4435a3435ede9e4e87cf9c1d0b;p=jalview.git diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index bc2465a..e9c9ce2 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -20,7 +20,9 @@ */ package jalview.io; -import jalview.api.AlignExportSettingI; +import java.util.Locale; + +import jalview.api.AlignExportSettingsI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; @@ -30,6 +32,7 @@ import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JmolParser; import jalview.structure.StructureImportSettings; +import jalview.util.Platform; import java.io.File; import java.io.IOException; @@ -73,7 +76,7 @@ public class AppletFormatAdapter */ protected String newline = System.getProperty("line.separator"); - private AlignExportSettingI exportSettings; + private AlignExportSettingsI exportSettings; private File selectedFile; @@ -100,7 +103,7 @@ public class AppletFormatAdapter } public AppletFormatAdapter(AlignmentViewPanel alignPanel, - AlignExportSettingI settings) + AlignExportSettingsI settings) { viewpanel = alignPanel; exportSettings = settings; @@ -158,7 +161,9 @@ public class AppletFormatAdapter this.selectedFile = selectedFile; if (selectedFile != null) + { this.inFile = selectedFile.getPath(); + } this.inFile = file; try { @@ -174,13 +179,13 @@ public class AppletFormatAdapter if (isParseWithJMOL) { // needs a File option - alignFile = new JmolParser(inFile, sourceType); + alignFile = new JmolParser(selectedFile == null ? inFile : selectedFile, sourceType); } else { - // todo is MCview parsing obsolete yet? JAL-2120 + // todo is mc_view parsing obsolete yet? JAL-2120 StructureImportSettings.setShowSeqFeatures(true); - alignFile = new MCview.PDBfile(annotFromStructure, + alignFile = new mc_view.PDBfile(annotFromStructure, localSecondaryStruct, serviceSecondaryStruct, inFile, sourceType); } @@ -265,7 +270,7 @@ public class AppletFormatAdapter else { StructureImportSettings.setShowSeqFeatures(true); - alignFile = new MCview.PDBfile(annotFromStructure, + alignFile = new mc_view.PDBfile(annotFromStructure, localSecondaryStruct, serviceSecondaryStruct, source); } ((StructureFile) alignFile).setDbRefType(Type.PDB); @@ -421,23 +426,32 @@ public class AppletFormatAdapter return null; } + /** * Determines the protocol (i.e DataSourceType.{FILE|PASTE|URL}) for the input * data + * + * BH 2018 allows File or String, and can return RELATIVE_URL * - * @param data + * @param dataObject File or String * @return the protocol for the input data */ - public static DataSourceType checkProtocol(String data) + public static DataSourceType checkProtocol(Object dataObject) { + if(dataObject instanceof File) + { + return DataSourceType.FILE; + } + + String data = dataObject.toString(); DataSourceType protocol = DataSourceType.PASTE; - String ft = data.toLowerCase().trim(); + String ft = data.toLowerCase(Locale.ROOT).trim(); if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0 || ft.indexOf("file:") == 0) { protocol = DataSourceType.URL; } - else if (jalview.bin.Jalview.isJS) + else if (Platform.isJS()) { protocol = DataSourceType.RELATIVE_URL; } @@ -448,6 +462,10 @@ public class AppletFormatAdapter return protocol; } + /** + * @param args + * @j2sIgnore + */ public static void main(String[] args) { int i = 0;