try {
String text = (String) (clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor));
StringTokenizer rowTokenizer = new StringTokenizer(text, "\n");
for (int i = 0; rowTokenizer.hasMoreTokens(); i++) {
String values = rowTokenizer.nextToken();
DcObject dco = module.getItem();
int fldCounter = 0;
int index = values.indexOf("\t");
while (index > -1) {
String value = values.substring(0, index);
if (fldCounter <= fields.length) {
DcField field = dco.getField(fields[fldCounter]);
if (field.getValueType() == DcRepository.ValueTypes._LONG) {
try {
dco.setValue(fields[fldCounter], Long.valueOf(value.trim()));
} catch (Exception e) {
logger.warn("Could not set " + value + " for field " + fields[fldCounter], e);
}
} else {
dco.setValue(fields[fldCounter], value);
}
}
fldCounter++;
values = values.substring(index + 1, values.length());
index = values.indexOf("\t");
}
dco.setValue(fields[fldCounter], values);
vc.update(dco.getID(), dco);
}
}
catch (Exception exp) {
logger.error("An error occurred while pasting data into the table", exp);
}