From: amwaterhouse Date: Fri, 9 Jun 2006 16:17:01 +0000 (+0000) Subject: Save text to file X-Git-Tag: Release_2_1~367 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2140ff9720fb75b29d13bd48350eda2808cb05f9;p=jalview.git Save text to file --- diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index d89d3be..3da42fc 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -88,6 +88,40 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer textarea.append(text); } + + public void save_actionPerformed(ActionEvent e) + { + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty( + "LAST_DIRECTORY")); + + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save Text to File"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + try + { + java.io.PrintWriter out = new java.io.PrintWriter( + new java.io.FileWriter(chooser.getSelectedFile())); + + out.print(getText()); + out.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + } + } + + + /** * DOCUMENT ME! * @@ -178,15 +212,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer catch (Exception ex) { } - } - try - { - this.setClosed(true); - } - catch (Exception ex) - { - } } } diff --git a/src/jalview/jbgui/GCutAndPasteTransfer.java b/src/jalview/jbgui/GCutAndPasteTransfer.java index 6a89e2c..bc7d6ee 100755 --- a/src/jalview/jbgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteTransfer.java @@ -21,10 +21,6 @@ package jalview.jbgui; import java.awt.*; import java.awt.event.*; -import java.beans.PropertyChangeEvent; -//import java.beans.PropertyVetoException; -//import java.beans.VetoableChangeListener; - import javax.swing.*; @@ -48,6 +44,8 @@ public class GCutAndPasteTransfer extends JInternalFrame JButton ok = new JButton(); JButton cancel = new JButton(); JMenuItem selectAll = new JMenuItem(); + JMenu jMenu1 = new JMenu(); + JMenuItem save = new JMenuItem(); /** * Creates a new GCutAndPasteTransfer object. @@ -82,7 +80,7 @@ public class GCutAndPasteTransfer extends JInternalFrame ok_actionPerformed(e); } }); - cancel.setText("Cancel"); + cancel.setText("Close"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -100,6 +98,16 @@ public class GCutAndPasteTransfer extends JInternalFrame selectAll_actionPerformed(e); } }); + jMenu1.setText("File"); + save.setText("Save"); + save.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + save_actionPerformed(e); + } + }); + editMenubar.add(jMenu1); editMenubar.add(editMenu); textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12)); textarea.addMouseListener(new java.awt.event.MouseAdapter() @@ -135,7 +143,8 @@ public class GCutAndPasteTransfer extends JInternalFrame this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER); inputButtonPanel.add(ok); inputButtonPanel.add(cancel); - } + jMenu1.add(save); + } /** * DOCUMENT ME! @@ -188,4 +197,9 @@ public class GCutAndPasteTransfer extends JInternalFrame { textarea.selectAll(); } + + public void save_actionPerformed(ActionEvent e) + { + + } }