Search in sources :

Example 6 with StartUserTransactionCommand

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();
        }
    }
}
Also used : CreateAttributeCommand(com.ramussoft.common.journal.command.CreateAttributeCommand) UpdateAttributeCommand(com.ramussoft.common.journal.command.UpdateAttributeCommand) DeleteElementCommand(com.ramussoft.common.journal.command.DeleteElementCommand) SetElementQualifierCommand(com.ramussoft.common.journal.command.SetElementQualifierCommand) CreateQualifierCommand(com.ramussoft.common.journal.command.CreateQualifierCommand) DeleteQualifierCommand(com.ramussoft.common.journal.command.DeleteQualifierCommand) TransactionStorageCommand(com.ramussoft.common.journal.command.TransactionStorageCommand) Command(com.ramussoft.common.journal.command.Command) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand) DeleteAttributeCommand(com.ramussoft.common.journal.command.DeleteAttributeCommand) FormulaCommand(com.ramussoft.common.journal.command.FormulaCommand) NewBranchCommand(com.ramussoft.common.journal.command.NewBranchCommand) UpdateQualifierCommand(com.ramussoft.common.journal.command.UpdateQualifierCommand) CreateElementCommand(com.ramussoft.common.journal.command.CreateElementCommand) SetStreamCommand(com.ramussoft.common.journal.command.SetStreamCommand) EndUserTransactionCommand(com.ramussoft.common.journal.command.EndUserTransactionCommand) NextCommand(com.ramussoft.common.journal.command.NextCommand) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EndUserTransactionCommand(com.ramussoft.common.journal.command.EndUserTransactionCommand)

Example 7 with StartUserTransactionCommand

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;
}
Also used : Command(com.ramussoft.common.journal.command.Command) EndUserTransactionCommand(com.ramussoft.common.journal.command.EndUserTransactionCommand) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand)

Example 8 with StartUserTransactionCommand

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);
                }
            }
        }
    }
}
Also used : StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) StartUserTransactionCommand(com.ramussoft.common.journal.command.StartUserTransactionCommand)

Aggregations

StartUserTransactionCommand (com.ramussoft.common.journal.command.StartUserTransactionCommand)8 Command (com.ramussoft.common.journal.command.Command)5 EndUserTransactionCommand (com.ramussoft.common.journal.command.EndUserTransactionCommand)5 IOException (java.io.IOException)4 CreateAttributeCommand (com.ramussoft.common.journal.command.CreateAttributeCommand)3 CreateElementCommand (com.ramussoft.common.journal.command.CreateElementCommand)3 CreateQualifierCommand (com.ramussoft.common.journal.command.CreateQualifierCommand)3 DeleteAttributeCommand (com.ramussoft.common.journal.command.DeleteAttributeCommand)3 DeleteElementCommand (com.ramussoft.common.journal.command.DeleteElementCommand)3 DeleteQualifierCommand (com.ramussoft.common.journal.command.DeleteQualifierCommand)3 FormulaCommand (com.ramussoft.common.journal.command.FormulaCommand)3 NewBranchCommand (com.ramussoft.common.journal.command.NewBranchCommand)3 NextCommand (com.ramussoft.common.journal.command.NextCommand)3 SetElementQualifierCommand (com.ramussoft.common.journal.command.SetElementQualifierCommand)3 SetStreamCommand (com.ramussoft.common.journal.command.SetStreamCommand)3 TransactionStorageCommand (com.ramussoft.common.journal.command.TransactionStorageCommand)3 UpdateAttributeCommand (com.ramussoft.common.journal.command.UpdateAttributeCommand)3 UpdateQualifierCommand (com.ramussoft.common.journal.command.UpdateQualifierCommand)3 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2