@@ -538,21 +538,21 @@ public void actionPerformed(ActionEvent e) {
538538 });
539539 fileMenu .add (saveAsMenuItem );
540540
541- item = newJMenuItem ("Upload to I/O Board " , 'U' );
541+ item = newJMenuItem ("Upload" , 'U' );
542542 item .addActionListener (new ActionListener () {
543543 public void actionPerformed (ActionEvent e ) {
544544 handleExport (false );
545545 }
546546 });
547547 fileMenu .add (item );
548548
549- // item = newJMenuItemShift("Upload to I/O Board (verbose) ", 'U');
550- // item.addActionListener(new ActionListener() {
551- // public void actionPerformed(ActionEvent e) {
552- // handleExport(true);
553- // }
554- // });
555- // fileMenu.add(item);
549+ item = newJMenuItemShift ("Upload Using Programmer " , 'U' );
550+ item .addActionListener (new ActionListener () {
551+ public void actionPerformed (ActionEvent e ) {
552+ handleExport (true );
553+ }
554+ });
555+ fileMenu .add (item );
556556
557557 fileMenu .addSeparator ();
558558
@@ -618,13 +618,13 @@ public void actionPerformed(ActionEvent e) {
618618// });
619619// sketchMenu.add(item);
620620
621- item = new JMenuItem ("Stop" );
622- item .addActionListener (new ActionListener () {
623- public void actionPerformed (ActionEvent e ) {
624- handleStop ();
625- }
626- });
627- sketchMenu .add (item );
621+ // item = new JMenuItem("Stop");
622+ // item.addActionListener(new ActionListener() {
623+ // public void actionPerformed(ActionEvent e) {
624+ // handleStop();
625+ // }
626+ // });
627+ // sketchMenu.add(item);
628628
629629 sketchMenu .addSeparator ();
630630
@@ -693,12 +693,20 @@ public void actionPerformed(ActionEvent e) {
693693 serialMenu = new JMenu ("Serial Port" );
694694 populateSerialMenu ();
695695 menu .add (serialMenu );
696-
696+
697697 menu .addSeparator ();
698+
699+ JMenu programmerMenu = new JMenu ("Programmer" );
700+ base .rebuildProgrammerMenu (programmerMenu );
701+ menu .add (programmerMenu );
698702
699- JMenu bootloaderMenu = new JMenu ("Burn Bootloader" );
700- base .rebuildBurnBootloaderMenu (bootloaderMenu );
701- menu .add (bootloaderMenu );
703+ item = new JMenuItem ("Burn Bootloader" );
704+ item .addActionListener (new ActionListener () {
705+ public void actionPerformed (ActionEvent e ) {
706+ handleBurnBootloader ();
707+ }
708+ });
709+ menu .add (item );
702710
703711 menu .addMenuListener (new MenuListener () {
704712 public void menuCanceled (MenuEvent e ) {}
@@ -989,8 +997,8 @@ protected void populateSerialMenu() {
989997 //serialMenu.addSeparator();
990998 //serialMenu.add(item);
991999 }
992-
993-
1000+
1001+
9941002 protected JMenu buildHelpMenu () {
9951003 // To deal with a Mac OS X 10.5 bug, add an extra space after the name
9961004 // so that the OS doesn't try to insert its slow help menu.
@@ -1887,12 +1895,12 @@ public Point getSketchLocation() {
18871895 * Implements Sketch → Stop, or pressing Stop on the toolbar.
18881896 */
18891897 public void handleStop () { // called by menu or buttons
1890- toolbar .activate (EditorToolbar .STOP );
1898+ // toolbar.activate(EditorToolbar.STOP);
18911899
18921900 internalCloseRunner ();
18931901
18941902 toolbar .deactivate (EditorToolbar .RUN );
1895- toolbar .deactivate (EditorToolbar .STOP );
1903+ // toolbar.deactivate(EditorToolbar.STOP);
18961904
18971905 // focus the PDE again after quitting presentation mode [toxi 030903]
18981906 toFront ();
@@ -2032,14 +2040,65 @@ protected void handleOpenUnchecked(String path, int codeIndex,
20322040 * modifications (if any) to the previous sketch need to be saved.
20332041 */
20342042 protected boolean handleOpenInternal (String path ) {
2043+ // rename .pde files to .ino
2044+ File [] oldFiles = (new File (path )).getParentFile ().listFiles (new FilenameFilter () {
2045+ public boolean accept (File dir , String name ) {
2046+ return (name .toLowerCase ().endsWith (".pde" ));
2047+ }
2048+ });
2049+
2050+ if (oldFiles != null && oldFiles .length > 0 ) {
2051+ if (!Preferences .getBoolean ("editor.update_extension" )) {
2052+ Object [] options = { "OK" , "Cancel" };
2053+ String prompt =
2054+ "In Arduino 1.0, the file extension for sketches changed\n " +
2055+ "from \" .pde\" to \" .ino\" . This version of the software only\n " +
2056+ "supports the new extension. Rename the files in this sketch\n " +
2057+ "(and future sketches) and continue?" ;
2058+
2059+ int result = JOptionPane .showOptionDialog (this ,
2060+ prompt ,
2061+ "New extension" ,
2062+ JOptionPane .YES_NO_OPTION ,
2063+ JOptionPane .QUESTION_MESSAGE ,
2064+ null ,
2065+ options ,
2066+ options [0 ]);
2067+ if (result != JOptionPane .YES_OPTION ) {
2068+ return false ;
2069+ }
2070+
2071+ Preferences .setBoolean ("editor.update_extension" , true );
2072+ }
2073+
2074+ for (int i = 0 ; i < oldFiles .length ; i ++) {
2075+ String oldPath = oldFiles [i ].getPath ();
2076+ File newFile = new File (oldPath .substring (0 , oldPath .length () - 4 ) + ".ino" );
2077+ try {
2078+ Base .copyFile (oldFiles [i ], newFile );
2079+ } catch (IOException e ) {
2080+ Base .showWarning ("Error" , "Could not copy to a proper location." , e );
2081+ return false ;
2082+ }
2083+
2084+ // remove the original file, so user doesn't get confused
2085+ oldFiles [i ].delete ();
2086+
2087+ // update with the new path
2088+ if (oldFiles [i ].compareTo (new File (path )) == 0 ) {
2089+ path = newFile .getAbsolutePath ();
2090+ }
2091+ }
2092+ }
2093+
20352094 // check to make sure that this .pde file is
20362095 // in a folder of the same name
20372096 File file = new File (path );
20382097 File parentFile = new File (file .getParent ());
20392098 String parentName = parentFile .getName ();
2040- String pdeName = parentName + ".pde " ;
2099+ String pdeName = parentName + ".ino " ;
20412100 File altFile = new File (file .getParent (), pdeName );
2042-
2101+
20432102 if (pdeName .equals (file .getName ())) {
20442103 // no beef with this guy
20452104
@@ -2049,10 +2108,10 @@ protected boolean handleOpenInternal(String path) {
20492108 path = altFile .getAbsolutePath ();
20502109 //System.out.println("found alt file in same folder");
20512110
2052- } else if (!path .endsWith (".pde " )) {
2111+ } else if (!path .endsWith (".ino " )) {
20532112 Base .showWarning ("Bad file selected" ,
20542113 "Processing can only open its own sketches\n " +
2055- "and other files ending in .pde " , null );
2114+ "and other files ending in .ino " , null );
20562115 return false ;
20572116
20582117 } else {
@@ -2271,13 +2330,13 @@ public boolean serialPrompt() {
22712330 * Made synchronized to (hopefully) avoid problems of people
22722331 * hitting export twice, quickly, and horking things up.
22732332 */
2274- synchronized public void handleExport (final boolean verbose ) {
2333+ synchronized public void handleExport (final boolean usingProgrammer ) {
22752334 //if (!handleExportCheckModified()) return;
22762335 toolbar .activate (EditorToolbar .EXPORT );
22772336 console .clear ();
22782337 statusNotice ("Uploading to I/O Board..." );
22792338
2280- new Thread (verbose ? exportAppHandler : exportHandler ).start ();
2339+ new Thread (usingProgrammer ? exportAppHandler : exportHandler ).start ();
22812340 }
22822341
22832342 // DAM: in Arduino, this is upload
@@ -2395,14 +2454,14 @@ public void handleSerial() {
23952454 }
23962455
23972456
2398- protected void handleBurnBootloader (final String target , final String programmer ) {
2457+ protected void handleBurnBootloader () {
23992458 console .clear ();
24002459 statusNotice ("Burning bootloader to I/O Board (this may take a minute)..." );
24012460 SwingUtilities .invokeLater (new Runnable () {
24022461 public void run () {
24032462 try {
24042463 Uploader uploader = new AvrdudeUploader ();
2405- if (uploader .burnBootloader (target , programmer )) {
2464+ if (uploader .burnBootloader ()) {
24062465 statusNotice ("Done burning bootloader." );
24072466 } else {
24082467 statusError ("Error while burning bootloader." );
0 commit comments