Changeset 5758
- Timestamp:
- 2003-10-29T12:22:18+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java
r5593 r5758 38 38 import org.greenstone.gatherer.cdm.CollectionDesignManager; 39 39 import org.greenstone.gatherer.cdm.PlugIn; 40 import org.greenstone.gatherer.gui.ModalDialog; 41 import org.greenstone.gatherer.gui.SimpleMenuBar; 40 42 import org.greenstone.gatherer.msm.ElementWrapper; 43 import org.greenstone.gatherer.util.StaticStrings; 41 44 import org.greenstone.gatherer.util.Utility; 42 45 import org.greenstone.gatherer.valuetree.GValueModel; 43 import org.greenstone.gatherer.gui.SimpleMenuBar;44 import org.greenstone.gatherer.gui.ModalDialog;45 46 46 47 /** This class provides us with a dialog box which allows us to edit the arguments of either a PlugIn or a Classifier. … … 175 176 Component component = central_pane.getComponent(i); 176 177 if(component instanceof ArgumentControl) { 177 // Once cont goes false it stays false 178 cont = cont && ((ArgumentControl)component).updateArgument(); 178 cont = cont && ((ArgumentControl)component).updateArgument(); 179 179 } 180 180 } … … 503 503 } 504 504 505 public Argument getArgument() { 506 return argument; 507 } 508 505 509 public Object getValue() { 506 510 if(value instanceof JComboBox) { … … 526 530 */ 527 531 public boolean updateArgument() { 528 529 argument.setAssigned(true);530 531 532 case Argument.ENUM:532 if(enabled.isSelected() || argument.isRequired()) { 533 argument.setAssigned(false); 534 String result = null; 535 switch(argument.getType()) { 536 case Argument.ENUM: 533 537 ListOption option = (ListOption)((JComboBox)value).getSelectedItem(); 538 if(option == null || option.getValue().length() == 0) { 539 String args[] = new String[1]; 540 args[0] = argument.getName(); 541 JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.No_Value", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE); 542 return false; 543 } 534 544 result = option.getValue(); 535 545 if(result.length() > 0) { 536 546 argument.setValue(result); 537 547 } 538 548 else { 539 if(argument.isRequired()) { 540 String args[] = new String[1]; 541 args[0] = argument.getName(); 542 JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE); 543 args = null; 544 return false; 545 } 546 else { 547 argument.setValue(null); 548 } 549 } 549 if(argument.isRequired()) { 550 String args[] = new String[1]; 551 args[0] = argument.getName(); 552 JOptionPane.showMessageDialog(self, Dictionary.get("CDM.ArgumentConfiguration.Required_Argument", args), Dictionary.get("CDM.ArgumentConfiguration.Error_Title"), JOptionPane.ERROR_MESSAGE); 553 args = null; 554 return false; 555 } 556 else { 557 argument.setValue(null); 558 } 559 } 560 argument.setAssigned(true); 550 561 return true; 551 562 case Argument.FLAG: 552 // Should have already been handled above. 563 // Should have already been handled above. 564 argument.setAssigned(true); 553 565 return true; 554 566 case Argument.INTEGER: … … 581 593 } 582 594 } 595 argument.setAssigned(true); 583 596 return true; 584 case Argument.LANGUAGE: 585 Language language = (Language) ((JComboBox)value).getSelectedItem(); 586 argument.setValue(language.getCode()); 587 // Kinda lucked out here. Its impossible not to choose an entry from these comboboxes as they are restricted. 588 return true; 597 case Argument.LANGUAGE: 598 String language = (((JComboBox)value).getSelectedItem()).toString(); 599 argument.setValue(language); 600 // Kinda lucked out here. Its impossible not to choose an entry from these comboboxes as they are restricted. 601 argument.setAssigned(true); 602 return true; 589 603 case Argument.METADATUM: 590 604 argument.setValue(((ElementWrapper)((JComboBox)value).getSelectedItem()).getName()); 591 605 // Kinda lucked out here. Its impossible not to choose an entry from these comboboxes as they are restricted. 606 argument.setAssigned(true); 592 607 return true; 593 608 case Argument.HIERARCHY: 594 609 argument.setValue(((JComboBox)value).getSelectedItem().toString()); 595 610 // Kinda lucked out here. Its impossible not to choose an entry from these comboboxes as they are restricted. 611 argument.setAssigned(true); 596 612 return true; 597 613 case Argument.METADATA: … … 602 618 } 603 619 argument.setValues(values); 620 argument.setAssigned(true); 604 621 return true; 605 622 case Argument.STRING: … … 619 636 } 620 637 } 638 argument.setAssigned(true); 621 639 return true; 622 640 } … … 785 803 implements Comparable { 786 804 /** The maximum length of this String version of this item. */ 787 //private int MAX_DESC = 35;805 private int MAX_DESC = 65; 788 806 /** The description of the value for this item. */ 789 807 private String description = null; … … 832 850 public String toString() { 833 851 if(text == null) { 834 //if(description.length() >= MAX_DESC) {835 // text = value + " - " + description.substring(0, MAX_DESC);836 //}837 //else {838 text = value + " - "+ description;839 //}852 if(description.length() >= MAX_DESC) { 853 text = value + StaticStrings.MINUS_CHARACTER + description.substring(0, MAX_DESC) + StaticStrings.TRUNCATED_STRING; 854 } 855 else { 856 text = value + StaticStrings.MINUS_CHARACTER + description; 857 } 840 858 } 841 859 return text; … … 875 893 JComboBox source = (JComboBox)event.getSource(); 876 894 ListOption lo = (ListOption)source.getSelectedItem(); 877 String description = Utility.formatHTMLWidth(lo.getDesc(), 60); 878 source.setToolTipText(description); 895 if(lo != null) { 896 String description = Utility.formatHTMLWidth(lo.getDesc(), 60); 897 source.setToolTipText(description); 898 } 899 else { 900 source.setToolTipText(StaticStrings.EMPTY_STR); 901 } 879 902 } 880 903 }
Note:
See TracChangeset
for help on using the changeset viewer.