Caret caret = editor.getCaret();
long p0 = caret.getMark();
long p1 = caret.getDot();
if (p0 == p1) {
HexModel model = editor.getModel();
if (p0 + data.length - 1 <= model.getLastOffset()) {
model.set(p0, data);
} else {
JOptionPane.showMessageDialog(editor.getRootPane(),
Strings.get("hexPasteEndError"),
Strings.get("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
}
} else {
if (p0 < 0 || p1 < 0) return;
if (p0 > p1) {
long t = p0; p0 = p1; p1 = t;
}
p1++;
HexModel model = editor.getModel();
if (p1 - p0 == data.length) {
model.set(p0, data);
} else {
JOptionPane.showMessageDialog(editor.getRootPane(),
Strings.get("hexPasteSizeError"),
Strings.get("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);