public class Sketch
extends Object
Constructor and Description |
---|
Sketch(String path,
Editor editor)
path is location of the main .pde file, because this is also
simplest to use when opening the file from the finder/explorer.
|
Sketch(String path,
Mode mode)
Used by the command-line version to create a sketch object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addFile(File sourceFile)
Add a file to the sketch.
|
static String |
checkName(String origName)
Convert to sanitized name and alert the user
if changes were made.
|
void |
ensureExistence()
Make sure the sketch hasn't been moved or deleted by a nefarious user.
|
SketchCode[] |
getCode() |
SketchCode |
getCode(int index) |
int |
getCodeCount() |
File |
getCodeFolder()
Returns the location of the sketch's code folder.
|
int |
getCodeIndex(SketchCode who) |
SketchCode |
getCurrentCode() |
int |
getCurrentCodeIndex() |
File |
getDataFolder()
Returns the location of the sketch's data folder.
|
File |
getFolder()
Returns the sketch folder.
|
File |
getMainFile()
Returns a File object for the main .pde file for this sketch.
|
String |
getMainFilePath()
Returns path to the main .pde file for this sketch.
|
String |
getMainProgram() |
Mode |
getMode() |
String |
getName()
Returns the name of this sketch.
|
void |
getSketchCodeFiles(List<String> outFilenames,
List<String> outExtensions) |
void |
handleAddFile()
Prompt the user for a new file to the sketch, then call the
other addFile() function to actually add it.
|
void |
handleDeleteCode()
Remove a piece of code from the sketch and from the disk.
|
void |
handleNewCode()
Handler for the New Code menu option.
|
void |
handleNextCode()
Move to the next tab.
|
void |
handlePrevCode()
Move to the previous tab.
|
void |
handleRenameCode()
Handler for the Rename Code menu option.
|
boolean |
hasCodeFolder() |
boolean |
hasDataFolder() |
boolean |
isModified() |
boolean |
isReadOnly()
Returns true if this is a read-only sketch.
|
static boolean |
isSanitaryName(String name)
Return true if the name is valid for a Processing sketch.
|
boolean |
isSaving() |
boolean |
isUntitled() |
void |
loadNewTab(String filename,
String ext,
boolean newAddition)
Load a tab that the user added to the sketch or modified with an external
editor.
|
File |
makeTempFolder()
Create a temporary folder that includes the sketch's name in its title.
|
File |
prepareCodeFolder()
Create the code folder if it does not exist already.
|
File |
prepareDataFolder()
Create the data folder if it does not exist already.
|
void |
reload()
Reload the current sketch.
|
void |
removeCode(SketchCode which)
Remove a SketchCode from the list of files without deleting its file.
|
static String |
sanitizeName(String origName)
Produce a sanitized name that fits our standards for likely to work.
|
boolean |
save()
Save all code in the current sketch.
|
boolean |
saveAs()
Handles 'Save As' for a sketch.
|
void |
setCurrentCode(int which)
Change what file is currently being edited.
|
void |
setCurrentCode(String findName)
Internal helper function to set the current tab based on a name.
|
void |
setModified(boolean state)
Sets the modified value for the code in the frontmost tab.
|
void |
setUntitled(boolean untitled) |
void |
updateSketchCodes()
Ensure that all SketchCodes are up-to-date, so that sc.save() works.
|
public Sketch(String path, Mode mode)
path
- location of the main .pde filemode
- what flavor of sketch we're dealing with.public Sketch(String path, Editor editor) throws IOException
IOException
public void getSketchCodeFiles(List<String> outFilenames, List<String> outExtensions)
public void reload()
public void loadNewTab(String filename, String ext, boolean newAddition)
public void handleNewCode()
public void handleRenameCode()
public void handleDeleteCode()
public void removeCode(SketchCode which)
handleDeleteCode()
public void handlePrevCode()
public void handleNextCode()
public void setModified(boolean state)
public boolean isModified()
public void updateSketchCodes()
public boolean save() throws IOException
IOException
public boolean saveAs() throws IOException
This basically just duplicates the current sketch folder to a new location, and then calls 'Save'. (needs to take the current state of the open files and save them to the new folder.. but not save over the old versions for the old sketch..)
Also removes the previously-generated .class and .jar files, because they can cause trouble.
IOException
public boolean isSaving()
public void handleAddFile()
public boolean addFile(File sourceFile)
public void setCurrentCode(int which)
public void setCurrentCode(String findName)
findName
- the file name (not pretty name) to be shownpublic File makeTempFolder()
public void ensureExistence()
public boolean isReadOnly()
public String getName()
public File getMainFile()
public String getMainFilePath()
public File getFolder()
public File getDataFolder()
public boolean hasDataFolder()
public File prepareDataFolder()
public File getCodeFolder()
public boolean hasCodeFolder()
public File prepareCodeFolder()
public SketchCode[] getCode()
public int getCodeCount()
public SketchCode getCode(int index)
public int getCodeIndex(SketchCode who)
public SketchCode getCurrentCode()
public int getCurrentCodeIndex()
public String getMainProgram()
public void setUntitled(boolean untitled)
public boolean isUntitled()
public static String checkName(String origName)
public static boolean isSanitaryName(String name)
public static String sanitizeName(String origName)
public Mode getMode()