MCPcopy Index your code
hub / github.com/processing/processing / ToolContribution

Class ToolContribution

app/src/processing/app/contrib/ToolContribution.java:34–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34public class ToolContribution extends LocalContribution implements Tool, Comparable<ToolContribution> {
35 private Tool tool;
36
37 private File referenceFile; // shortname/reference/index.html
38
39 static public ToolContribution load(File folder) {
40 try {
41 return new ToolContribution(folder);
42 } catch (IgnorableException ig) {
43 Messages.log(ig.getMessage());
44
45 } catch (VerifyError ve) { // incompatible
46 // avoid the excessive error spew that happens here
47
48 } catch (NoClassDefFoundError ncdfe) {
49 if (ncdfe.getMessage().contains("processing/app/Editor")) {
50 System.err.println("The Editor class has moved to the processing.app.ui package in Processing 3");
51 }
52
53 } catch (Throwable e) { // unknown error
54 e.printStackTrace();
55 }
56 return null;
57 }
58
59
60 private ToolContribution(File folder) throws Throwable {
61 super(folder);
62
63 String className = initLoader(null);
64 if (className != null) {
65 Class<?> toolClass = loader.loadClass(className);
66 tool = (Tool) toolClass.getDeclaredConstructor().newInstance();
67 }
68
69 referenceFile = new File(folder, "reference/index.html");
70 }
71
72
73 /**
74 * Method to close the ClassLoader so that the archives are no longer
75 * "locked" and a tool can be removed without restart.
76 */
77 public void clearClassLoader() {
78 try {
79 ((URLClassLoader) this.loader).close();
80 } catch (IOException e1) {
81 e1.printStackTrace();
82 }
83 }
84
85
86// static protected List<File> discover(File folder) {
87// File[] folders = listCandidates(folder, "tool");
88// if (folders == null) {
89// return new ArrayList<File>();
90// } else {
91// return Arrays.asList(folders);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected