Author: ruschein
Date: 2010-02-18 14:48:37 -0800 (Thu, 18 Feb 2010)
New Revision: 19374
Modified:
coreplugins/trunk/browser/src/browser/MultiDataEditAction.java
coreplugins/trunk/browser/src/browser/ui/ModPanel.java
Log:
We now allow copying from int to float attrs.
Modified: coreplugins/trunk/browser/src/browser/MultiDataEditAction.java
===================================================================
--- coreplugins/trunk/browser/src/browser/MultiDataEditAction.java
2010-02-18 22:17:08 UTC (rev 19373)
+++ coreplugins/trunk/browser/src/browser/MultiDataEditAction.java
2010-02-18 22:48:37 UTC (rev 19374)
@@ -279,9 +279,9 @@
return;
}
- byte fromType = attrData.getType(attributeFrom);
- byte toType= attrData.getType(attributeTo);
- if (toType != CyAttributes.TYPE_UNDEFINED && fromType !=
toType) {
+ final byte fromType = attrData.getType(attributeFrom);
+ final byte toType = attrData.getType(attributeTo);
+ if (toType == CyAttributes.TYPE_UNDEFINED ||
!copyAttrsAreCompatible(fromType, toType)) {
showErrorWindow("Copy Failed: Incompatible data
types.");
return;
@@ -303,11 +303,22 @@
else
value =
attrData.getAttribute(go.getIdentifier(), attributeFrom);
new_values.add(value);
+
+ if ((fromType == CyAttributes.TYPE_INTEGER) && (toType
== CyAttributes.TYPE_FLOATING))
+ value = new Double((Integer)value);
setAttributeValue(go.getIdentifier(), attributeTo,
value);
+
old_values.add(null);
}
}
+ private boolean copyAttrsAreCompatible(final byte fromType, final byte
toType) {
+ if (fromType == toType)
+ return true;
+
+ return (fromType == CyAttributes.TYPE_INTEGER) && (toType ==
CyAttributes.TYPE_FLOATING);
+ }
+
/**
* Use the global edit variables to delete the values from the given
* attribute. the deleted values will be stored in "old_values"
Modified: coreplugins/trunk/browser/src/browser/ui/ModPanel.java
===================================================================
--- coreplugins/trunk/browser/src/browser/ui/ModPanel.java 2010-02-18
22:17:08 UTC (rev 19373)
+++ coreplugins/trunk/browser/src/browser/ui/ModPanel.java 2010-02-18
22:48:37 UTC (rev 19374)
@@ -384,6 +384,8 @@
if (fromType != currentAttributeCopyToType) {
final Set<Byte> attrTypes = new
TreeSet<Byte>();
attrTypes.add(fromType);
+ if (fromType ==
CyAttributes.TYPE_INTEGER) // Allow copying from int to float.
+
attrTypes.add(CyAttributes.TYPE_FLOATING);
attributeCopyToBox.setModel(new
AttributeModel(data, attrTypes));
}
}
--
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.