JAL-1588 restoring saved Chimera session(s)
[jalview.git] / src / ext / edu / ucsf / rbvi / strucviz2 / ChimeraManager.java
index b45404e..2c40e1c 100644 (file)
@@ -29,12 +29,6 @@ public class ChimeraManager
 {
   private static final boolean debug = false;
 
-  /*
-   * true: use REST API (recommended), false: use stdout/stdin (deprecated)
-   */
-  // TODO remove once definitely happy with using REST
-  private static final boolean USE_REST = true;
-
   private int chimeraRestPort;
 
   private Process chimera;
@@ -224,10 +218,14 @@ public class ChimeraManager
                     modelNumbers[0], modelNumbers[1]);
             currentModelsMap.put(modelNumber, newModel);
             models.add(newModel);
+
+            //
             // patch for Jalview - set model name in Chimera
+            //
             sendChimeraCommand("setattr M name " + modelName + " #"
                     + modelNumbers[0], false);
             // end patch for Jalview
+
             modelNumbers = null;
           }
         }
@@ -370,15 +368,7 @@ public class ChimeraManager
   {
     chimera = null;
     currentModelsMap.clear();
-    if (USE_REST)
-    {
       this.chimeraRestPort = 0;
-    }
-    else
-    {
-      chimeraListenerThread.requestStop();
-      chimeraListenerThread = null;
-    }
     structureManager.clearOnChimeraExit();
   }
 
@@ -549,13 +539,11 @@ public class ChimeraManager
         List<String> args = new ArrayList<String>();
         args.add(chimeraPath);
         args.add("--start");
-        args.add(USE_REST ? "RESTServer" : "ReadStdin");
+        args.add("RESTServer");
         ProcessBuilder pb = new ProcessBuilder(args);
         chimera = pb.start();
         error = "";
         workingPath = chimeraPath;
-        logger.info("Starting " + chimeraPath + " with "
-                + (USE_REST ? "REST API" : "stdin/stdout"));
         break;
       } catch (Exception e)
       {
@@ -566,18 +554,9 @@ public class ChimeraManager
     // If no error, then Chimera was launched successfully
     if (error.length() == 0)
     {
-      if (USE_REST)
-      {
-        this.chimeraRestPort = getPortNumber();
-        System.out.println("Chimera REST API on port " + chimeraRestPort);
-      }
-      else
-      {
-        // Initialize the listener threads
-        chimeraListenerThread = new ListenerThreads(chimera,
-                structureManager);
-        chimeraListenerThread.start();
-      }
+      this.chimeraRestPort = getPortNumber();
+      System.out.println("Chimera REST API started on port "
+              + chimeraRestPort);
       // structureManager.initChimTable();
       structureManager.setChimeraPathProperty(workingPath);
       // TODO: [Optional] Check Chimera version and show a warning if below 1.8
@@ -766,22 +745,17 @@ public class ChimeraManager
       } catch (InterruptedException q)
       {
       }
-      ;
     }
     busy = true;
     long startTime = System.currentTimeMillis();
     try
     {
-      if (USE_REST)
-      {
-        return sendRestCommand(command);
-      }
-      else
-      {
-        return sendStdinCommand(command, reply);
-      }
+      return sendRestCommand(command);
     } finally
     {
+      /*
+       * Make sure busy flag is reset come what may!
+       */
       busy = false;
       if (debug)
       {