/* ActMain.java * * created: Wed May 10 2000 * * This file is part of Artemis * * Copyright(C) 2000 Genome Research Limited * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or(at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ActMain.java,v 1.17 2008-11-17 13:52:34 tjc Exp $ */ package uk.ac.sanger.artemis.components; import uk.ac.sanger.artemis.components.filetree.FileManager; import uk.ac.sanger.artemis.components.filetree.LocalAndRemoteFileManager; import uk.ac.sanger.artemis.*; import uk.ac.sanger.artemis.sequence.Bases; import uk.ac.sanger.artemis.sequence.NoSequenceException; import uk.ac.sanger.artemis.components.database.DatabaseEntrySource; import uk.ac.sanger.artemis.components.database.DatabaseTreeNode; import uk.ac.sanger.artemis.util.*; import uk.ac.sanger.artemis.io.DatabaseDocumentEntry; import uk.ac.sanger.artemis.io.EntryInformation; import uk.ac.sanger.artemis.io.SimpleEntryInformation; import java.awt.event.*; import java.io.File; import java.io.IOException; import java.net.URL; import javax.swing.JFrame; /** * The main window for the Artemis Comparison Tool. * * @author Kim Rutherford * @version $Id: ActMain.java,v 1.17 2008-11-17 13:52:34 tjc Exp $ **/ public class ActMain extends Splash { /** */ private static final long serialVersionUID = 1L; /** Version String use for banner messages and title bars. */ public static final String version = "Release 6"; /** File manager */ protected static FileManager filemanager = null; private static DatabaseEntrySource dbEntrySource; /** * The constructor creates all the components for the main ACT window * and sets up all the menu callbacks. **/ public ActMain() { super("Artemis Comparison Tool", "ACT", version); ActionListener open_listener = new ActionListener() { public void actionPerformed(ActionEvent event) { makeOpenDialog(); } }; makeMenuItem(file_menu, "Open ...", open_listener); ActionListener quit_listener = new ActionListener() { public void actionPerformed(ActionEvent event) { exit(); } }; ActionListener menu_listener_ssh = new ActionListener() { private LocalAndRemoteFileManager fm; public void actionPerformed(ActionEvent event) { if(fm == null) fm = new LocalAndRemoteFileManager(ActMain.this); else fm.setVisible(true); dbEntrySource = fm.getDatabaseEntrySource(); new ComparatorDialog(ActMain.this).setVisible(true); } }; if(System.getProperty("chado") != null) makeMenuItem(file_menu, "Open Database and SSH File Manager ...", menu_listener_ssh); else makeMenuItem(file_menu, "Open SSH File Manager ...", menu_listener_ssh); /* final boolean sanger_options = Options.getOptions().getPropertyTruthValue("sanger_options"); if(sanger_options) { ActionListener menu_listener = new ActionListener() { public void actionPerformed(ActionEvent event) { launchDatabaseJFrame(true); } }; makeMenuItem(file_menu, "Database Entry ...", menu_listener); if(System.getProperty("chado") != null) launchDatabaseJFrame(false); }*/ makeMenuItem(file_menu, "Quit", quit_listener); } /** * Make a new Comparator component from the given files. * @param frame The JFrame used when making a new MessageDialog. * @param progress_listener The object to which InputStreamProgressEvents * will be send while reading. Can be null. * @param file_names Alternating sequence and comparison data file names. * Must be >= 3. I there are an even number of file names the first * file/sequence object will be added to the send of the display and the * last comparison file will be assumed to be a a comparison between the * last and first sequence files. **/ public static boolean makeMultiComparator(final JFrame frame, final InputStreamProgressListener progress_listener, final Object[] file_names) { processJnlpAttributes(); final ProgressThread progress_thread = new ProgressThread(null, "Loading Entry..."); SwingWorker entryWorker = new SwingWorker() { public Object construct() { progress_thread.start(); final EntryGroup[] entry_group_array = new EntryGroup[file_names.length / 2 + 1]; final ComparisonData[] comparison_data_array = new ComparisonData[file_names.length / 2]; for(int i = 0; i= 3) { // Make sure the files provided are actually valid as far as possible... for (String file : args) { if (file.startsWith("ftp") || file.startsWith("http")) { // web resource try { URL url = new URL(file); } catch (Exception e) { valid = false; System.err.println("\nError - " + file + " is not a valid URL."); } } else { // normal file File argFile = new File(file); if (!argFile.exists() || !argFile.isFile()) { valid = false; System.err.println("\nError - " + argFile + " is not a valid file."); } } } } else { if(args.length != 0) { System.err.println("\nError - this program needs either no" + " arguments or an odd number\n" + "(3 or more):"); System.err.println(" act sequence_1 comparison_data sequence_2"); System.err.println("or"); System.err.println(" act seq_1 comparison_data_2_v_1 seq_2 comparison_data_3_v_2 seq_3"); System.err.println("or"); System.err.println(" act"); valid = false; } } if (!valid) { System.exit(1); } } /** * Main entry point for ACT **/ public static void main(final String [] args) { validateStartupArguments(args); final ActMain main_window = new ActMain(); main_window.setVisible(true); final InputStreamProgressListener progress_listener = main_window.getInputStreamProgressListener(); if(args.length >= 3) { ActMain.makeMultiComparator(main_window, progress_listener, args); } } }