Merge branch 'test_paolo_JAL-1065' into Tcoffee_JAL-1065
[jalview.git] / src / jalview / gui / AlignFrame.java
index 3ba7319..221d52c 100755 (executable)
@@ -143,8 +143,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   Vector alignPanels = new Vector();
   
-  TCoffeeScoreFile tcoffeeScoreFile;
-
   /**
    * Last format used to load or save alignments in this window
    */
@@ -3884,6 +3882,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
              {
                  TCoffeeScoreFile result = TCoffeeScoreFile.load(new File(sFilePath));
                  if( result == null ) { 
+                      // TODO: raise a dialog box here rather than bomb out.
+                 
                          throw new RuntimeException("The file provided does not match the T-Coffee scores file format"); 
                  }
 
@@ -3892,14 +3892,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                   */
                  AlignmentI aln; 
                  if( (aln=viewport.alignment) != null && (aln.getHeight() != result.getHeight() || aln.getWidth() != result.getWidth()) ) {
-                         throw new RuntimeException("The scores matrix does not match the alignment dimensions");
+                     // TODO: raise a dialog box here rather than bomb out.
+                   throw new RuntimeException("The scores matrix does not match the alignment dimensions");
                  }
-
-                 changeColour( new TCoffeeColourScheme(result) );
-                 tcoffeeScoreFile = result;
-                 tcoffeeColour.setEnabled(true);
-                 tcoffeeColour.setSelected(true);
-                 
+                 if (result.annotateAlignment(alignPanel.getAlignment(), true))
+                 {
+                         tcoffeeColour.setEnabled(true);
+                         tcoffeeColour.setSelected(true);
+                         // switch to this color
+                         changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
+                 } else {
+                   tcoffeeColour.setEnabled(false);
+                   tcoffeeColour.setSelected(false);
+                 }
              } 
              catch (Exception ex) {
                JOptionPane.showMessageDialog(
@@ -3917,9 +3922,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   
   @Override
   protected void tcoffeeColorScheme_actionPerformed(ActionEvent e) {
-         if( tcoffeeScoreFile != null ) {
-         changeColour( new TCoffeeColourScheme(tcoffeeScoreFile) );
-         }
+         changeColour( new TCoffeeColourScheme(alignPanel.getAlignment()) );
   }
   
 //  /**