[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Thu Dec 6 17:32:32 UTC 2007
gordonp
Thu Dec 6 12:32:32 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv25597/src/main/ca/ucalgary/seahawk/gui
Modified Files:
MobySecondaryInputGUI.java
Log Message:
Added typecheck for secondary:widget map
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/26 15:25:13 1.6
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/12/06 17:32:32 1.7
@@ -32,7 +32,7 @@
private String confirmMessage = "Execute Service";
private JPanel optionsPanel;
- private Map data2widget;
+ private Map<MobyDataSecondaryInstance,JComponent> data2widget;
private ActionListener listener;
private int handlerCode = 0; // callback event ID provided by caller to c-tor
private boolean showingNew = false;
@@ -76,7 +76,7 @@
setTitle(TITLE);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- data2widget = new HashMap();
+ data2widget = new HashMap<MobyDataSecondaryInstance,JComponent>();
optionsPanel = new JPanel();
// Layout widgets top to bottom in one column
@@ -335,11 +335,23 @@
public Component makeIntWidget(MobyDataSecondaryInstance msdi){
String name = msdi.getName();
- // Note, nothing in the MOBY sopec says the number has to fit
- // into a Java int, so really these should be arbitrary precision BigIntegers
- // but the jMOBY API doesn't provide these right now...
- int min = msdi.getMinimumValue();
- int max = msdi.getMaximumValue();
+ // Should change to BigInteger eventually...
+ int min = Integer.MIN_VALUE;
+ int max = Integer.MAX_VALUE;
+ if(msdi.getMinValue() != null && msdi.getMinValue().length() != 0){
+ try{min = Integer.parseInt(msdi.getMinValue());}
+ catch(NumberFormatException nfe){
+ logger.error("NumberFormatException: Warning: minimum value for secondary input " + name +
+ " could not be parse into an integer as required, using " + Integer.MIN_VALUE);
+ }
+ }
+ if(msdi.getMaxValue() != null && msdi.getMaxValue().length() != 0){
+ try{max = Integer.parseInt(msdi.getMaxValue());}
+ catch(NumberFormatException nfe){
+ logger.error("NumberFormatException: Warning: maximum value for secondary input " + name +
+ " could not be parse into an integer as required, using " + Integer.MAX_VALUE);
+ }
+ }
int defaultValue = 0;
if(msdi.getDefaultValue() == null || msdi.getDefaultValue().length() == 0){
logger.warn("Warning: default value for secondary input " + name +
@@ -407,8 +419,26 @@
public Component makeFloatWidget(MobyDataSecondaryInstance msdi){
String name = msdi.getName();
// Note: jMOBY API does not yet support floating point min and max values
- double min = (double) msdi.getMinimumValue();
- double max = (double) msdi.getMaximumValue();
+ double min = Double.MIN_VALUE;
+ if(msdi.getMinValue() != null && msdi.getMinValue().length() > 0){
+ try{Double.parseDouble(msdi.getMinValue());}
+ catch(NumberFormatException nfe){
+ logger.error("NumberFormatException: Minimum value (" + msdi.getMinValue() +
+ ") for decimal-format MOBY Secondary Input '" +
+ name + "' was not a decimal number, setting minimum to " +
+ Double.MIN_VALUE + ". Error was: " + nfe);
+ }
+ }
+ double max = Double.MAX_VALUE;
+ if(msdi.getMaxValue() != null && msdi.getMaxValue().length() > 0){
+ try{Double.parseDouble(msdi.getMaxValue());}
+ catch(NumberFormatException nfe){
+ logger.error("NumberFormatException: Maximum value (" + msdi.getMaxValue() +
+ ") for decimal-format MOBY Secondary Input '" +
+ name + "' was not a decimal number, setting minimum to " +
+ Double.MAX_VALUE + ". Error was: " + nfe);
+ }
+ }
String defaultValueString = msdi.getDefaultValue();
double defaultValue = 0.0;
if(defaultValueString != null){
@@ -530,12 +560,10 @@
// Go through the map we build while constructing the interface
// and grab the current values for all the widgets as the new
// secondary input data values.
- Iterator keys = data2widget.keySet().iterator();
- while(keys.hasNext()){
- MobyDataSecondaryInstance msdi = (MobyDataSecondaryInstance) keys.next();
+ for(MobyDataSecondaryInstance msdi: data2widget.keySet()){
Object newValue = null;
try{
- Object widget = data2widget.get(msdi);
+ JComponent widget = data2widget.get(msdi);
if(widget instanceof JComboBox){
newValue = ((JComboBox) widget).getSelectedItem();
msdi.setValue(newValue.toString());
More information about the MOBY-guts
mailing list