Changeset 10299 for trunk/gsdl3/src
- Timestamp:
- 2005-07-25T16:36:00+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/anttasks/MyGetUserAndPassword.java
r9874 r10299 26 26 /** A new ant task to prompt the user for username and password. 27 27 * 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" /> 29 29 * 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)"/> 32 37 * 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. 33 38 */ … … 37 42 38 43 private String message = null; 39 44 private String user_property = null; 45 private String pword_property = null; 40 46 private String username = null; 41 47 private String password = null; … … 60 66 } 61 67 68 public void setPwordproperty(String p_prop) { 69 pword_property = p_prop; 70 } 71 62 72 /** specify a property name - the task will only execute if this property is not set */ 63 73 public void setUnless(String property) { … … 72 82 } 73 83 84 public void setUserproperty(String u_prop) { 85 user_property = u_prop; 86 } 74 87 public void execute() throws org.apache.tools.ant.BuildException { 75 88 … … 77 90 return; 78 91 } 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 79 96 JFrame hiddenFrame = new JFrame("Username and Password Hidden Frame"); 80 97 final JDialog dialog = new JDialog(hiddenFrame, "Username and Password", true); … … 167 184 } 168 185 169 getProject().setProperty( "proxy.username", username);170 getProject().setProperty( "proxy.password", password);186 getProject().setProperty(user_property, username); 187 getProject().setProperty(pword_property, password); 171 188 172 189 … … 208 225 MyGetUserAndPassword task = new MyGetUserAndPassword(); 209 226 task.setMessage("hi there kath"); 227 task.setUserproperty("username"); 228 task.setPwordproperty("password"); 210 229 task.execute(); 211 230
Note:
See TracChangeset
for help on using the changeset viewer.