What IDE are you using? Creating a new tab in the PDE will create a new Class... I believe the Eclipse equivalent would be to right-click the package and select "New Class"... If you don't have that advanced an IDE, all it really does is create a new JAVA file...
I really need to stop answering questions without fully reading them, sorry...
Would Robot be of any help? That probably isn't the right solution, but I feel that I have to suggest something...
I have found a simple solution to this problem which came to me when I was writing the last post.
The solution is to create a blank pde file which is stored in the data folder of the Tool, then it is a simple matter of using the addFile() method in Sketch to add this as a new Tab.
How to do this Using the Tools Template I created a project in Eclipse.(in Windows 7), although it creates a data folder under the main project heading this does not appear to be included in the build, so create a new folder called data inside the src folder. In this data folder create a blank or template pde file. I have called this test.pde
In the Tools run() method the followwing 2 lines will copy the file to the sketch and add it as a new Tab
String s = editor.getBase().getSketchbookFolder().toString() + "\\tools\\##name##\\src\\data\\test.pde";
Obviously this is just the starting point the code would need to check if the tab already exists etc. but it works also the file does not have to be blank it could be like a template for something.
@fjenett just spotted your post I had thought of that but I must admit I quite like my solution. Thanks
Thanks for the File.seperator tip that will save me a lot of time.
The actual file to be used for the new tab is not a temporary file as it will have standard content that will act as a template for source code generated by the tool,
The soultion I proposed earlier in the 'how to' was a bad idea as it generates errors when creating the javadoc and causes the ant build to fail. The problem to me seems to be that although the Eclipse tool template has a data folder it is not copied accross to the distribution or to the sketchbook tools folder.
To resolve this I have deleted the now unneeded src/data folder and modified the ant build file adding the following code to appropriate locations in the generate.structure targetof build.xml
The actual tool opens a new JFrame and since this will have a complex GUI I decided to use Netbeans in tandem with Eclipse. Since Netbeans creates a .form file inside Eclipse's src folder this causes problems when creating the javadoc so in the generate.javadoc target I have modified the fileset tag to exclude .form files