Author: ruschein
Date: 2010-06-28 16:22:46 -0700 (Mon, 28 Jun 2010)
New Revision: 20703
Modified:
coreplugins/trunk/browser/src/browser/DataEditAction.java
coreplugins/trunk/browser/src/browser/ui/FormulaBuilderDialog.java
Log:
Fixed some nasty tracebacks when list equations were being entered into browser
cells that require scalar values.
Modified: coreplugins/trunk/browser/src/browser/DataEditAction.java
===================================================================
--- coreplugins/trunk/browser/src/browser/DataEditAction.java 2010-06-28
22:37:46 UTC (rev 20702)
+++ coreplugins/trunk/browser/src/browser/DataEditAction.java 2010-06-28
23:22:46 UTC (rev 20703)
@@ -34,8 +34,12 @@
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
+import org.cytoscape.equations.BooleanList;
import org.cytoscape.equations.EqnCompiler;
+import org.cytoscape.equations.DoubleList;
import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.LongList;
+import org.cytoscape.equations.StringList;
import java.util.ArrayList;
import java.util.Arrays;
@@ -143,13 +147,17 @@
attrs.deleteAttribute(id, attrName);
return;
}
- if (equation.getType() == String.class) {
+
+ final Class returnType = equation.getType();
+ if (returnType != Long.class && returnType !=
Double.class && returnType != Boolean.class) {
showErrorWindow("Error in attribute \""
+ attrName
- + "\": equation is of
type String but should be of type Integer!");
+ + "\": equation is of
type " + getLastDotComponent(returnType.toString())
+ + " but should be of
type Integer!");
objectAndEditString = new
ValidatedObjectAndEditString(null, newValueStr, "#TYPE");
attrs.deleteAttribute(id, attrName);
return;
}
+
attrs.setAttribute(id, attrName, equation);
final Object attrValue = attrs.getAttribute(id,
attrName);
String errorMessage =
attrs.getLastEquationError();
@@ -182,13 +190,17 @@
attrs.deleteAttribute(id, attrName);
return;
}
- if (equation.getType() == String.class) {
+
+ final Class returnType = equation.getType();
+ if (returnType != Double.class && returnType !=
Long.class && returnType != Boolean.class) {
showErrorWindow("Error in attribute \""
+ attrName
- + "\": equation is of
type String but should be of type Floating Point!");
+ + "\": equation is of
type " + getLastDotComponent(returnType.toString())
+ + " but should be of
type Floating Point!");
objectAndEditString = new
ValidatedObjectAndEditString(null, newValueStr, "#TYPE");
attrs.deleteAttribute(id, attrName);
return;
}
+
attrs.setAttribute(id, attrName, equation);
final Object attrValue = attrs.getAttribute(id,
attrName);
String errorMessage =
attrs.getLastEquationError();
@@ -222,13 +234,17 @@
attrs.deleteAttribute(id, attrName);
return;
}
- if (equation.getType() == String.class) {
+
+ final Class returnType = equation.getType();
+ if (returnType != Boolean.class && returnType
!= Long.class && returnType != Double.class) {
objectAndEditString = new
ValidatedObjectAndEditString(null, newValueStr, "#TYPE");
attrs.deleteAttribute(id, attrName);
showErrorWindow("Error in attribute \""
+ attrName
- + "\": equation is of
type String but should be of type Boolean!");
+ + "\": equation is of
type " + getLastDotComponent(returnType.toString())
+ + " but should be of
type Boolean!");
return;
}
+
attrs.setAttribute(id, attrName, equation);
final Object attrValue = attrs.getAttribute(id,
attrName);
String errorMessage =
attrs.getLastEquationError();
@@ -338,6 +354,18 @@
}
}
+ /**
+ * Assumes that "s" consists of components separated by dots.
+ * @returns the last component of "s" or all of "s" if there are no
dots
+ */
+ private static String getLastDotComponent(final String s) {
+ final int lastDotPos = s.lastIndexOf('.');
+ if (lastDotPos == -1)
+ return s;
+
+ return s.substring(lastDotPos + 1);
+ }
+
/** Does some rudimentary list syntax checking and returns the number
of items in "listCandidate."
* @param listCandidate a string that will be analysed as to
list-syntax conformance.
* @returns -1 if "listCandidate" does not conform to a list syntax,
otherwise the number of items in the simple list.
Modified: coreplugins/trunk/browser/src/browser/ui/FormulaBuilderDialog.java
===================================================================
--- coreplugins/trunk/browser/src/browser/ui/FormulaBuilderDialog.java
2010-06-28 22:37:46 UTC (rev 20702)
+++ coreplugins/trunk/browser/src/browser/ui/FormulaBuilderDialog.java
2010-06-28 23:22:46 UTC (rev 20703)
@@ -363,9 +363,9 @@
/**
* Assumes that "s" consists of components separated by dots.
- * @returns the last component of "s"
+ * @returns the last component of "s" or all of "s" if there are no
dots
*/
- private String getLastDotComponent(final String s) {
+ private static String getLastDotComponent(final String s) {
final int lastDotPos = s.lastIndexOf('.');
if (lastDotPos == -1)
return s;
--
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.