1

I've recently been experimenting with an ANT script for setting up a small application (with various paths and other variables) using AntForm. AntForm has a file selector, but I would have to write something custom to validate the path (i.e., make sure it is the path to the thing that I asked the user for). I was wondering if anyone had experience with using using AntForm in this way. What I want is something like a Wizard page with a file selector, and when the user clicks "next" or when the file is selected some sort of a validation task is executed, and the wizard proceeds from there. The absolute best would be if I could gray out the "next" button or add an "invalid path" message, but that's getting a little complicated for what it seems that AntForm was designed for. Below is an example XML file to get started. Note that it expects AntForm.jar to be in the ./bin directory.

<?xml version="1.0"?>
<project name="My App Setup" default="getPath" basedir=".">

    <property name="app.dir" value="${user.home}/appXYZ"/>

    <path id="runtime.cp">
        <pathelement location="bin/"/>
        <fileset dir="lib" includes="antform.jar"/>
    </path>
    <taskdef name="antform" classname="com.sardak.antform.AntForm"
        classpathref="runtime.cp"/>
    <taskdef name="antmenu" classname="com.sardak.antform.AntMenu"
        classpathref="runtime.cp"/>


    <!-- test wizard behaviour, step 1 -->
    <target name="getPath" 
        description="Check for App XYZ in path">
        <antform title="Choose directory of app xyz"
            lookAndFeel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
            okMessage="Next"
            nextTarget="wizard2"
            >
            <fileSelectionProperty 
                label="App XYZ Distribution"
                property="app.dir"
                directoryChooser="true" />
            <!-- TODO: how to validate and choose where to go from this form? -->
        </antform>
    </target>

        <!-- test wizard behaviour, step 1 -->
    <target name="wizard2" 
        description="continue setup">
        <antform title="did we validate?"
            lookAndFeel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
            okMessage="Finish"
            previousTarget="getPath"
            >

            <label>Did we validate the path before we got here?</label>
        </antform>
    </target>
</project>
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
  • See the following answer for a related issue. Not the same question but perhaps that solution (using XSLT) could be applied? Are you using subversion?: http://stackoverflow.com/questions/3530181/getting-directory-listing-from-svn-for-use-in-ant-dropdown/3534025#3534025 – Mark O'Connor Dec 08 '12 at 08:53
  • We are using subversion, but will be switching to Git eventually. I'm not quite sure how the answer relates. I need the user to provide the path to an external application, one that isn't versioned by us, and for the form to tell the user if it isn't valid and to refuse to continue without a valid path. – Nate Glenn Dec 08 '12 at 19:23

0 Answers0