use of com.ramussoft.common.journal.command.StartUserTransactionCommand in project ramus by Vitaliy-Yakovchuk.
the class Journal method undoUserTransaction.
@Override
public void undoUserTransaction() {
int counter = 0;
try {
Command command = undo();
counter++;
if (!(command instanceof EndUserTransactionCommand)) {
throw new Exception("Command is not user transaction");
}
while (!((command = undo()) instanceof StartUserTransactionCommand)) {
counter++;
}
} catch (Exception e) {
e.printStackTrace();
while (counter > 0) {
counter--;
redo();
}
}
}
use of com.ramussoft.common.journal.command.StartUserTransactionCommand in project ramus by Vitaliy-Yakovchuk.
the class InternetHookJournal method undo.
@Override
public Command undo() {
Command undo = super.undo();
if (undo instanceof StartUserTransactionCommand) {
try {
long cursor = getPointer();
byte[] bs = new byte[(int) (this.cursor - cursor)];
accessFile.read(bs);
accessFile.seek(cursor);
this.cursor = cursor;
onUndo(bs);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return undo;
}
use of com.ramussoft.common.journal.command.StartUserTransactionCommand in project ramus by Vitaliy-Yakovchuk.
the class History method refresh.
private void refresh(JournalEvent event) {
if (!framework.getMainFrame().isActive())
return;
if (event.getCommand() instanceof StartUserTransactionCommand) {
long branch = -1;
if (event.getJournal() != null)
branch = event.getJournal().getBranch();
Hashtable<Long, Command> hash = getHash(branch);
Command command = hash.get(event.getIndex());
if (command == null)
return;
ActionEvent actionEvent = command.event;
if (actionEvent != null) {
framework.propertyChanged(actionEvent);
if (command.workspace != null) {
if (!command.workspace.equals(framework.getCurrentWorkspace())) {
framework.propertyChanged("ShowWorkspace", command.workspace);
}
}
}
}
}
Aggregations