blob: 2ecaa9552d29dbac27fc314ce8a9268e2f064d45 [file] [log] [blame]
<html>
<head>
<title>Developing Scripts in NetBeans</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<a name="top"></a>
<h1>Developing Scripts in NetBeans</h1>
This document describes how to set up NetBeans for Office Scripting
and how to write a simple script using NetBeans. You can download
the NetBeans IDE from the <a href="http://www.netbeans.org/ide/download.html">
NetBeans download page</a>.
<h2>Contents:</h2>
<ul>
<li><p><a href="#prerequisites">Pre-requisites</a>
<li><p><a href="#recipe-create">Creating a Parcel Recipe</a>
<li><p><a href="#recipe-actions">Actions available for Parcel Recipes</a>
<li><p><a href="#parcel-actions">Actions available for Script Parcels</a>
<li><p><a href="#document-actions">Actions available for Office Documents</a>
<li><p><a href="#debugging">Debugging Java Office scripts in NetBeans</a>
<li><p><a href="#troubleshooting">Troubleshooting</a>
</ul>
<a name="prerequisites"></a>
<h2>Pre-requisites</h2>
<ul>
<!-- <li>You need to install the Office API support module for NetBeans which
can be obtained from
<a href="http://api.openoffice.org/common/man/IDEintegration/OfficeNetBeansIntegration.html">here</a>.
This module must be installed in NetBeans if you wish to use the
Office API in your scripts.
-->
<li>The Office Scripting module works with NetBeans 3.4
<li>You should have installed the Office Scripting module during the
installation process for the Scripting Framework. If you have not installed
it, see the <a href="install-guide.html">Installation Guide</a> for
instructions on how to install.
<li>On Linux, you will need to ensure that your DISPLAY environment
variable is set to &lt;your hostname&gt;:0 in the shell from which you
start NetBeans to work around a problem with Java GUIs in Office.
<li>Create a directory somewhere on your machine in which you will develop
your scripts.
</ul>
Now start NetBeans and mount the directory you created using the
File/Mount Filesystem menu option. You also need to mount all of the jar
files in the &lt;Office installation&gt;/program/classes directory in
order to access the Office API from your scripts.
<p>
<a href="#top">Top</a>
<p>
<a name="recipe-create"></a>
<h2>Creating a Parcel Recipe</h2>
Office scripts are delivered in Script Parcels. Like Office documents they
are zip files. Script Parcels have the .sxp extension. Script Parcels are
generated from Parcel Recipes where all of the files that are necessary
to create the parcel are put together. To create a new Parcel Recipe:
<ul>
<li>Right click on your mounted filesystem
<li>Select New/Office Scripting/Parcel Recipe
<li>In the New Wizard window that appears enter a name for your Parcel Recipe
<li>Select a language for your Parcel Recipe from the Initial Script
Language dropdown list.
<li>Click the Finish button to create your Parcel Recipe
</ul>
This will create a new directory with the name you chose. In this directory
you will find a Contents directory where all of your files will
be placed. An empty stub file will have been placed in the
Contents directory and can be used as a starting point for your script.
<p>
<b>Note:</b> To add further empty stub scripts to your Parcel Recipe, right
click on the Contents directory and use the New/Office Scripting/Empty Script
menu item.
<p>
<a href="#top">Top</a>
<p>
<a name="recipe-actions"></a>
<h2>Actions available for Parcel Recipe</h2>
If the user right clicks on the parcel directory they should be
able to use the following actions:
<ul>
<li><b>Compile:</b> Compiles all of the .java files in the Parcel Recipe
<li><b>Build:</b> Compiles all of the .java files in the Parcel Recipe.
It then searches for valid Office scripts in the language you selected
in the Contents directory files and pops up a dialog
which allows you to select which Java methods or BeanShell scripts
you wish to export as Office scripts.
Once you have finish making your selections, it creates a
&lt;Parcel Recipe Name&gt;.sxp Script Parcel file in the Parcel
Recipe directory. You can configure what files are put into the
Script Parcel using the File Filter property. If you script includes any
jar files that need to be in the classpath when it is executed you should
add them to the Classpath property of your Parcel Recipe.
<li><b>Configure:</b> This pops up the Configure dialog, which allows you
to select what Office scripts to export. Any changes you make in
this dialog will <b>only</b> appear in your Script Parcel after you run
Build again.
</ul>
<p>
<a href="#top">Top</a>
<p>
<a name="parcel-actions"></a>
<h2>Actions available for Script Parcels</h2>
Script Parcels supports only one action:
<ul>
<li><b>Deploy:</b> This will deploy the Script Parcel to an Office Document
or to an Office installation. If the Script Parcel already exists
in the target, you will be asked whether you want to overwrite.
</ul>
<p>
<b>Note:</b> If you deploy a Script Parcel to an OpenOffice.org
installation you need to use the Tools/Scripting Add-on's/Refresh All Scripts
menu item for the new script to appear in the Assign Script dialog.
<p>
<b>Note:</b> You can also deploy to Office documents within NetBeans
using drag and drop or cut and paste.
<p>
<a href="#top">Top</a>
<p>
<a name="document-actions"></a>
<h2>Actions available for Office Documents</h2>
Office Documents are also recognised by NetBeans. Any parcels contained
in the document will be displayed as nodes of the Office document. Deleting
one of these nodes will remove the Script Parcel from the document. You
should ensure that the document is not open in OpenOffice.org before deleting
any parcels it may contain.
Office documents support the standard Delete, Cut and Copy actions and
the following custom actions:
<ul>
<li><b>Open:</b> This will open the document in Office using the path
in the Office Settings property to find the Office installation.
<p>
If the path to Office is not valid, an error dialog will be popped
up informing the user that they need to set their Path to Office
Installation property. This setting can be changed by bringing
up the Tools/Options dialog and changing
IDE Configuration/Server and External Tool Settings/Office Settings
</ul>
<p>
<a href="#top">Top</a>
<p>
<a name="debugging"></a>
<h2>Debugging Java Office scripts in NetBeans</h2>
<ul>
<li>Follow the instructions at
<a href="http://api.openoffice.org/common/man/IDEintegration/OfficeNetBeansIntegration.html#Debugging">
Debugging Java components in NetBeans/Forte for Java</a>
to set up your Office installation to allow debugging of the JVM.
<li>Start OpenOffice and run one of your Java scripts. This will
make sure the JVM is running.
<li>Attach to Office JVM using the NetBeans Debug/Start Session/Attach...
menu option.
<li>Load a script source in NetBeans and set up breakpoints using
Debug/New Breakpoint... menu option.
<li>Run the script in Office.
</ul>
<p>
<b>Note:</b> As the BeanShell scripting language does not support debugging
it is not possible to debug BeanShell Office scripts from NetBeans. You
can however use the Interactive BeanShell scripting menu item under the Tools
menu in OpenOffice.org to test BeanShell code. Just enter any BeanShell code
and hit the Eval button to execute it.
<p>
<a href="#top">Top</a>
<p>
<a name="troubleshooting"></a>
<h2>Troubleshooting</h2>
<ul>
<li><p>If you encounter problems when developing or deploying scripts in
NetBeans, one thing you can try is to move your NetBeans settings directory
(.netbeans on UNIX, netbeans in Windows - can be found in your home
directory) to another name and restart NetBeans.
<li><p>The Choose What to Export as Scripts dialog <b>only</b> displays
methods which are defined within class files, it will not display
methods in class files which are within jar files in the Parcel Recipe.
<li><p>If you include package directives in the Java source files of your
Parcel Recipe, you should ensure that the source files are in the appropriate
directories for your package directives. This is because the
default NetBeans compiler implementation does not use the -d switch to the
Java compiler. As a result class files do not get placed in the appropriate
directories and methods in these classes will not appear in the
Choose What to Export as Scripts dialog.
<p>
There are a couple of workarounds for this problem:
<p>
<ol>
<li>Use the <a href="commandline-devguide.html">command line tools</a>
<li>Set the Target flag in the Tools/Options window under
Building/Compiler Types/Internal Compilation
</ol>
</ul>
<p>
<a href="#top">Top</a>
<hr>
Last Modified: Tue Mar 12 11:40:28 GMT 2003
</body>
</html>