Index: ScripterMenuBar.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tools/java/net/tinyos/script/ScripterMenuBar.java,v
retrieving revision 1.2
diff -u -r1.2 ScripterMenuBar.java
--- ScripterMenuBar.java	15 Jul 2004 02:54:27 -0000	1.2
+++ ScripterMenuBar.java	28 Jun 2006 18:13:53 -0000
@@ -57,6 +57,7 @@
 public class ScripterMenuBar extends JMenuBar {
   private JMenu fileMenu;
   private JMenuItem loadItem;
+  private JMenuItem saveItem;
   private JMenuItem quitItem;
   
   public ScripterMenuBar(ScripterWindowed scripter) {
@@ -69,6 +70,12 @@
     loadItem.addActionListener(new LoadActionListener(scripter));
     loadItem.setFont(TinyLook.defaultFont());
     fileMenu.add(loadItem);
+    
+    saveItem = new JMenuItem();
+    saveItem.setText("Save");
+    saveItem.addActionListener(new SaveActionListener(scripter));
+    saveItem.setFont(TinyLook.defaultFont());
+    fileMenu.add(saveItem);
 
     quitItem = new JMenuItem();
     quitItem.setText("Quit");
@@ -115,4 +122,22 @@
       System.exit(0);
     }
   }
+  
+  private class SaveActionListener implements ActionListener {
+     private ScripterWindowed scripter;
+     private JFileChooser chooser;
+     
+     public SaveActionListener(ScripterWindowed s) {
+       scripter = s;
+       chooser = new JFileChooser();
+     }
+
+     public void actionPerformed(ActionEvent e) {
+       int rval = chooser.showSaveDialog(scripter);
+       if (rval == JFileChooser.APPROVE_OPTION) {
+        File file = chooser.getSelectedFile();
+          scripter.saveProgramFile(file);
+        }
+     }
+  }
 }
Index: ScripterWindowed.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tools/java/net/tinyos/script/ScripterWindowed.java,v
retrieving revision 1.3
diff -u -r1.3 ScripterWindowed.java
--- ScripterWindowed.java	21 Oct 2004 22:26:37 -0000	1.3
+++ ScripterWindowed.java	28 Jun 2006 18:13:53 -0000
@@ -263,7 +263,18 @@
       showError("Error reading file: " + exception.getMessage());
     }
   }
-
+ protected void saveProgramFile(File file) {
+    try {
+      String text = "";
+      BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+      text = programPanel.getProgram();
+      writer.write(text + "\n");
+      writer.close();
+    }
+    catch (IOException ioe) {
+      showError("Error writing file: " + ioe.getMessage());
+    }
+  }
   
   public void messageReceived(int to, Message m) {
     try {
