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

synch with remote ssh file

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3640 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 69fa86dc
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/EntryFileDialog.java,v 1.3 2004-12-03 17:47:04 tjc Exp $ * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/EntryFileDialog.java,v 1.4 2005-09-05 13:35:55 tjc Exp $
*/ */
package uk.ac.sanger.artemis.components; package uk.ac.sanger.artemis.components;
...@@ -32,6 +32,7 @@ import uk.ac.sanger.artemis.io.DocumentEntryFactory; ...@@ -32,6 +32,7 @@ import uk.ac.sanger.artemis.io.DocumentEntryFactory;
import uk.ac.sanger.artemis.io.ReadFormatException; import uk.ac.sanger.artemis.io.ReadFormatException;
import uk.ac.sanger.artemis.io.EntryInformation; import uk.ac.sanger.artemis.io.EntryInformation;
import uk.ac.sanger.artemis.io.EntryInformationException; import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.DocumentEntry;
import java.io.*; import java.io.*;
import javax.swing.*; import javax.swing.*;
...@@ -40,7 +41,7 @@ import javax.swing.*; ...@@ -40,7 +41,7 @@ import javax.swing.*;
* This class is a JFileChooser that can read EMBL Entry objects. * This class is a JFileChooser that can read EMBL Entry objects.
* *
* @author Kim Rutherford * @author Kim Rutherford
* @version $Id: EntryFileDialog.java,v 1.3 2004-12-03 17:47:04 tjc Exp $ * @version $Id: EntryFileDialog.java,v 1.4 2005-09-05 13:35:55 tjc Exp $
**/ **/
public class EntryFileDialog extends StickyFileChooser public class EntryFileDialog extends StickyFileChooser
...@@ -348,13 +349,20 @@ public class EntryFileDialog extends StickyFileChooser ...@@ -348,13 +349,20 @@ public class EntryFileDialog extends StickyFileChooser
final boolean keep_new_name, final boolean keep_new_name,
final int destination_type) final int destination_type)
{ {
JCheckBox remoteSave = new JCheckBox("Ssh/Remote Save",
true);
File file = null;
try try
{ {
if(ask_for_name || entry.getName() == null) if(ask_for_name || entry.getName() == null)
{ {
Box yBox = Box.createVerticalBox();
boolean useAccessory = false;
JCheckBox emblHeader = new JCheckBox("Add EMBL Header", JCheckBox emblHeader = new JCheckBox("Add EMBL Header",
false); false);
emblHeader.setSelected(false);
setDialogTitle("Save to ..."); setDialogTitle("Save to ...");
setDialogType(JFileChooser.SAVE_DIALOG); setDialogType(JFileChooser.SAVE_DIALOG);
...@@ -362,7 +370,21 @@ public class EntryFileDialog extends StickyFileChooser ...@@ -362,7 +370,21 @@ public class EntryFileDialog extends StickyFileChooser
if( destination_type == DocumentEntryFactory.EMBL_FORMAT && if( destination_type == DocumentEntryFactory.EMBL_FORMAT &&
(entry.getHeaderText() == null || (entry.getHeaderText() == null ||
!isHeaderEMBL(entry.getHeaderText())) ) !isHeaderEMBL(entry.getHeaderText())) )
setAccessory(emblHeader); {
yBox.add(emblHeader);
useAccessory = true;
}
if(((DocumentEntry)entry.getEMBLEntry()).getDocument()
instanceof RemoteFileDocument)
{
yBox.add(remoteSave);
useAccessory = true;
}
if(useAccessory)
setAccessory(yBox);
int status = showSaveDialog(owner); int status = showSaveDialog(owner);
if(status != JFileChooser.APPROVE_OPTION || if(status != JFileChooser.APPROVE_OPTION ||
...@@ -391,7 +413,7 @@ public class EntryFileDialog extends StickyFileChooser ...@@ -391,7 +413,7 @@ public class EntryFileDialog extends StickyFileChooser
} }
} }
File file = new File(getCurrentDirectory(), file = new File(getCurrentDirectory(),
getSelectedFile().getName()); getSelectedFile().getName());
if(file.exists()) if(file.exists())
...@@ -478,6 +500,20 @@ public class EntryFileDialog extends StickyFileChooser ...@@ -478,6 +500,20 @@ public class EntryFileDialog extends StickyFileChooser
new MessageDialog(owner, "error while saving: " + e); new MessageDialog(owner, "error while saving: " + e);
return; return;
} }
// save it back to ssh server
if(((DocumentEntry)entry.getEMBLEntry()).getDocument()
instanceof RemoteFileDocument &&
remoteSave.isSelected())
{
RemoteFileDocument node =
(RemoteFileDocument)(((DocumentEntry)entry.getEMBLEntry()).getDocument());
if(file == null)
file = new File( ((DocumentEntry)entry.getEMBLEntry()).getDocument().toString() );
node.saveEntry(file);
}
} }
/** /**
......
...@@ -209,12 +209,16 @@ public class RemoteFileNode extends DefaultMutableTreeNode ...@@ -209,12 +209,16 @@ public class RemoteFileNode extends DefaultMutableTreeNode
return flist.rename(getRootDir()+"/"+getFullName(), new_file); return flist.rename(getRootDir()+"/"+getFullName(), new_file);
} }
protected boolean put(File local_file, FTProgress monitor) public boolean put(File local_file, FTProgress monitor)
{ {
FileList flist = new FileList(); FileList flist = new FileList();
final String dir; String dir;
if(!isDirectory()) if(!isDirectory())
dir = getRootDir(); {
dir = getRootDir()+"/"+getFullName();
int index = dir.lastIndexOf("/");
dir = dir.substring(0,index);
}
else else
dir = getRootDir()+"/"+getFullName(); dir = getRootDir()+"/"+getFullName();
......
...@@ -27,6 +27,7 @@ package uk.ac.sanger.artemis.util; ...@@ -27,6 +27,7 @@ package uk.ac.sanger.artemis.util;
import java.io.*; import java.io.*;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import uk.ac.sanger.artemis.components.filetree.*; import uk.ac.sanger.artemis.components.filetree.*;
import uk.ac.sanger.artemis.components.SwingWorker;
import uk.ac.sanger.artemis.j2ssh.FileTransferProgressMonitor; import uk.ac.sanger.artemis.j2ssh.FileTransferProgressMonitor;
import uk.ac.sanger.artemis.j2ssh.FTProgress; import uk.ac.sanger.artemis.j2ssh.FTProgress;
...@@ -154,10 +155,39 @@ public class RemoteFileDocument extends Document ...@@ -154,10 +155,39 @@ public class RemoteFileDocument extends Document
return file_output_stream; return file_output_stream;
} }
/**
*
* Save the entry back to the ssh server
*
*/
public void saveEntry(final File local_file)
{
SwingWorker putWorker = new SwingWorker()
{
FileTransferProgressMonitor monitor;
public Object construct()
{
monitor = new FileTransferProgressMonitor(null);
FTProgress progress = monitor.add(local_file.getName());
getRemoteFileNode().put(local_file, progress);
monitor.close();
return null;
}
public void finished()
{
if(monitor != null)
monitor.close();
}
};
putWorker.start();
}
/** /**
* Return the RemoteFileNode object that this RemoteFileDocument is encapsulating. * Return the RemoteFileNode object that this RemoteFileDocument is encapsulating.
**/ **/
private RemoteFileNode getRemoteFileNode() public RemoteFileNode getRemoteFileNode()
{ {
return (RemoteFileNode)getLocation(); return (RemoteFileNode)getLocation();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment