ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r426186 - /ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java
Date Thu, 27 Jul 2006 18:21:53 GMT
Author: jglick
Date: Thu Jul 27 11:21:52 2006
New Revision: 426186

URL: http://svn.apache.org/viewvc?rev=426186&view=rev
Log:
Display the default value for an input prompt sensibly.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java?rev=426186&r1=426185&r2=426186&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/input/DefaultInputHandler.java Thu Jul 27
11:21:52 2006
@@ -82,23 +82,34 @@
      */
     protected String getPrompt(InputRequest request) {
         String prompt = request.getPrompt();
+        String def = request.getDefaultValue();
         if (request instanceof MultipleChoiceInputRequest) {
             StringBuffer sb = new StringBuffer(prompt);
-            sb.append("(");
+            sb.append(" (");
             Enumeration e =
                 ((MultipleChoiceInputRequest) request).getChoices().elements();
             boolean first = true;
             while (e.hasMoreElements()) {
                 if (!first) {
-                    sb.append(",");
+                    sb.append(", ");
+                }
+                String next = (String) e.nextElement();
+                if (next.equals(def)) {
+                    sb.append('[');
+                }
+                sb.append(next);
+                if (next.equals(def)) {
+                    sb.append(']');
                 }
-                sb.append(e.nextElement());
                 first = false;
             }
             sb.append(")");
-            prompt = sb.toString();
+            return sb.toString();
+        } else if (def != null) {
+            return prompt + " [" + def + "]";
+        } else {
+            return prompt;
         }
-        return prompt;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message