Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / gui / VamsasApplication.java
index 3bf7c24..fbca39d 100644 (file)
@@ -42,7 +42,6 @@ import java.io.IOException;
 import java.util.Hashtable;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
-import java.util.List;
 
 import javax.swing.JInternalFrame;
 
@@ -174,7 +173,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
           }
         } catch (InvalidSessionDocumentException e)
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
 
                   MessageManager.getString(
                           "label.vamsas_doc_couldnt_be_opened_as_new_session"),
@@ -265,8 +264,8 @@ public class VamsasApplication implements SelectionSource, VamsasSource
   {
     if (!inSession())
     {
-      throw new Error(MessageManager.getString(
-              "error.implementation_error_vamsas_operation_not_init"));
+      throw new Error(
+              "Implementation error! Vamsas Operations when client not initialised and connected");
     }
     addDocumentUpdateHandler();
     addStoreDocumentHandler();
@@ -352,8 +351,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
   {
     if (!inSession())
     {
-      throw new Error(MessageManager
-              .getString("error.jalview_no_connected_vamsas_session"));
+      throw new Error("Jalview not connected to Vamsas session");
     }
     Cache.log.info("Jalview disconnecting from the Vamsas Session.");
     try
@@ -456,7 +454,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
     VamsasAppDatastore vds = new VamsasAppDatastore(doc, vobj2jv, jv2vobj,
             baseProvEntry(), alRedoState);
     // wander through frames
-    JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+    JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
 
     if (frames == null)
     {
@@ -485,8 +483,8 @@ public class VamsasApplication implements SelectionSource, VamsasSource
               errorsDuringUpdate = true;
               Cache.log.error("Exception synchronizing " + af.getTitle()
                       + " "
-                      + (af.getViewport().viewName == null ? ""
-                              : " view " + af.getViewport().viewName)
+                      + (af.getViewport().getViewName() == null ? ""
+                              : " view " + af.getViewport().getViewName())
                       + " to document.", e);
               stored = false;
             }
@@ -661,7 +659,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
                   Cache.log.debug(
                           "Asking user if the vamsas session should be stored.");
                   int reply = JvOptionPane.showInternalConfirmDialog(
-                          Desktop.desktop,
+                          Desktop.getDesktopPane(),
                           "The current VAMSAS session has unsaved data - do you want to save it ?",
                           "VAMSAS Session Shutdown",
                           JvOptionPane.YES_NO_OPTION,
@@ -670,7 +668,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
                   if (reply == JvOptionPane.YES_OPTION)
                   {
                     Cache.log.debug("Prompting for vamsas store filename.");
-                    Desktop.instance.vamsasSave_actionPerformed(null);
+                    Desktop.getInstance().vamsasSave_actionPerformed(null);
                     Cache.log
                             .debug("Finished attempt at storing document.");
                   }
@@ -689,7 +687,8 @@ public class VamsasApplication implements SelectionSource, VamsasSource
 
   public void disableGui(boolean b)
   {
-    Desktop.instance.setVamsasUpdate(b);
+    // JAL-3311 TODO: remove this class!
+    // Desktop.getInstance().setVamsasUpdate(b);
   }
 
   Hashtable _backup_vobj2jv;
@@ -722,8 +721,8 @@ public class VamsasApplication implements SelectionSource, VamsasSource
         return;
       }
 
-      throw new Error(MessageManager.getString(
-              "error.implementation_error_cannot_recover_vamsas_object_mappings"));
+      throw new Error(
+              "IMPLEMENTATION ERROR: Cannot recover vamsas object mappings - no backup was made");
     }
     jv2vobj.clear();
     Iterator el = _backup_jv2vobj.entrySet().iterator();
@@ -764,7 +763,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource
       {
         final IPickManager pm = vclient.getPickManager();
         final StructureSelectionManager ssm = StructureSelectionManager
-                .getStructureSelectionManager(Desktop.instance);
+                .getStructureSelectionManager(Desktop.getInstance());
         final VamsasApplication me = this;
         pm.registerMessageHandler(new IMessageHandler()
         {
@@ -1075,15 +1074,15 @@ public class VamsasApplication implements SelectionSource, VamsasSource
                   }
                   else
                   {
-                    // int[] intervals = colsel.getVisibleContigs(
-                    // seqsel.getStartRes(), seqsel.getEndRes() + 1);
-                    List<int[]> intervals = hidden.getVisibleContigs(
-                            seqsel.getStartRes(), seqsel.getEndRes() + 1);
-                    for (int[] region : intervals)
+                    Iterator<int[]> intervals = hidden
+                            .getVisContigsIterator(seqsel.getStartRes(),
+                                    seqsel.getEndRes() + 1, false);
+                    while (intervals.hasNext())
                     {
+                      int[] region = intervals.next();
                       Seg s = new Seg();
-                      s.setStart(region[0] + 1); // vamsas indices begin at
-                      // 1, not zero.
+                      s.setStart(region[0] + 1); // vamsas indices begin at 1,
+                                                 // not zero.
                       s.setEnd(region[1] + 1);
                       s.setInclusive(true);
                       range.addSeg(s);