X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjavascript%2FMouseOverStructureListener.java;h=9104ac14e1cff0a368b25fe95219e82fa89560b9;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=176c881b36707e37de04529640852f44651a9fba;hpb=15335b83310784537f6c1b9c20d2c1ea2f57bcfc;p=jalview.git diff --git a/src/jalview/javascript/MouseOverStructureListener.java b/src/jalview/javascript/MouseOverStructureListener.java index 176c881..9104ac1 100644 --- a/src/jalview/javascript/MouseOverStructureListener.java +++ b/src/jalview/javascript/MouseOverStructureListener.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -32,10 +32,8 @@ import jalview.structure.StructureListener; import jalview.structure.StructureMapping; import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; +import jalview.util.HttpUtils; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -105,7 +103,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements public String resolveModelFile(String file) { // TODO reuse JalviewLite.LoadingThread.addProtocol instead - if (isValidUrl(file)) + if (HttpUtils.isValidUrl(file)) { return file; } @@ -113,13 +111,13 @@ public class MouseOverStructureListener extends JSFunctionExec implements String db = jvlite.getDocumentBase().toString(); db = db.substring(0, db.lastIndexOf("/")); String docBaseFile = db + "/" + file; - if (isValidUrl(docBaseFile)) + if (HttpUtils.isValidUrl(docBaseFile)) { return docBaseFile; } String cb = jvlite.getCodeBase() + file; - if (isValidUrl(cb)) + if (HttpUtils.isValidUrl(cb)) { return cb; } @@ -127,43 +125,6 @@ public class MouseOverStructureListener extends JSFunctionExec implements return file; } - /** - * Returns true if it is possible to open an input stream at the given URL, - * else false. The input stream is closed. - * - * @param file - * @return - */ - private boolean isValidUrl(String file) - { - InputStream is = null; - try - { - is = new URL(file).openStream(); - if (is != null) - { - return true; - } - } catch (IOException x) - { - // MalformedURLException, FileNotFoundException - return false; - } finally - { - if (is != null) - { - try - { - is.close(); - } catch (IOException e) - { - // ignore - } - } - } - return false; - } - @Override public String[] getPdbFile() {