Changeset 10299


Ignore:
Timestamp:
2005-07-25T16:36:00+12:00 (19 years ago)
Author:
kjdon
Message:

made this more general - now specify what user and pword properties should be set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/anttasks/MyGetUserAndPassword.java

    r9874 r10299  
    2626/** A new ant task to prompt the user for username and password.
    2727 * To use this task, the compiled class must be put in the classpath. add a taskdef line to the build.xml:
    28  * <taskdef name="getuserandpassword" classname="MyGetUserAndPassword" />
     28 * <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" />
    2929 * and call it like the following:
    30  *  <getuserandpassword message="a message to display at the top of the dialog"
    31  * username="if the username is already specified" if="property name" unless="property name"/>
     30 *  <getuserandpassword
     31 *       message="a message to display at the top of the dialog"
     32 *       userproperty="the name of the username property to set"
     33 *       pwordproperty="the name of the password property to set"
     34 *       username="default value for username (optional)"
     35 *       if="property name (optional)"
     36 *       unless="property name (optional)"/>
    3237 * the if and unless attributes are used to control whether this task runs or not. If the 'if' attribute is set, the task will only run if the specified property is defined. If the unless attribute is set, the task will only run if the property is not defined.
    3338*/
     
    3742   
    3843    private String message = null;
    39    
     44    private String user_property = null;
     45    private String pword_property = null;
    4046    private String username = null;
    4147    private String password = null;
     
    6066    }
    6167
     68    public void setPwordproperty(String p_prop) {
     69    pword_property = p_prop;
     70    }
     71   
    6272    /** specify a property name - the task will only execute if this property is not set */
    6373    public void setUnless(String property) {
     
    7282    }
    7383
     84    public void setUserproperty(String u_prop) {
     85    user_property = u_prop;
     86    }
    7487    public void execute() throws org.apache.tools.ant.BuildException {
    7588   
     
    7790        return;
    7891    }
     92    if (user_property == null || pword_property == null) {
     93        throw new org.apache.tools.ant.BuildException("userproperty and pwordproperty attributes must be specified");
     94    }
     95   
    7996    JFrame hiddenFrame = new JFrame("Username and Password Hidden Frame");
    8097    final JDialog dialog = new JDialog(hiddenFrame, "Username and Password", true);
     
    167184    }
    168185   
    169     getProject().setProperty("proxy.username", username);
    170     getProject().setProperty("proxy.password", password);
     186    getProject().setProperty(user_property, username);
     187    getProject().setProperty(pword_property, password);
    171188   
    172189   
     
    208225    MyGetUserAndPassword task = new MyGetUserAndPassword();
    209226    task.setMessage("hi there kath");
     227    task.setUserproperty("username");
     228    task.setPwordproperty("password");
    210229    task.execute();
    211230
Note: See TracChangeset for help on using the changeset viewer.