mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
Tool and Lib References now show in Help menu
Removing LocalContribWithReference.java
This commit is contained in:
@@ -7,15 +7,13 @@ import processing.app.contrib.*;
|
||||
import processing.core.*;
|
||||
|
||||
|
||||
public class Library extends LocalContribWithReference {
|
||||
public class Library extends LocalContribution {
|
||||
static final String[] platformNames = PConstants.platformNames;
|
||||
|
||||
//protected File folder; // /path/to/shortname
|
||||
protected File libraryFolder; // shortname/library
|
||||
protected File examplesFolder; // shortname/examples
|
||||
|
||||
// Shifted to LocalContribWithReference
|
||||
// protected File referenceFile; // shortname/reference/index.html is one possible path
|
||||
protected File referenceFile; // shortname/reference/index.html is one possible path
|
||||
|
||||
/**
|
||||
* Subfolder for grouping libraries in a menu. Basic subfolder support
|
||||
@@ -112,9 +110,7 @@ public class Library extends LocalContribWithReference {
|
||||
|
||||
libraryFolder = new File(folder, "library");
|
||||
examplesFolder = new File(folder, "examples");
|
||||
|
||||
// Now done in LocalContribWithReference's ctor
|
||||
// referenceFile = loadReferenceIndexFile(folder);
|
||||
referenceFile = new File(folder, "reference/index.html");
|
||||
|
||||
File exportSettings = new File(libraryFolder, "export.txt");
|
||||
HashMap<String,String> exportTable = Base.readSettings(exportSettings);
|
||||
@@ -216,6 +212,8 @@ public class Library extends LocalContribWithReference {
|
||||
|
||||
// get the path for all .jar files in this code folder
|
||||
packageList = Base.packageListFromClassPath(getClassPath());
|
||||
|
||||
referenceFile = loadReferenceIndexFile(folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -518,4 +516,47 @@ public class Library extends LocalContribWithReference {
|
||||
public ContributionType getType() {
|
||||
return ContributionType.LIBRARY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param folder
|
||||
* The file object representing the base folder of the contribution
|
||||
* @return Returns a file object representing the index file of the reference
|
||||
*/
|
||||
protected File loadReferenceIndexFile(File folder) {
|
||||
final String potentialFileList[] = {
|
||||
"reference/index.html", "reference/index.htm",
|
||||
"documentation/index.html", "documentation/index.htm", "docs/index.html",
|
||||
"docs/index.htm", "documentation.html", "documentation.htm",
|
||||
"reference.html", "reference.htm", "docs.html", "docs.htm", "readme.txt" };
|
||||
|
||||
int i = 0;
|
||||
File potentialRef = new File(folder, potentialFileList[i]);
|
||||
while (!potentialRef.exists() && ++i < potentialFileList.length) {
|
||||
potentialRef = new File(folder, potentialFileList[i]);
|
||||
}
|
||||
return potentialRef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the object stored in the referenceFile field, which contains an
|
||||
* instance of the file object representing the index file of the reference
|
||||
*
|
||||
* @return referenceFile
|
||||
*/
|
||||
public File getReferenceIndexFile() {
|
||||
return referenceFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether the reference's index file indicated by referenceFile exists.
|
||||
*
|
||||
* @return true if and only if the file denoted by referenceFile exists; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean hasReference() {
|
||||
return referenceFile.exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package processing.app.contrib;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* A local contribution that comes with references.
|
||||
*/
|
||||
public abstract class LocalContribWithReference extends LocalContribution {
|
||||
|
||||
protected File referenceFile; // shortname/reference/index.html is one possible path
|
||||
|
||||
public LocalContribWithReference(File folder) {
|
||||
super(folder);
|
||||
referenceFile = loadReferenceIndexFile(folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param folder
|
||||
* The file object representing the base folder of the contribution
|
||||
* @return Returns a file object representing the index file of the reference
|
||||
*/
|
||||
protected File loadReferenceIndexFile(File folder) {
|
||||
final String potentialFileList[] = {
|
||||
"reference/index.html", "reference/index.htm",
|
||||
"documentation/index.html", "documentation/index.htm", "docs/index.html",
|
||||
"docs/index.htm", "documentation.html", "documentation.htm",
|
||||
"reference.html", "reference.htm", "docs.html", "docs.htm", "readme.txt" };
|
||||
|
||||
int i = 0;
|
||||
File potentialRef = new File(folder, potentialFileList[i]);
|
||||
while (!potentialRef.exists() && ++i < potentialFileList.length) {
|
||||
potentialRef = new File(folder, potentialFileList[i]);
|
||||
}
|
||||
return potentialRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object stored in the referenceFile field, which contains an
|
||||
* instance of the file object representing the index file of the reference
|
||||
*
|
||||
* @return referenceFile
|
||||
*/
|
||||
public File getReferenceIndexFile() {
|
||||
return referenceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the reference's index file indicated by referenceFile exists.
|
||||
*
|
||||
* @return true if and only if the file denoted by referenceFile exists; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean hasReference() {
|
||||
return referenceFile.exists();
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,10 @@ import processing.app.Editor;
|
||||
import processing.app.tools.Tool;
|
||||
|
||||
|
||||
public class ToolContribution extends LocalContribWithReference implements Tool {
|
||||
public class ToolContribution extends LocalContribution implements Tool {
|
||||
private Tool tool;
|
||||
|
||||
private File referenceFile; // shortname/reference/index.html is one possible path
|
||||
|
||||
static public ToolContribution load(File folder) {
|
||||
try {
|
||||
@@ -59,6 +60,8 @@ public class ToolContribution extends LocalContribWithReference implements Tool
|
||||
Class<?> toolClass = loader.loadClass(className);
|
||||
tool = (Tool) toolClass.newInstance();
|
||||
}
|
||||
|
||||
referenceFile = loadReferenceIndexFile(folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,4 +156,47 @@ public class ToolContribution extends LocalContribWithReference implements Tool
|
||||
public ContributionType getType() {
|
||||
return ContributionType.TOOL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param folder
|
||||
* The file object representing the base folder of the contribution
|
||||
* @return Returns a file object representing the index file of the reference
|
||||
*/
|
||||
protected File loadReferenceIndexFile(File folder) {
|
||||
final String potentialFileList[] = {
|
||||
"reference/index.html", "reference/index.htm",
|
||||
"documentation/index.html", "documentation/index.htm", "docs/index.html",
|
||||
"docs/index.htm", "documentation.html", "documentation.htm",
|
||||
"reference.html", "reference.htm", "docs.html", "docs.htm", "readme.txt" };
|
||||
|
||||
int i = 0;
|
||||
File potentialRef = new File(folder, potentialFileList[i]);
|
||||
while (!potentialRef.exists() && ++i < potentialFileList.length) {
|
||||
potentialRef = new File(folder, potentialFileList[i]);
|
||||
}
|
||||
return potentialRef;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the object stored in the referenceFile field, which contains an
|
||||
* instance of the file object representing the index file of the reference
|
||||
*
|
||||
* @return referenceFile
|
||||
*/
|
||||
public File getReferenceIndexFile() {
|
||||
return referenceFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether the reference's index file indicated by referenceFile exists.
|
||||
*
|
||||
* @return true if and only if the file denoted by referenceFile exists; false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean hasReference() {
|
||||
return referenceFile.exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user