use of org.jabref.gui.undo.UndoableStringChange in project jabref by JabRef.
the class StringChange method makeChange.
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
if (string == null) {
// The string was removed or renamed locally. We guess that it was removed.
BibtexString bs = new BibtexString(label, disk);
try {
panel.getDatabase().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs));
} catch (KeyCollisionException ex) {
LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex);
}
} else {
string.setContent(disk);
undoEdit.addEdit(new UndoableStringChange(panel, string, false, mem, disk));
}
// Update tmp database:
if (tmpString == null) {
BibtexString bs = new BibtexString(label, disk);
secondary.addString(bs);
} else {
tmpString.setContent(disk);
}
return true;
}
use of org.jabref.gui.undo.UndoableStringChange in project jabref by JabRef.
the class StringNameChange method makeChange.
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
if (panel.getDatabase().hasStringLabel(disk)) {
// The name to change to is already in the database, so we can't comply.
LOGGER.info("Cannot rename string '" + mem + "' to '" + disk + "' because the name " + "is already in use.");
}
if (string == null) {
// The string was removed or renamed locally. We guess that it was removed.
BibtexString bs = new BibtexString(disk, content);
try {
panel.getDatabase().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs));
} catch (KeyCollisionException ex) {
LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex);
}
} else {
string.setName(disk);
undoEdit.addEdit(new UndoableStringChange(panel, string, true, mem, disk));
}
// Update tmp database:
if (tmpString == null) {
BibtexString bs = new BibtexString(disk, content);
secondary.addString(bs);
} else {
tmpString.setName(disk);
}
return true;
}
Aggregations