/* ArtemisMain.java * * created: Wed Feb 23 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/ArtemisMain.java,v 1.33 2008-12-10 16:43:38 tjc Exp $ */ package uk.ac.sanger.artemis.components; import uk.ac.sanger.artemis.components.database.DatabaseEntrySource; import uk.ac.sanger.artemis.components.database.DatabaseJPanel; 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.NoSequenceException; import uk.ac.sanger.artemis.sequence.Bases; import uk.ac.sanger.artemis.util.Document; import uk.ac.sanger.artemis.util.TextDocument; import uk.ac.sanger.artemis.util.DocumentFactory; import uk.ac.sanger.artemis.util.OutOfRangeException; import uk.ac.sanger.artemis.util.InputStreamProgressListener; import uk.ac.sanger.artemis.io.EntryInformation; import org.biojava.bio.seq.io.SequenceFormat; import java.awt.event.*; import java.awt.Toolkit; import java.io.*; import java.util.Vector; import java.awt.datatransfer.*; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; /** * The main window for the Artemis sequence editor. * * @author Kim Rutherford * @version $Id: ArtemisMain.java,v 1.33 2008-12-10 16:43:38 tjc Exp $ **/ public class ArtemisMain extends Splash { /** */ private static final long serialVersionUID = 1L; /** A vector containing all EntryEdit object we have created. */ private Vector entry_edit_objects = new Vector(); protected static FileManager filemanager = null; private LocalAndRemoteFileManager fm; /** * The constructor creates all the components for the main Artemis * window and sets up all the menu callbacks. **/ public ArtemisMain(final String args[]) { super("Artemis", "Artemis", "15"); makeMenuItem(file_menu, "Open Project Manager ...", new ActionListener(){ public void actionPerformed(ActionEvent e) { new ProjectProperty(ArtemisMain.this); } }); ActionListener menu_listener = new ActionListener() { public void actionPerformed(ActionEvent event) { if(filemanager == null) filemanager = new FileManager(ArtemisMain.this); else filemanager.setVisible(true); } }; makeMenuItem(file_menu, "Open File Manager ...", menu_listener); ActionListener menu_listener_ssh = new ActionListener() { public void actionPerformed(ActionEvent event) { if(fm == null) fm = new LocalAndRemoteFileManager(ArtemisMain.this); else fm.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 EntrySourceVector entry_sources = getEntrySources(this); for(int source_index=0; source_index-1) { // open from database e.g. Pfalciparum:Pf3D7_09:95000..150000 Splash.logger4j.info("OPEN ENTRY "+new_entry_name); getStatusLabel().setText("Connecting ..."); DatabaseEntrySource entry_source = new DatabaseEntrySource(); boolean promptUser = true; if(System.getProperty("read_only") != null) { promptUser = false; entry_source.setReadOnly(true); } last_entry_edit = dbLogin(entry_source, promptUser, new_entry_name); if(last_entry_edit == null) return; } else { // new sequence file if(last_entry_edit != null) { last_entry_edit.setVisible(true); last_entry_edit = null; } if (new_entry_name.indexOf ("://") == -1) { File file = new File (new_entry_name); if(!file.exists()) { JOptionPane.showMessageDialog(null, "File "+ new_entry_name +" not found.\n"+ "Check the file name.", "File Not Found", JOptionPane.WARNING_MESSAGE); } } final Document entry_document = DocumentFactory.makeDocument(new_entry_name); entry_document.addInputStreamProgressListener(getInputStreamProgressListener()); final uk.ac.sanger.artemis.io.Entry new_embl_entry = EntryFileDialog.getEntryFromFile(f, entry_document, artemis_entry_information, false); if(new_embl_entry == null) // the read failed break; try { final Entry entry = new Entry(new_embl_entry); last_entry_edit = makeEntryEdit(entry); addEntryEdit(last_entry_edit); getStatusLabel().setText(""); } catch(OutOfRangeException e) { new MessageDialog(this, "read failed: one of the features in " + new_entry_name + " has an out of range " + "location: " + e.getMessage()); break; } catch(NoSequenceException e) { new MessageDialog(this, "read failed: " + new_entry_name + " contains no sequence"); break; } } } if(System.getProperty("offset") != null) last_entry_edit.getGotoEventSource().gotoBase( Integer.parseInt(System.getProperty("offset"))); last_entry_edit.setVisible(true); for(int entry_index=0; entry_index