Changeset 6087 for trunk/gli/src/org/greenstone/gatherer/cdm
- Timestamp:
- 2003-12-02T17:18:37+13:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Argument.java
r5230 r6087 66 66 /** The type of this argument. Initially an int, but bytes are cheaper. */ 67 67 private byte type = STRING; 68 69 /** The maximum value an integer based control can have. */ 70 private int maximum = Integer.MAX_VALUE; 71 /** The minimum value an integer based control can have. */ 72 private int minimum = Integer.MIN_VALUE; 73 68 74 private Element element; 69 75 /** If the argument is of type ENUM then this map holds all the various options. Each entry is an <option value> -> <description> mapping. */ … … 162 168 } 163 169 170 public int getMaximum() { 171 return maximum; 172 } 173 174 public int getMinimum() { 175 return minimum; 176 } 177 164 178 /** Method to retrieve the option list for this argument. 165 179 * @return A <strong>HashMap</strong> containing <option value> -> <description> entries. … … 284 298 public void setElement(Element element) { 285 299 this.element = element; 300 } 301 302 public void setMaximum(int maximum) { 303 this.maximum = maximum; 304 } 305 306 public void setMinimum(int minimum) { 307 this.minimum = minimum; 286 308 } 287 309 -
trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java
r6051 r6087 325 325 Collections.sort(options_model); 326 326 value = new JComboBox(options_model.toArray()); 327 327 ((JComboBox)value).setEditable(true); 328 328 ((JComboBox)value).addActionListener(new ToolTipUpdater()); 329 329 if(existing_value != null) { … … 353 353 break; 354 354 case Argument.INTEGER: 355 // Build a spinner 356 JSpinner spinner = new JSpinner(new SpinnerNumberModel(0, argument.getMinimum(), argument.getMaximum(), 1)); 357 // If there was an original value, set it. 358 if(existing_value != null) { 359 try { 360 spinner.setValue(new Integer(existing_value)); 361 } 362 catch (Exception error) { 363 } 364 } 365 else if(default_value != null) { 366 try { 367 spinner.setValue(new Integer(default_value)); 368 } 369 catch (Exception error) { 370 } 371 } 372 // And remember it 373 value = spinner; 374 break; 355 375 case Argument.STRING: 356 376 // Use a standard text field … … 450 470 break; 451 471 } // end of switch 472 452 473 // Enable or disable as necessary. 453 474 if(argument.isRequired() || argument.isAssigned()) { … … 457 478 value.setBackground(Color.white); 458 479 value.setEnabled(true); 480 if(value instanceof JSpinner) { 481 // Set enabled 482 JComponent c = ((JSpinner)value).getEditor(); 483 if ( c instanceof JSpinner.DefaultEditor ) { 484 JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c; 485 JFormattedTextField field = editor.getTextField(); 486 field.setEditable(true); 487 field.setBackground(Color.white); 488 } 489 } 459 490 } 460 491 } … … 465 496 value.setBackground(Color.lightGray); 466 497 value.setEnabled(false); 498 if(value instanceof JSpinner) { 499 // Set enabled 500 JComponent c = ((JSpinner)value).getEditor(); 501 if ( c instanceof JSpinner.DefaultEditor ) { 502 JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c; 503 JFormattedTextField field = editor.getTextField(); 504 field.setEditable(false); 505 field.setBackground(Color.lightGray); 506 } 507 } 467 508 } 468 509 } … … 567 608 return true; 568 609 case Argument.INTEGER: 569 result = ((J TextField)value).getText();610 result = ((JSpinner)value).getValue().toString(); 570 611 if(result.length() > 0) { 571 612 // Test if the value entered is a valid int. … … 789 830 target.setBackground(Color.white); 790 831 target.setEnabled(true); 832 if(target instanceof JSpinner) { 833 // Set enabled 834 JComponent c = ((JSpinner)target).getEditor(); 835 if ( c instanceof JSpinner.DefaultEditor ) { 836 JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c; 837 JFormattedTextField field = editor.getTextField(); 838 field.setEditable(true); 839 field.setBackground(Color.white); 840 } 841 } 791 842 if(one != null && two != null && list != null) { 792 843 one.setEnabled(true); … … 799 850 target.setBackground(Color.lightGray); 800 851 target.setEnabled(false); 852 if(target instanceof JSpinner) { 853 // Set enabled 854 JComponent c = ((JSpinner)target).getEditor(); 855 if ( c instanceof JSpinner.DefaultEditor ) { 856 JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) c; 857 JFormattedTextField field = editor.getTextField(); 858 field.setEditable(false); 859 field.setBackground(Color.lightGray); 860 } 861 } 801 862 if(one != null && two != null && list != null) { 802 863 one.setEnabled(false); -
trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java
r6032 r6087 490 490 } 491 491 } 492 else if(node_name.equals(StaticStrings.RANGE_ELEMENT)) { 493 String range_raw = MSMUtils.getValue(det); 494 int index = -1; 495 if((index = range_raw.indexOf(StaticStrings.COMMA_CHARACTER)) != -1) { 496 if(index > 0) { 497 try { 498 String first_number = range_raw.substring(0, index); 499 argument.setMinimum(Integer.parseInt(first_number)); 500 first_number = null; 501 } 502 catch(Exception exception) { 503 } 504 } 505 506 if(index + 1 < range_raw.length()) { 507 try { 508 String second_number = range_raw.substring(index + 1); 509 argument.setMaximum(Integer.parseInt(second_number)); 510 second_number = null; 511 512 } 513 catch(Exception exception) { 514 } 515 } 516 517 } 518 // Else it wasn't a valid range anyway, so ignore it 519 } 492 520 } 493 521 classifier.addArgument(argument); -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r6051 r6087 498 498 } 499 499 } 500 else if(node_name.equals(StaticStrings.RANGE_ELEMENT)) { 501 String range_raw = MSMUtils.getValue(det); 502 int index = -1; 503 if((index = range_raw.indexOf(StaticStrings.COMMA_CHARACTER)) != -1) { 504 if(index > 0) { 505 try { 506 String first_number = range_raw.substring(0, index); 507 argument.setMinimum(Integer.parseInt(first_number)); 508 first_number = null; 509 } 510 catch(Exception exception) { 511 } 512 } 513 514 if(index + 1 < range_raw.length()) { 515 try { 516 String second_number = range_raw.substring(index + 1); 517 argument.setMaximum(Integer.parseInt(second_number)); 518 second_number = null; 519 } 520 catch(Exception exception) { 521 } 522 } 523 } 524 // Else it wasn't a valid range anyway, so ignore it 525 } 500 526 } 501 527 plugin.addArgument(argument);
Note:
See TracChangeset
for help on using the changeset viewer.