From 91550c0dc08a29233682c2b9d24bf77696de271e Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Tue, 18 Nov 2014 05:26:34 +0530 Subject: [PATCH] Remove extra ways for references to be included --- app/src/processing/app/Editor.java | 8 ++---- app/src/processing/app/Library.java | 25 +------------------ .../app/contrib/ToolContribution.java | 25 ++----------------- app/src/processing/mode/java/JavaEditor.java | 4 +-- 4 files changed, 7 insertions(+), 55 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 0e8702652..acf63a6a9 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1279,12 +1279,8 @@ public abstract class Editor extends JFrame implements RunnerListener { e.printStackTrace(); } - 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()); + // Prepend with file:// and also encode spaces & other characters + Base.openURL(file.toURI().toString()); } diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java index 342143bc3..0d7ccf4b1 100644 --- a/app/src/processing/app/Library.java +++ b/app/src/processing/app/Library.java @@ -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 is one possible path + protected File referenceFile; // shortname/reference/index.html /** * Subfolder for grouping libraries in a menu. Basic subfolder support @@ -212,8 +212,6 @@ public class Library extends LocalContribution { // get the path for all .jar files in this code folder packageList = Base.packageListFromClassPath(getClassPath()); - - referenceFile = loadReferenceIndexFile(folder); } @@ -518,27 +516,6 @@ public class Library extends LocalContribution { } - /** - * @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 diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index aa6620b79..02583ea94 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -35,7 +35,7 @@ import processing.app.tools.Tool; public class ToolContribution extends LocalContribution implements Tool { private Tool tool; - private File referenceFile; // shortname/reference/index.html is one possible path + private File referenceFile; // shortname/reference/index.html static public ToolContribution load(File folder) { try { @@ -61,7 +61,7 @@ public class ToolContribution extends LocalContribution implements Tool { tool = (Tool) toolClass.newInstance(); } - referenceFile = loadReferenceIndexFile(folder); + referenceFile = new File(folder, "reference/index.html"); } @@ -158,27 +158,6 @@ public class ToolContribution extends LocalContribution implements 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 diff --git a/app/src/processing/mode/java/JavaEditor.java b/app/src/processing/mode/java/JavaEditor.java index 37d064d95..a9bcf1b59 100644 --- a/app/src/processing/mode/java/JavaEditor.java +++ b/app/src/processing/mode/java/JavaEditor.java @@ -340,8 +340,8 @@ public class JavaEditor extends Editor { Iterator iter = toolsList.iterator(); while (iter.hasNext()) { final ToolContribution toolContrib = iter.next(); - if (toolContrib.hasReference()) { - final File toolRef = toolContrib.getReferenceIndexFile(); + final File toolRef = new File(toolContrib.getFolder(), "reference/index.html"); + if (toolRef.exists()) { JMenuItem libRefItem = new JMenuItem(toolContrib.getName()); libRefItem.addActionListener(new ActionListener() {