Processing 3.0a4 fails to create new tab when adding a file

edited October 2014 in Create & Announce Tools

I have created an empty tool using the latest template and have added the minimum source code to add a pde file to the sketch.

When the tool below is run it should add the gui.pde file from the root of the tools folder into the active sketch and show the 'gui' tab.

Now this works fully as expected in 2.2.1. BUT in 3.04a it copies the file because I can see it in Finder but the tab does not appear in the PDE and I get the exception shown below.

So my questions is -

Is this the correct way to add a file/tab in Processing 3?

package template.tool;

import java.io.File;

import processing.app.*;
import processing.app.tools.*;

public class HelloTool implements Tool {

    public static Editor editor = null;

    public String getMenuTitle() {
        return "Hello Tool";
    }

    public void init(Editor theEditor) {
        editor = theEditor;
    }

    public void run() {
        Sketch sketch = editor.getSketch();
        // Get reference to a file in root of the tools folder
        File file = new File(Base.getSketchbookToolsFolder(), "gui.pde");
        System.out.println(file);
        sketch.addFile(file);   
    }

}


Could not createInput() for /Users/peter/Documents/Processing/P300_1/gui.pde
java.io.FileNotFoundException: /Users/peter/Documents/Processing/P300_1/gui.pde (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at processing.core.PApplet.createInput(PApplet.java:7395)
    at processing.core.PApplet.loadStrings(PApplet.java:7483)
    at processing.app.Base.loadFile(Base.java:2513)
    at processing.app.SketchCode.load(SketchCode.java:275)
    at processing.app.SketchCode.<init>(SketchCode.java:88)
    at processing.app.Sketch.addFile(Sketch.java:1160)
    at template.tool.HelloTool.run(Unknown Source)
    at processing.app.contrib.ToolContribution.run(ToolContribution.java:140)
    at processing.app.Editor$35.actionPerformed(Editor.java:1065)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)

Answers

Sign In or Register to comment.