1 31 32 package org.opencms.util.ant; 33 34 import javax.swing.UIManager ; 35 36 51 public class CmsAntTaskSelectionTreePrompt extends org.apache.tools.ant.Task { 52 53 54 public static final String LIST_SEPARATOR = ","; 55 56 57 private String m_allValues; 59 60 private String m_defaultValue = ""; 61 62 63 private int m_expansionLevels = 0; 64 65 66 private String m_prompt = "Please make your choice:"; 67 68 69 private String m_property; 71 72 private boolean m_singleSelection = false; 73 74 75 private String m_title = "Selection Dialog"; 76 77 81 public CmsAntTaskSelectionTreePrompt() { 82 83 super(); 84 } 85 86 91 public static void main(String [] args) { 92 93 CmsAntTaskSelectionTreePrompt prompt = new CmsAntTaskSelectionTreePrompt(); 94 prompt.setAllValues("org.opencms.test,org.opencms.test.subtest,org.opencms.code,org.opencms.blabla,com.lgt.module,com.lgt.code,com.lgt.dummy"); 95 prompt.setTitle("title"); 96 97 prompt.execute(); 98 99 } 100 101 113 public void execute() throws org.apache.tools.ant.BuildException { 114 115 log("Prompting user for " + m_property); 116 117 String value = new CmsAntTaskSelectionTreeDialog(this).getSelection(); 118 119 if (value == null) { 120 value = "__ABORT__"; 121 } else { 122 log("user selection: " + value); 123 } 124 getProject().setProperty(m_property, value); 125 } 126 127 133 public String getAllValues() { 134 135 return m_allValues; 136 } 137 138 144 public String getDefaultValue() { 145 146 return m_defaultValue; 147 } 148 149 155 public int getExpansionLevels() { 156 157 return m_expansionLevels - 1; 159 } 160 161 167 public String getPrompt() { 168 169 return m_prompt; 170 } 171 172 178 public String getProperty() { 179 180 return m_property; 181 } 182 183 189 public String getTitle() { 190 191 return m_title; 192 } 193 194 198 public void init() { 199 200 super.init(); 201 try { 202 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 203 } catch (Exception e) { 204 } 206 } 207 208 214 public boolean isSingleSelection() { 215 216 return m_singleSelection; 217 } 218 219 225 public void log(String arg0) { 226 227 try { 228 super.log(arg0); 229 } catch (Exception ex) { 230 System.err.println(arg0); 231 } 232 233 } 234 235 241 public void log(String arg0, int arg1) { 242 243 try { 244 super.log(arg0, arg1); 245 } catch (Exception ex) { 246 System.err.println(arg0); 247 } 248 } 249 250 256 public void setAllValues(String allValues) { 257 258 this.m_allValues = allValues; 259 } 260 261 267 public void setDefaultValue(String defaultValue) { 268 269 this.m_defaultValue = defaultValue; 270 } 271 272 278 public void setExpansionLevels(int expansionLevels) { 279 280 m_expansionLevels = expansionLevels + 1; 282 } 283 284 290 public void setPrompt(String prompt) { 291 292 m_prompt = prompt; 293 } 294 295 300 public void setProperty(String property) { 301 302 this.m_property = property; 303 } 304 305 311 public void setSingleSelection(boolean singleSelection) { 312 313 m_singleSelection = singleSelection; 314 } 315 316 322 public void setTitle(String title) { 323 324 m_title = title; 325 } 326 327 } | Popular Tags |