public abstract class Mode
extends Object
Modifier and Type | Field and Description |
---|---|
List<Library> |
contribLibraries |
List<Library> |
coreLibraries |
Modifier and Type | Method and Description |
---|---|
File |
addTemplateFiles(File sketchFolder,
String sketchName)
Add files to a folder to create an empty sketch.
|
DefaultMutableTreeNode |
buildSketchbookTree() |
boolean |
canEdit(File f) |
abstract Editor |
createEditor(Base base,
String path,
EditorState state)
Create a new editor associated with this mode.
|
Library |
findLibraryByName(String libName)
Checks coreLibraries and contribLibraries for a library with the specified name
|
boolean |
getBoolean(String attribute) |
ClassLoader |
getClassLoader() |
Color |
getColor(String attribute) |
File |
getContentFile(String path) |
InputStream |
getContentStream(String path) |
Library |
getCoreLibrary() |
abstract String |
getDefaultExtension()
Returns the default extension for this editor setup.
|
File[] |
getExampleCategoryFolders()
Override this to control the order of the first set of example folders
and how they appear in the examples window.
|
File |
getExamplesFolder() |
abstract String[] |
getExtensions()
Returns a String[] array of proper extensions.
|
File |
getFolder()
Get the folder where this mode is stored.
|
Font |
getFont(String attribute) |
String |
getIdentifier()
Get an identifier that can be used to resurrect this mode and connect it
to a sketch.
|
abstract String[] |
getIgnorable()
Get array of file/directory names that needn't be copied during "Save As".
|
JMenu |
getImportMenu() |
int |
getInteger(String attribute) |
File[] |
getKeywordFiles()
To add additional keywords, or to grab them from another mode, override
this function.
|
File |
getLibrariesFolder() |
Library |
getLibrary(String pkgName) |
String |
getModuleExtension()
Returns the appropriate file extension to use for auxilliary source files in a sketch.
|
File |
getReferenceFolder() |
String |
getString(String attribute) |
SyntaxStyle |
getStyle(String attribute) |
File |
getTemplateFolder() |
abstract String |
getTitle()
Return the pretty/printable/menu name for this mode.
|
TokenMarker |
getTokenMarker() |
TokenMarker |
getTokenMarker(SketchCode code)
Specialized version of getTokenMarker() that can be overridden to
provide different TokenMarker objects for different file types.
|
JMenu |
getToolbarMenu() |
boolean |
hideExtension(String what)
True if the specified extension should be hidden when shown on a tab.
|
void |
insertImportMenu(JMenu sketchMenu)
Re-insert the Import Library menu.
|
void |
insertToolbarRecentMenu() |
boolean |
isDefaultExtension(SketchCode code)
True if the specified code has the default file extension.
|
boolean |
isDefaultExtension(String what)
True if the specified extension is the default file extension.
|
ImageIcon |
loadIcon(String filename)
Get an ImageIcon object from the Mode folder.
|
Image |
loadImage(String filename)
Get an image object from the mode folder.
|
Image |
loadImageX(String filename) |
String |
lookupReference(String keyword)
Returns the HTML filename (including path prefix if necessary)
for this keyword, or null if it doesn't exist.
|
Image |
makeGradient(String attribute,
int wide,
int high) |
void |
prepareExportFolder(File targetFolder)
Create a fresh applet/application folder if the 'delete target folder'
pref has been set in the preferences.
|
void |
rebuildExamplesFrame() |
void |
rebuildImportMenu() |
void |
rebuildLibraryList() |
void |
rebuildSketchbookFrame()
Sketchbook has changed, update it on next viewing.
|
void |
removeImportMenu(JMenu sketchMenu)
Rather than re-building the library menu for every open sketch (very slow
and prone to bugs when updating libs, particularly with the contribs mgr),
share a single instance across all windows.
|
void |
removeToolbarRecentMenu() |
boolean |
requireExampleCompatibility()
Require examples to explicitly state that they're compatible with this
Mode before they're included.
|
void |
setClassLoader(ClassLoader loader) |
void |
setupGUI()
Setup additional elements that are only required when running with a GUI,
rather than from the command-line.
|
void |
showExamplesFrame() |
void |
showSketchbookFrame() |
String |
toString() |
boolean |
validExtension(String what)
Check this extension (no dots, please) against the list of valid
extensions.
|
public List<Library> coreLibraries
public List<Library> contribLibraries
public Mode(Base base, File folder)
public File[] getKeywordFiles()
public void setClassLoader(ClassLoader loader)
public ClassLoader getClassLoader()
public void setupGUI()
public File getContentFile(String path)
public InputStream getContentStream(String path) throws FileNotFoundException
FileNotFoundException
public File addTemplateFiles(File sketchFolder, String sketchName) throws IOException
sketchFolder
- the directory where the new sketch should livesketchName
- the name of the new sketchIOException
- if the file somehow already existspublic File getTemplateFolder()
public abstract String getTitle()
public String getIdentifier()
public abstract Editor createEditor(Base base, String path, EditorState state) throws EditorException
EditorException
public File getFolder()
public File getExamplesFolder()
public File getLibrariesFolder()
public File getReferenceFolder()
public void rebuildLibraryList()
public Library getCoreLibrary()
public Library getLibrary(String pkgName) throws SketchException
SketchException
public JMenu getToolbarMenu()
public void insertToolbarRecentMenu()
public void removeToolbarRecentMenu()
public void removeImportMenu(JMenu sketchMenu)
sketchMenu
- the Sketch menu that's currently activepublic void insertImportMenu(JMenu sketchMenu)
sketchMenu
- the Sketch menu that's currently activepublic JMenu getImportMenu()
public void rebuildImportMenu()
public boolean requireExampleCompatibility()
public File[] getExampleCategoryFolders()
public void rebuildExamplesFrame()
public void showExamplesFrame()
public DefaultMutableTreeNode buildSketchbookTree()
public void rebuildSketchbookFrame()
public void showSketchbookFrame()
public ImageIcon loadIcon(String filename)
public Image loadImage(String filename)
public Image loadImageX(String filename)
public String lookupReference(String keyword)
public TokenMarker getTokenMarker(SketchCode code)
code
- the code for which we need a TokenMarkerpublic TokenMarker getTokenMarker()
public String getString(String attribute)
public boolean getBoolean(String attribute)
public int getInteger(String attribute)
public Color getColor(String attribute)
public Font getFont(String attribute)
public SyntaxStyle getStyle(String attribute)
public Image makeGradient(String attribute, int wide, int high)
public boolean hideExtension(String what)
public boolean isDefaultExtension(SketchCode code)
public boolean isDefaultExtension(String what)
public boolean canEdit(File f)
f
- File to be checked against this mode's accepted extensions.public boolean validExtension(String what)
public abstract String getDefaultExtension()
public String getModuleExtension()
Modes that do not override this function will get the default behavior of returning the default extension.
public abstract String[] getExtensions()
public abstract String[] getIgnorable()
public Library findLibraryByName(String libName)
libName
- the name of the library to findpublic void prepareExportFolder(File targetFolder)
public String toString()
toString
in class Object