|
7 | 7 | import processing.core.*; |
8 | 8 |
|
9 | 9 |
|
10 | | -public class Library extends LocalContribWithReference { |
| 10 | +public class Library extends LocalContribution { |
11 | 11 | static final String[] platformNames = PConstants.platformNames; |
12 | 12 |
|
13 | 13 | //protected File folder; // /path/to/shortname |
14 | 14 | protected File libraryFolder; // shortname/library |
15 | 15 | protected File examplesFolder; // shortname/examples |
16 | | - |
17 | | - // Shifted to LocalContribWithReference |
18 | | -// protected File referenceFile; // shortname/reference/index.html is one possible path |
| 16 | + protected File referenceFile; // shortname/reference/index.html is one possible path |
19 | 17 |
|
20 | 18 | /** |
21 | 19 | * Subfolder for grouping libraries in a menu. Basic subfolder support |
@@ -112,9 +110,7 @@ private Library(File folder, String groupName) { |
112 | 110 |
|
113 | 111 | libraryFolder = new File(folder, "library"); |
114 | 112 | examplesFolder = new File(folder, "examples"); |
115 | | - |
116 | | - // Now done in LocalContribWithReference's ctor |
117 | | - // referenceFile = loadReferenceIndexFile(folder); |
| 113 | + referenceFile = new File(folder, "reference/index.html"); |
118 | 114 |
|
119 | 115 | File exportSettings = new File(libraryFolder, "export.txt"); |
120 | 116 | HashMap<String,String> exportTable = Base.readSettings(exportSettings); |
@@ -216,6 +212,8 @@ private Library(File folder, String groupName) { |
216 | 212 |
|
217 | 213 | // get the path for all .jar files in this code folder |
218 | 214 | packageList = Base.packageListFromClassPath(getClassPath()); |
| 215 | + |
| 216 | + referenceFile = loadReferenceIndexFile(folder); |
219 | 217 | } |
220 | 218 |
|
221 | 219 |
|
@@ -518,4 +516,47 @@ static protected void list(File folder, ArrayList<Library> libraries) { |
518 | 516 | public ContributionType getType() { |
519 | 517 | return ContributionType.LIBRARY; |
520 | 518 | } |
| 519 | + |
| 520 | + |
| 521 | + /** |
| 522 | + * @param folder |
| 523 | + * The file object representing the base folder of the contribution |
| 524 | + * @return Returns a file object representing the index file of the reference |
| 525 | + */ |
| 526 | + protected File loadReferenceIndexFile(File folder) { |
| 527 | + final String potentialFileList[] = { |
| 528 | + "reference/index.html", "reference/index.htm", |
| 529 | + "documentation/index.html", "documentation/index.htm", "docs/index.html", |
| 530 | + "docs/index.htm", "documentation.html", "documentation.htm", |
| 531 | + "reference.html", "reference.htm", "docs.html", "docs.htm", "readme.txt" }; |
| 532 | + |
| 533 | + int i = 0; |
| 534 | + File potentialRef = new File(folder, potentialFileList[i]); |
| 535 | + while (!potentialRef.exists() && ++i < potentialFileList.length) { |
| 536 | + potentialRef = new File(folder, potentialFileList[i]); |
| 537 | + } |
| 538 | + return potentialRef; |
| 539 | + } |
| 540 | + |
| 541 | + |
| 542 | + /** |
| 543 | + * Returns the object stored in the referenceFile field, which contains an |
| 544 | + * instance of the file object representing the index file of the reference |
| 545 | + * |
| 546 | + * @return referenceFile |
| 547 | + */ |
| 548 | + public File getReferenceIndexFile() { |
| 549 | + return referenceFile; |
| 550 | + } |
| 551 | + |
| 552 | + |
| 553 | + /** |
| 554 | + * Tests whether the reference's index file indicated by referenceFile exists. |
| 555 | + * |
| 556 | + * @return true if and only if the file denoted by referenceFile exists; false |
| 557 | + * otherwise. |
| 558 | + */ |
| 559 | + public boolean hasReference() { |
| 560 | + return referenceFile.exists(); |
| 561 | + } |
521 | 562 | } |
0 commit comments