Save text to file
authoramwaterhouse <Andrew Waterhouse>
Fri, 9 Jun 2006 16:17:01 +0000 (16:17 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 9 Jun 2006 16:17:01 +0000 (16:17 +0000)
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/jbgui/GCutAndPasteTransfer.java

index d89d3be..3da42fc 100755 (executable)
@@ -88,6 +88,40 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       textarea.append(text);\r
     }\r
 \r
+\r
+    public void save_actionPerformed(ActionEvent e)\r
+    {\r
+      JalviewFileChooser chooser = new JalviewFileChooser(\r
+          jalview.bin.Cache.getProperty(\r
+              "LAST_DIRECTORY"));\r
+\r
+      chooser.setAcceptAllFileFilterUsed(false);\r
+      chooser.setFileView(new JalviewFileView());\r
+      chooser.setDialogTitle("Save Text to File");\r
+      chooser.setToolTipText("Save");\r
+\r
+      int value = chooser.showSaveDialog(this);\r
+\r
+      if (value == JalviewFileChooser.APPROVE_OPTION)\r
+      {\r
+        try\r
+        {\r
+          java.io.PrintWriter out = new java.io.PrintWriter(\r
+              new java.io.FileWriter(chooser.getSelectedFile()));\r
+\r
+          out.print(getText());\r
+          out.close();\r
+        }\r
+        catch (Exception ex)\r
+        {\r
+          ex.printStackTrace();\r
+        }\r
+\r
+      }\r
+    }\r
+\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -178,15 +212,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
             catch (Exception ex)\r
             {\r
             }\r
-\r
           }\r
-            try\r
-            {\r
-                this.setClosed(true);\r
-            }\r
-            catch (Exception ex)\r
-            {\r
-            }\r
         }\r
     }\r
 \r
index 6a89e2c..bc7d6ee 100755 (executable)
@@ -21,10 +21,6 @@ package jalview.jbgui;
 import java.awt.*;\r
 import java.awt.event.*;\r
 \r
-import java.beans.PropertyChangeEvent;\r
-//import java.beans.PropertyVetoException;\r
-//import java.beans.VetoableChangeListener;\r
-\r
 import javax.swing.*;\r
 \r
 \r
@@ -48,6 +44,8 @@ public class GCutAndPasteTransfer extends JInternalFrame
     JButton ok = new JButton();\r
     JButton cancel = new JButton();\r
   JMenuItem selectAll = new JMenuItem();\r
+  JMenu jMenu1 = new JMenu();\r
+  JMenuItem save = new JMenuItem();\r
 \r
   /**\r
      * Creates a new GCutAndPasteTransfer object.\r
@@ -82,7 +80,7 @@ public class GCutAndPasteTransfer extends JInternalFrame
                     ok_actionPerformed(e);\r
                 }\r
             });\r
-        cancel.setText("Cancel");\r
+        cancel.setText("Close");\r
         cancel.addActionListener(new ActionListener()\r
             {\r
                 public void actionPerformed(ActionEvent e)\r
@@ -100,6 +98,16 @@ public class GCutAndPasteTransfer extends JInternalFrame
         selectAll_actionPerformed(e);\r
       }\r
     });\r
+    jMenu1.setText("File");\r
+    save.setText("Save");\r
+    save.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        save_actionPerformed(e);\r
+      }\r
+    });\r
+    editMenubar.add(jMenu1);\r
     editMenubar.add(editMenu);\r
         textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));\r
         textarea.addMouseListener(new java.awt.event.MouseAdapter()\r
@@ -135,7 +143,8 @@ public class GCutAndPasteTransfer extends JInternalFrame
         this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);\r
         inputButtonPanel.add(ok);\r
         inputButtonPanel.add(cancel);\r
-    }\r
+    jMenu1.add(save);\r
+  }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -188,4 +197,9 @@ public class GCutAndPasteTransfer extends JInternalFrame
     {\r
       textarea.selectAll();\r
     }\r
+\r
+  public void save_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r