rio, lca, refactoring
[jalview.git] / forester / java / src / org / forester / archaeopteryx / MainFrameApplication.java
index 655383c..2c674fe 100644 (file)
@@ -36,6 +36,7 @@ import java.awt.event.WindowEvent;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -292,8 +293,9 @@ public final class MainFrameApplication extends MainFrame {
         // hide until everything is ready
         setVisible( false );
         setOptions( Options.createInstance( _configuration ) );
+        setInferenceManager( InferenceManager.createInstance( _configuration ) );
         setPhylogeneticInferenceOptions( PhylogeneticInferenceOptions.createInstance( _configuration ) );
-        _textframe = null;
+        //     _textframe = null; #~~~~
         _species_tree = null;
         // set title
         setTitle( Constants.PRG_NAME + " " + Constants.VERSION + " (" + Constants.PRG_DATE + ")" );
@@ -667,14 +669,23 @@ public final class MainFrameApplication extends MainFrame {
     }
 
     void buildPhylogeneticInferenceMenu() {
-        final InferenceManager inference_manager = InferenceManager.getInstance();
+        final InferenceManager im = getInferenceManager();
         _inference_menu = MainFrame.createMenu( "Inference", getConfiguration() );
         _inference_menu.add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );
         customizeJMenuItem( _inference_from_msa_item );
         _inference_from_msa_item.setToolTipText( "Basic phylogenetic inference from MSA" );
-        _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );
-        customizeJMenuItem( _inference_from_seqs_item );
-        _inference_from_seqs_item.setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );
+        if ( im.canDoMsa() ) {
+            _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );
+            customizeJMenuItem( _inference_from_seqs_item );
+            _inference_from_seqs_item
+                    .setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );
+        }
+        else {
+            _inference_menu
+                    .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );
+            customizeJMenuItem( _inference_from_seqs_item );
+            _inference_from_seqs_item.setEnabled( false );
+        }
         _jmenubar.add( _inference_menu );
     }
 
@@ -1319,7 +1330,7 @@ public final class MainFrameApplication extends MainFrame {
     }
 
     void exit() {
-        removeTextFrame();
+        removeAllTextFrames();
         _mainpanel.terminate();
         _contentpane.removeAll();
         setVisible( false );
@@ -1360,7 +1371,7 @@ public final class MainFrameApplication extends MainFrame {
 
     private File getCurrentDir() {
         if ( ( _current_dir == null ) || !_current_dir.canRead() ) {
-            if ( ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1 ) {
+            if ( ForesterUtil.isWindowns() ) {
                 try {
                     _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() );
                 }
@@ -1966,12 +1977,12 @@ public final class MainFrameApplication extends MainFrame {
             setMsa( null );
             Msa msa = null;
             try {
-                if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) {
-                    msa = FastaParser.parseMsa( new FileInputStream( file ) );
-                    System.out.println( msa.toString() );
+                final InputStream is = new FileInputStream( file );
+                if ( FastaParser.isLikelyFasta( file ) ) {
+                    msa = FastaParser.parseMsa( is );
                 }
                 else {
-                    msa = GeneralMsaParser.parse( new FileInputStream( file ) );
+                    msa = GeneralMsaParser.parse( is );
                 }
             }
             catch ( final MsaFormatException e ) {