Skip to content
Snippets Groups Projects
Commit f06e72c1 authored by tjc's avatar tjc
Browse files

implement ssh file reading in act

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3788 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 86fe7965
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,13 @@
* 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.7 2005-08-17 08:43:05 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ActMain.java,v 1.8 2005-10-26 16:10:38 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.components.filetree.FileManager;
......@@ -35,13 +37,14 @@ import uk.ac.sanger.artemis.io.SimpleEntryInformation;
import java.awt.event.*;
import java.io.IOException;
import java.io.File;
import javax.swing.JFrame;
/**
* The main window for the Artemis Comparison Tool.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: ActMain.java,v 1.7 2005-08-17 08:43:05 tjc Exp $
* @version $Id: ActMain.java,v 1.8 2005-10-26 16:10:38 tjc Exp $
**/
public class ActMain extends Splash
......@@ -77,6 +80,20 @@ public class ActMain extends Splash
}
};
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);
new ComparatorDialog(ActMain.this).setVisible(true);
}
};
makeMenuItem(file_menu, "Open SSH File Manager ...", menu_listener_ssh);
makeMenuItem(file_menu, "Quit", quit_listener);
}
......@@ -116,40 +133,13 @@ public class ActMain extends Splash
new SimpleEntryInformation(Options.getArtemisEntryInformation());
final String this_file_name = file_names[i];
final Document entry_document =
DocumentFactory.makeDocument(this_file_name);
if(progress_listener != null)
entry_document.addInputStreamProgressListener(progress_listener);
final uk.ac.sanger.artemis.io.Entry embl_entry =
EntryFileDialog.getEntryFromFile(frame, entry_document,
entry_information,
false);
// getEntryFromFile() has alerted the user so we just need to quit
if(embl_entry == null)
return null;
final uk.ac.sanger.artemis.io.Sequence sequence =
embl_entry.getSequence();
if(sequence == null)
{
new MessageDialog(frame, "This file contains no sequence: " +
this_file_name);
return null;
}
final Bases embl_bases = new Bases(sequence);
final EntryGroup entry_group = new SimpleEntryGroup(embl_bases);
File this_file = new File(this_file_name);
try
{
final Entry entry = new Entry(entry_group.getBases(), embl_entry);
entry_group.add(entry);
entry_group_array[i / 2] = entry_group;
if(!openEntry(this_file_name, entry_group_array,
entry_information, i))
return null;
}
catch(OutOfRangeException e)
{
......@@ -223,12 +213,52 @@ public class ActMain extends Splash
progress_thread.finished();
}
private boolean openEntry(String this_file_name, EntryGroup[] entry_group_array,
final EntryInformation entry_information, int i)
throws OutOfRangeException
{
final Document entry_document =
DocumentFactory.makeDocument(this_file_name);
if(progress_listener != null)
entry_document.addInputStreamProgressListener(progress_listener);
final uk.ac.sanger.artemis.io.Entry embl_entry =
EntryFileDialog.getEntryFromFile(frame, entry_document,
entry_information,
false);
// getEntryFromFile() has alerted the user so we just need to quit
if(embl_entry == null)
return false;
final uk.ac.sanger.artemis.io.Sequence sequence =
embl_entry.getSequence();
if(sequence == null)
{
new MessageDialog(frame, "This file contains no sequence: " +
this_file_name);
return false;
}
final Bases embl_bases = new Bases(sequence);
EntryGroup entry_group = new SimpleEntryGroup(embl_bases);
Entry entry = new Entry(entry_group.getBases(), embl_entry);
entry_group.add(entry);
entry_group_array[i / 2] = entry_group;
return true;
}
};
entryWorker.start();
return true;
}
/**
* Create a dialog that allow the user to the choose two files to compare
* and a file containing comparison data.
......
......@@ -20,7 +20,7 @@
* 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/MultiComparator.java,v 1.13 2005-08-17 08:43:05 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/MultiComparator.java,v 1.14 2005-10-26 16:10:38 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
......@@ -28,6 +28,7 @@ package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.*;
import uk.ac.sanger.artemis.components.filetree.FileManager;
import uk.ac.sanger.artemis.components.filetree.FileNode;
import uk.ac.sanger.artemis.util.RemoteFileDocument;
import uk.ac.sanger.artemis.util.FileDocument;
import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.util.InputStreamProgressListener;
......@@ -35,6 +36,7 @@ import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.DocumentEntryFactory;
import uk.ac.sanger.artemis.io.EntryInformation;
import uk.ac.sanger.artemis.io.SimpleEntryInformation;
import uk.ac.sanger.artemis.io.DocumentEntry;
import java.awt.*;
import java.awt.event.*;
......@@ -58,7 +60,7 @@ import javax.swing.border.BevelBorder;
* to keep them synchronized.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: MultiComparator.java,v 1.13 2005-08-17 08:43:05 tjc Exp $
* @version $Id: MultiComparator.java,v 1.14 2005-10-26 16:10:38 tjc Exp $
**/
public class MultiComparator extends JFrame
......@@ -496,6 +498,18 @@ public class MultiComparator extends JFrame
try
{
entry.save(DocumentEntryFactory.ANY_FORMAT);
// save it back to ssh server
if(((DocumentEntry)entry.getEMBLEntry()).getDocument()
instanceof RemoteFileDocument)
{
RemoteFileDocument node =
(RemoteFileDocument)(((DocumentEntry)entry.getEMBLEntry()).getDocument());
File file = new File( ((DocumentEntry)entry.getEMBLEntry()).getDocument().toString() );
node.saveEntry(file);
}
}
catch(IOException e)
{
......
......@@ -20,7 +20,7 @@
* 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/io/SimpleDocumentEntry.java,v 1.15 2005-10-11 14:20:31 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java,v 1.16 2005-10-26 16:10:38 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -37,7 +37,7 @@ import java.util.Enumeration;
* This class contains the methods common to all DocumentEntry objects.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: SimpleDocumentEntry.java,v 1.15 2005-10-11 14:20:31 tjc Exp $
* @version $Id: SimpleDocumentEntry.java,v 1.16 2005-10-26 16:10:38 tjc Exp $
**/
abstract public class SimpleDocumentEntry
......@@ -1116,7 +1116,16 @@ abstract public class SimpleDocumentEntry
public void save(final Document document)
throws IOException
{
final Writer out_file = document.getWriter();
final Writer out_file;
try
{
out_file = document.getWriter();
}
catch(NullPointerException npe)
{
return;
}
writeToStream(out_file);
out_file.close();
......
......@@ -20,7 +20,7 @@
* 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/util/DocumentFactory.java,v 1.1 2004-06-09 09:52:58 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/util/DocumentFactory.java,v 1.2 2005-10-26 16:10:38 tjc Exp $
*/
package uk.ac.sanger.artemis.util;
......@@ -28,11 +28,13 @@ package uk.ac.sanger.artemis.util;
import java.net.*;
import java.io.*;
import uk.ac.sanger.artemis.components.filetree.RemoteFileNode;
/**
* A Factory for Document objects.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: DocumentFactory.java,v 1.1 2004-06-09 09:52:58 tjc Exp $
* @version $Id: DocumentFactory.java,v 1.2 2005-10-26 16:10:38 tjc Exp $
**/
public class DocumentFactory {
......@@ -47,8 +49,18 @@ public class DocumentFactory {
} catch (MalformedURLException e) {
return new FileDocument (new File (source_string));
}
} else {
return new FileDocument (new File (source_string));
}
else
{
File file = new File (source_string);
if(file.exists()) // assume a local file
return new FileDocument(file);
else // assume a remote file
{
RemoteFileNode node = new RemoteFileNode("", file.getName(), null,
file.getParent(), false);
return new RemoteFileDocument(node);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment