JAL-2344 use ".cif" for saved mmCIF file (and refactor fetch as file)
[jalview.git] / src / MCview / PDBViewer.java
index a49d6a0..f108fc2 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -24,8 +24,10 @@ import jalview.datamodel.PDBEntry;
 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;
@@ -60,7 +62,6 @@ import javax.swing.JInternalFrame;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
 import javax.swing.JRadioButtonMenuItem;
 
 public class PDBViewer extends JInternalFrame implements Runnable
@@ -79,12 +80,12 @@ public class PDBViewer extends JInternalFrame implements Runnable
 
   AlignmentPanel ap;
 
-  String protocol;
+  DataSourceType protocol;
 
   String tmpPDBFile;
 
   public PDBViewer(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
-          AlignmentPanel ap, String protocol)
+          AlignmentPanel ap, DataSourceType protocol)
   {
     this.pdbentry = pdbentry;
     this.seq = seq;
@@ -113,7 +114,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
       {
         tmpPDBFile = pdbentry.getFile();
         PDBfile pdbfile = new PDBfile(false, false, false, tmpPDBFile,
-                jalview.io.AppletFormatAdapter.FILE);
+                DataSourceType.FILE);
 
         pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
 
@@ -128,18 +129,17 @@ public class PDBViewer extends JInternalFrame implements Runnable
       worker.start();
     }
 
-    if (pdbentry.getProperty() != null)
+    String method = (String) pdbentry.getProperty("method");
+    if (method != null)
     {
-      if (pdbentry.getProperty().get("method") != null)
-      {
-        title.append(" Method: ");
-        title.append(pdbentry.getProperty().get("method"));
-      }
-      if (pdbentry.getProperty().get("chains") != null)
-      {
-        title.append(" Chain:");
-        title.append(pdbentry.getProperty().get("chains"));
-      }
+      title.append(" Method: ");
+      title.append(method);
+    }
+    String ch = (String) pdbentry.getProperty("chains");
+    if (ch != null)
+    {
+      title.append(" Chain:");
+      title.append(ch);
     }
     Desktop.addInternalFrame(this, title.toString(), 400, 400);
   }
@@ -151,7 +151,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
     {
       EBIFetchClient ebi = new EBIFetchClient();
       String query = "pdb:" + pdbentry.getId();
-      pdbentry.setFile(ebi.fetchDataAsFile(query, "default", ".xml")
+      pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "xml")
               .getAbsolutePath());
 
       if (pdbentry.getFile() != null)
@@ -437,13 +437,13 @@ public class PDBViewer extends JInternalFrame implements Runnable
           {
             radioItem.removeActionListener(radioItem.getActionListeners()[0]);
 
-            int option = JOptionPane.showInternalConfirmDialog(
+            int option = JvOptionPane.showInternalConfirmDialog(
                     jalview.gui.Desktop.desktop, MessageManager
                             .getString("label.remove_from_default_list"),
                     MessageManager
                             .getString("label.remove_user_defined_colour"),
-                    JOptionPane.YES_NO_OPTION);
-            if (option == JOptionPane.YES_OPTION)
+                    JvOptionPane.YES_NO_OPTION);
+            if (option == JvOptionPane.YES_OPTION)
             {
               jalview.gui.UserDefinedColours
                       .removeColourFromDefaults(radioItem.getText());