Author: scooter
Date: 2011-08-04 19:01:17 -0700 (Thu, 04 Aug 2011)
New Revision: 26381
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/layout/Tunable.java
Log:
Fix bug in setting list values
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/layout/Tunable.java
===================================================================
--- cytoscape/trunk/application/src/main/java/cytoscape/layout/Tunable.java
2011-08-04 21:23:03 UTC (rev 26380)
+++ cytoscape/trunk/application/src/main/java/cytoscape/layout/Tunable.java
2011-08-05 02:01:17 UTC (rev 26381)
@@ -552,8 +552,17 @@
((JList)inputField).setSelectedIndices(intArray);
}
} else {
+ // Two possibilities -- could be an
Integer, or could be a string that matches something
+ // in the list. We need to check both
if (value.getClass() == String.class)
- this.value = new
Integer((String) value);
+ try {
+ this.value = new
Integer((String) value);
+ } catch (NumberFormatException
e) {
+ // OK, probably a
string that we need to match (if possible)
+ if (lowerBound == null
|| value == null)
+ return;
+ this.value =
getSelectedValue((Object [])lowerBound,(String)value);
+ }
else
this.value = value;
@@ -1040,6 +1049,15 @@
return selVals;
}
+ private Integer getSelectedValue(Object []valueList, String value) {
+ if (valueList == null || value == null) return null;
+ for (int i = 0; i < valueList.length; i++) {
+ if (value.equals(valueList[i].toString()))
+ return new Integer(i);
+ }
+ return null;
+ }
+
private int[] decodeIntegerArray(String value) {
if(value == null || value.length() == 0) {
return null;
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.