int c0 = caret.getCursorCol();
int c1 = caret.getMarkCol();
int r0 = caret.getCursorRow();
int r1 = caret.getMarkRow();
if (r0 < 0 || r1 < 0 || c0 < 0 || c1 < 0) return;
TruthTable model = table.getTruthTable();
int rows = model.getRowCount();
int inputs = model.getInputColumnCount();
int outputs = model.getOutputColumnCount();
if (c0 == c1 && r0 == r1) {
if (r0 + entries.length > rows
|| c0 + entries[0].length > inputs + outputs) {
JOptionPane.showMessageDialog(table.getRootPane(),
getFromLocale("clipPasteEndError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
} else {
if (r0 > r1) { int t = r0; r0 = r1; r1 = t; }
if (c0 > c1) { int t = c0; c0 = c1; c1 = t; }
if (r1 - r0 + 1 != entries.length
|| c1 - c0 + 1 != entries[0].length) {
JOptionPane.showMessageDialog(table.getRootPane(),
getFromLocale("clipPasteSizeError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
}
for (int r = 0; r < entries.length; r++) {
for (int c = 0; c < entries[0].length; c++) {
if (c0 + c >= inputs) {
model.setOutputEntry(r0 + r, c0 + c - inputs,
entries[r][c]);
}
}
}
}