mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Added many, many more ways for references to be included
This commit is contained in:
@@ -1278,8 +1278,13 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Prepend with file:// and also encode spaces & other characters
|
||||
Base.openURL(file.toURI().toString());
|
||||
|
||||
if (file.toString().endsWith(".txt"))
|
||||
// To enable readme.txt files to open as well
|
||||
Base.openFolder(file);
|
||||
else
|
||||
// Prepend with file:// and also encode spaces & other characters
|
||||
Base.openURL(file.toURI().toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Library extends LocalContribution {
|
||||
//protected File folder; // /path/to/shortname
|
||||
protected File libraryFolder; // shortname/library
|
||||
protected File examplesFolder; // shortname/examples
|
||||
protected File referenceFile; // shortname/reference/index.html
|
||||
protected File referenceFile; // shortname/reference/index.html is one possible path
|
||||
|
||||
/**
|
||||
* Subfolder for grouping libraries in a menu. Basic subfolder support
|
||||
@@ -110,7 +110,7 @@ public class Library extends LocalContribution {
|
||||
|
||||
libraryFolder = new File(folder, "library");
|
||||
examplesFolder = new File(folder, "examples");
|
||||
referenceFile = new File(folder, "reference/index.html");
|
||||
referenceFile = loadReferenceIndexFile(folder);
|
||||
|
||||
File exportSettings = new File(libraryFolder, "export.txt");
|
||||
HashMap<String,String> exportTable = Base.readSettings(exportSettings);
|
||||
@@ -284,6 +284,22 @@ public class Library extends LocalContribution {
|
||||
}
|
||||
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasReference() {
|
||||
return referenceFile.exists();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ import processing.app.tools.Tool;
|
||||
public class ToolContribution extends LocalContribution implements Tool {
|
||||
private Tool tool;
|
||||
|
||||
|
||||
protected File referenceFile; // shortname/reference/index.html is one possible path
|
||||
|
||||
static public ToolContribution load(File folder) {
|
||||
try {
|
||||
return new ToolContribution(folder);
|
||||
@@ -53,6 +54,7 @@ public class ToolContribution extends LocalContribution implements Tool {
|
||||
|
||||
private ToolContribution(File folder) throws Exception {
|
||||
super(folder);
|
||||
referenceFile = loadReferenceIndexFile();
|
||||
|
||||
String className = initLoader(null);
|
||||
if (className != null) {
|
||||
@@ -153,4 +155,29 @@ public class ToolContribution extends LocalContribution implements Tool {
|
||||
public ContributionType getType() {
|
||||
return ContributionType.TOOL;
|
||||
}
|
||||
|
||||
public File loadReferenceIndexFile() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public File getReferenceIndexFile() {
|
||||
return referenceFile;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasReference() {
|
||||
return referenceFile.exists();
|
||||
}
|
||||
}
|
||||
@@ -313,8 +313,8 @@ public class JavaEditor extends Editor {
|
||||
Iterator<ToolContribution> iter = toolsList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final ToolContribution toolContrib = iter.next();
|
||||
final File toolRef = new File(toolContrib.getFolder(), "reference/index.html");
|
||||
if (toolRef.exists()) {
|
||||
if (toolContrib.hasReference()) {
|
||||
final File toolRef = toolContrib.getReferenceIndexFile();
|
||||
JMenuItem libRefItem = new JMenuItem(toolContrib.getName());
|
||||
libRefItem.addActionListener(new ActionListener() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user