()
| 719 | }; |
| 720 | |
| 721 | protected File createNewUntitled() throws IOException { |
| 722 | File newbieDir = null; |
| 723 | String newbieName = null; |
| 724 | |
| 725 | // In 0126, untitled sketches will begin in the temp folder, |
| 726 | // and then moved to a new location because Save will default to Save As. |
| 727 | File sketchbookDir = BaseNoGui.getSketchbookFolder(); |
| 728 | File newbieParentDir = untitledFolder; |
| 729 | |
| 730 | // Use a generic name like sketch_031008a, the date plus a char |
| 731 | int index = 0; |
| 732 | //SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd"); |
| 733 | //SimpleDateFormat formatter = new SimpleDateFormat("MMMdd"); |
| 734 | //String purty = formatter.format(new Date()).toLowerCase(); |
| 735 | Calendar cal = Calendar.getInstance(); |
| 736 | int day = cal.get(Calendar.DAY_OF_MONTH); // 1..31 |
| 737 | int month = cal.get(Calendar.MONTH); // 0..11 |
| 738 | String purty = months[month] + PApplet.nf(day, 2); |
| 739 | |
| 740 | do { |
| 741 | if (index == 26*26) { |
| 742 | // In 0166, avoid running past zz by sending people outdoors. |
| 743 | if (!breakTime) { |
| 744 | showWarning(tr("Time for a Break"), |
| 745 | tr("You've reached the limit for auto naming of new sketches\n" + |
| 746 | "for the day. How about going for a walk instead?"), null); |
| 747 | breakTime = true; |
| 748 | } else { |
| 749 | showWarning(tr("Sunshine"), |
| 750 | tr("No really, time for some fresh air for you."), null); |
| 751 | } |
| 752 | return null; |
| 753 | } |
| 754 | |
| 755 | int multiples = index / 26; |
| 756 | |
| 757 | if(multiples > 0){ |
| 758 | newbieName = ((char) ('a' + (multiples-1))) + "" + ((char) ('a' + (index % 26))) + ""; |
| 759 | }else{ |
| 760 | newbieName = ((char) ('a' + index)) + ""; |
| 761 | } |
| 762 | newbieName = "sketch_" + purty + newbieName; |
| 763 | newbieDir = new File(newbieParentDir, newbieName); |
| 764 | index++; |
| 765 | // Make sure it's not in the temp folder *and* it's not in the sketchbook |
| 766 | } while (newbieDir.exists() || new File(sketchbookDir, newbieName).exists()); |
| 767 | |
| 768 | // Make the directory for the new sketch |
| 769 | newbieDir.mkdirs(); |
| 770 | |
| 771 | // Make an empty pde file |
| 772 | File newbieFile = new File(newbieDir, newbieName + ".ino"); |
| 773 | if (!newbieFile.createNewFile()) { |
| 774 | throw new IOException(); |
| 775 | } |
| 776 | |
| 777 | // Initialize the pde file with the BareMinimum sketch. |
| 778 | // Apply user-defined tab settings. |
no test coverage detected