From cb226508dd03def2583b4f2239e0d3d2d9e834a1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 6 Feb 2022 16:54:33 -0500 Subject: [PATCH] switch to "main" instead of "primary" for naming (discussion with Reas) --- app/src/processing/app/Base.java | 4 ++-- app/src/processing/app/Sketch.java | 33 +++++++++++++-------------- app/src/processing/app/ui/Recent.java | 4 ++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 2ec60055c..f0105ad82 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1005,13 +1005,13 @@ public class Base { //saveModeSettings(props, nextMode); sketch.updateModeProperties(nextMode, getDefaultMode()); handleClose(activeEditor, true); - Editor editor = handleOpen(sketch.getMainFilePath()); + Editor editor = handleOpen(sketch.getMainPath()); if (editor == null) { // the Mode change failed (probably code that's out of date) // re-open the sketch using the mode we were in before //saveModeSettings(props, oldMode); sketch.updateModeProperties(oldMode, getDefaultMode()); - handleOpen(sketch.getMainFilePath()); + handleOpen(sketch.getMainPath()); return false; } } else { diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index de0753d39..8814576ee 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -39,7 +39,6 @@ import java.awt.event.KeyEvent; import java.io.*; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import javax.swing.*; @@ -54,7 +53,7 @@ public class Sketch { private final Mode mode; /** main pde file for this sketch. */ - private File primaryFile; + private File mainFile; /** * Name of sketch, which is the name of main file @@ -118,8 +117,8 @@ public class Sketch { protected void load(String path) { - primaryFile = new File(path); - folder = primaryFile.getParentFile(); + mainFile = new File(path); + folder = mainFile.getParentFile(); /* // get the name of the sketch by chopping .pde or .java // off of the main file name @@ -170,7 +169,7 @@ public class Sketch { // start at 1, if it's at zero, don't bother for (int i = 1; i < codeCount; i++) { //if (code[i].file.getName().equals(mainFilename)) { - if (code[i].getFile().equals(primaryFile)) { + if (code[i].getFile().equals(mainFile)) { SketchCode temp = code[0]; code[0] = code[i]; code[i] = temp; @@ -615,7 +614,7 @@ public class Sketch { code[i].setFolder(newFolder); } // Save the path in case we need to remove it from the Recent menu - String oldPath = getMainFilePath(); + String oldPath = getMainPath(); // Update internal state to reflect the new location updateInternal(newFolder); @@ -1203,7 +1202,7 @@ public class Sketch { */ protected void updateInternal(File sketchFolder) { // reset all the state information for the sketch object - primaryFile = code[0].getFile(); + mainFile = code[0].getFile(); name = sketchFolder.getName(); folder = sketchFolder; @@ -1307,7 +1306,7 @@ public class Sketch { private void updateNameProperties() { // If the main file and the sketch name are not identical, // update sketch.properties. - String mainName = primaryFile.getName(); + String mainName = mainFile.getName(); String defaultName = name + "." + mode.getDefaultExtension(); try { @@ -1649,19 +1648,19 @@ public class Sketch { } - /** - * Returns a File object for the main .pde file for this sketch. - */ - public File getMainFile() { - return primaryFile; - } +// /** +// * Returns a File object for the main .pde file for this sketch. +// */ +// public File getMainFile() { +// return mainFile; +// } /** * Returns path to the main .pde file for this sketch. */ - public String getMainFilePath() { - return primaryFile.getAbsolutePath(); + public String getMainPath() { + return mainFile.getAbsolutePath(); } @@ -1875,7 +1874,7 @@ public class Sketch { @Override public boolean equals(Object another) { if (another instanceof Sketch) { - return getMainFilePath().equals(((Sketch) another).getMainFilePath()); + return getMainPath().equals(((Sketch) another).getMainPath()); } return false; } diff --git a/app/src/processing/app/ui/Recent.java b/app/src/processing/app/ui/Recent.java index b4d355046..5d0a4557e 100644 --- a/app/src/processing/app/ui/Recent.java +++ b/app/src/processing/app/ui/Recent.java @@ -240,7 +240,7 @@ public class Recent { synchronized static public void remove(Editor editor) { - int index = findRecord(editor.getSketch().getMainFilePath()); + int index = findRecord(editor.getSketch().getMainPath()); if (index != -1) { records.remove(index); } @@ -371,7 +371,7 @@ public class Recent { // } Record(Editor editor) { - this(editor.getSketch().getMainFilePath()); + this(editor.getSketch().getMainPath()); } String getName() {