From a3c09955392b1fce23ea3fcd5c072b5051e2d97f Mon Sep 17 00:00:00 2001 From: ricklon Date: Thu, 3 Sep 2015 12:33:04 -0400 Subject: [PATCH] Issue #603 made changes for ino vs pde. --- app/src/processing/app/Base.java | 10 +-- app/src/processing/app/Preferences.java | 26 ++++---- app/src/processing/app/Sketch.java | 64 ++++++++++---------- app/src/processing/app/windows/Platform.java | 12 ++-- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index ffc6b0de6..674d7ba33 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -548,8 +548,8 @@ protected String createNewUntitled() throws IOException { // Make the directory for the new sketch newbieDir.mkdirs(); - // Make an empty pde file - File newbieFile = new File(newbieDir, newbieName + ".pde"); + // Make an empty ino file + File newbieFile = new File(newbieDir, newbieName + ".ino"); new FileOutputStream(newbieFile); // create the file return newbieFile.getAbsolutePath(); } @@ -1185,11 +1185,11 @@ public void actionPerformed(ActionEvent e) { if (!subfolder.isDirectory()) continue; File entry = new File(subfolder, list[i] + ".ino"); - if (!entry.exists() && (new File(subfolder, list[i] + ".pde")).exists()) { - entry = new File(subfolder, list[i] + ".pde"); + if (!entry.exists() && (new File(subfolder, list[i] + ".ino")).exists()) { + entry = new File(subfolder, list[i] + ".ino"); } - // if a .pde file of the same prefix as the folder exists.. + // if a .ino file of the same prefix as the folder exists.. if (entry.exists()) { //String sanityCheck = sanitizedName(list[i]); //if (!sanityCheck.equals(list[i])) { diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 59374f61e..26cc0ad4f 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -197,7 +197,7 @@ static protected void init(String commandLinePrefs) { " and restart MPIDE.", ex); } } - } + } } @@ -310,11 +310,11 @@ public void actionPerformed(ActionEvent e) { top += d.height + GUI_BETWEEN; - // [ ] Automatically associate .pde files with Processing + // [ ] Automatically associate .ino files with Processing if (Base.isWindows()) { autoAssociateBox = - new JCheckBox("Automatically associate .pde files with MPIDE"); + new JCheckBox("Automatically associate .ino files with MPIDE"); pain.add(autoAssociateBox); d = autoAssociateBox.getPreferredSize(); autoAssociateBox.setBounds(left, top, d.width + 10, d.height); @@ -339,7 +339,7 @@ public void actionPerformed(ActionEvent e) { public void mousePressed(MouseEvent e) { Base.openFolder(Base.getSettingsFolder()); } - + public void mouseEntered(MouseEvent e) { clickable.setForeground(new Color(0, 0, 140)); } @@ -548,8 +548,8 @@ protected void showFrame(Editor editor) { static protected void load(InputStream input) throws IOException { load(input, table); } - - static public void load(InputStream input, Map table) throws IOException { + + static public void load(InputStream input, Map table) throws IOException { String[] lines = PApplet.loadStrings(input); // Reads as UTF-8 for (String line : lines) { if ((line.length() == 0) || @@ -602,7 +602,7 @@ static protected void save() { //static public String get(String attribute) { //return get(attribute, null); //} - + static public String get(String attribute /*, String defaultValue */) { return (String) table.get(attribute); /* @@ -735,7 +735,7 @@ static public Font getFont(String attr) { return font; } - + // ROA: current getStyle: from Arduino 1.0 static public SyntaxStyle getStyle(String what /*, String dflt*/) { String str = get("editor." + what + ".style"); //, dflt); @@ -760,20 +760,20 @@ static public SyntaxStyle getStyle(String what /*, String dflt*/) { //get a Map of the Preferences - static public Map getMap() + static public Map getMap() { Map globalpreferences = new LinkedHashMap(); Enumeration e = table.keys(); - while (e.hasMoreElements()) + while (e.hasMoreElements()) { String key = (String) e.nextElement(); //System.out.println("Key: " + key + "Val: " + table.get(key)); String value = (String) table.get(key); - globalpreferences.put(key, value ); + globalpreferences.put(key, value ); } - return globalpreferences; + return globalpreferences; } - + } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 0bebdafcd..53473a950 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -53,9 +53,9 @@ * Stores information about files in the current sketch */ public class Sketch { - + static Logger logger = Logger.getLogger(Base.class.getName()); - + static private File tempBuildFolder; private Editor editor; @@ -105,7 +105,7 @@ public class Sketch { */ private String libraryPath; /** - * List of library folders. + * List of library folders. */ private ArrayList importedLibraries; @@ -410,16 +410,16 @@ protected void nameCode(String newName) { return; } } - + // In Arduino, don't allow a .cpp file with the same name as the sketch, // because the sketch is concatenated into a file with that name as part - // of the build process. + // of the build process. if (newName.equals(getName() + ".cpp")) { Base.showMessage("Nope", "You can't have a .cpp file with the same name as the sketch."); return; } - + if (renamingCode && currentIndex == 0) { for (int i = 1; i < codeCount; i++) { if (sanitaryName.equalsIgnoreCase(code[i].getPrettyName()) && @@ -726,7 +726,7 @@ public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".pde"); } }); - + if (pdeFiles != null && pdeFiles.length > 0) {/* if (Preferences.get("editor.update_extension") == null) { Object[] options = { "OK", "Cancel" }; @@ -744,12 +744,12 @@ public boolean accept(File dir, String name) { null, options, options[0]); - + if (result != JOptionPane.OK_OPTION) return false; // save cancelled - + Preferences.setBoolean("editor.update_extension", true); } - + if (Preferences.getBoolean("editor.update_extension")) { // Do rename of all .pde files to new .ino extension for (File pdeFile : pdeFiles) @@ -922,7 +922,7 @@ protected boolean saveAs() throws IOException { } // save the main tab with its new name - File newFile = new File(newFolder, newName + ".pde"); + File newFile = new File(newFolder, newName + ".ino"); code[0].saveAs(newFile); editor.handleOpenUnchecked(newFile.getPath(), @@ -1234,8 +1234,8 @@ protected void cleanup() { /** - * When running from the editor, take care of preparations before running - * the build. + * When running from the editor, take care of preparations before running + * the build. */ public void prepare() { // make sure the user didn't hide the sketch folder @@ -1323,7 +1323,7 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws StringBuffer bigCode = new StringBuffer(); int bigCount = 0; for (SketchCode sc : code) { - if (sc.isExtension("ino") || sc.isExtension("pde")) { + if (sc.isExtension("ino") || sc.isExtension("pde")) { sc.setPreprocOffset(bigCount); bigCode.append(sc.getProgram()); bigCode.append('\n'); @@ -1395,7 +1395,7 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws logger.debug("preprocessor.getExtraImports()" + preprocessor.getExtraImports()); logger.debug("Base.importToLibraryTable: " + Base.importToLibraryTable); for (String item : preprocessor.getExtraImports()) { - //Debug print library filename + //Debug print library filename logger.debug("Library filename item: " + item); logger.debug("Base.importToLibraryTable.get(item): " + Base.importToLibraryTable.get(item)); @@ -1441,7 +1441,7 @@ public ArrayList getImportedLibraries() { return importedLibraries; } - + /** * Map an error from a set of processed .java files back to its location * in the actual sketch. @@ -1451,7 +1451,7 @@ public ArrayList getImportedLibraries() { * @return A RunnerException to be sent to the editor, or null if it wasn't * possible to place the exception to the sketch code. */ -// public RunnerException placeExceptionAlt(String message, +// public RunnerException placeExceptionAlt(String message, // String filename, int line) { // String appletJavaFile = appletClassName + ".java"; // SketchCode errorCode = null; @@ -1483,14 +1483,14 @@ public ArrayList getImportedLibraries() { // line--; // // // getMessage() will be what's shown in the editor -// RunnerException exception = +// RunnerException exception = // new RunnerException(message, codeIndex, line, -1); // exception.hideStackTrace(); // return exception; // } // return null; // } - + /** * Map an error from a set of processed .java files back to its location @@ -1501,8 +1501,8 @@ public ArrayList getImportedLibraries() { * @return A RunnerException to be sent to the editor, or null if it wasn't * possible to place the exception to the sketch code. */ - public RunnerException placeException(String message, - String dotJavaFilename, + public RunnerException placeException(String message, + String dotJavaFilename, int dotJavaLine) { int codeIndex = 0; //-1; int codeLine = -1; @@ -1545,7 +1545,7 @@ public RunnerException placeException(String message, } } // could not find a proper line number, so deal with this differently. - // but if it was in fact the .java file we're looking for, though, + // but if it was in fact the .java file we're looking for, though, // send the error message through. // this is necessary because 'import' statements will be at a line // that has a lower number than the preproc offset, for instance. @@ -1577,7 +1577,7 @@ public String build(boolean verbose) throws RunnerException { */ public String build(String buildPath, boolean verbose) throws RunnerException { - + // run the preprocessor editor.status.progressUpdate(20); String primaryClassName = preprocess(buildPath); @@ -1591,8 +1591,8 @@ public String build(String buildPath, boolean verbose) } return null; } - - + + protected boolean exportApplet(boolean verbose) throws Exception { return exportApplet(tempBuildFolder.getAbsolutePath(), verbose); } @@ -1603,7 +1603,7 @@ protected boolean exportApplet(boolean verbose) throws Exception { */ public boolean exportApplet(String appletPath, boolean verbose) throws RunnerException, IOException, SerialException { - + // Make sure the user didn't hide the sketch folder ensureExistence(); @@ -1639,7 +1639,7 @@ public boolean exportApplet(String appletPath, boolean verbose) // } editor.status.progressNotice("Uploading..."); upload(appletFolder.getPath(), foundName, verbose); - editor.status.progressUpdate(100); + editor.status.progressUpdate(100); return true; } @@ -1659,7 +1659,7 @@ protected void size(String buildPath, String suggestedClassName) try { size = sizer.computeSize(); System.out.println("Binary sketch size: " + size + " bytes (of a " + - maxsize + " byte maximum)"); + maxsize + " byte maximum)"); } catch (RunnerException e) { System.err.println("Couldn't determine program size: " + e.getMessage()); } @@ -1677,7 +1677,7 @@ protected String upload(String buildPath, String suggestedClassName, boolean ver // download the program // - + uploader = new AvrdudeUploader(); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, @@ -1742,9 +1742,9 @@ public boolean exportApplicationPrompt() throws IOException, RunnerException { return false; } - + /** - * Export to application via GUI. + * Export to application via GUI. */ protected boolean exportApplication() throws IOException, RunnerException { return false; @@ -1870,7 +1870,7 @@ public boolean validExtension(String what) { * Returns the default extension for this editor setup. */ public String getDefaultExtension() { - return "pde"; + return "ino"; } static private List hiddenExtensions = Arrays.asList("ino", "pde"); diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index 218e9f3cc..a40fae7dd 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -57,7 +57,7 @@ public void init(Base base) { /** - * Make sure that .pde files are associated with processing.exe. + * Make sure that .ino files are associated with processing.exe. */ protected void checkAssociations() { try { @@ -82,13 +82,13 @@ protected void checkAssociations() { /** - * Associate .pde files with this version of Processing. + * Associate .ino files with this version of Processing. */ protected void setAssociations() throws UnsupportedEncodingException { if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, - "", ".pde") && + "", ".ino") && Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, - ".pde", "", DOC) && + ".ino", "", DOC) && Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, "", DOC) && Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "", @@ -136,8 +136,8 @@ protected void checkQuickTime() { e.printStackTrace(); } } - - + + /** * Remove extra quotes, slashes, and garbage from the Windows PATH. */