blob: 5d260f137e3101ed2ffd0b0db9a5eefda830411c [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
package org.eclipse.osbp.runtime.emf.edit.commands;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.osbp.runtime.emf.change.ChangedRecorder;
/**
* Uses the {@link ChangeCommand} to record notifications.
*/
public abstract class ChangeCommand extends AbstractCommand {
private Resource resource;
private ChangedRecorder recorder;
public ChangeCommand(String name, Resource resource) {
super(name);
this.resource = resource;
}
@Override
public void execute() {
recorder.start();
doExecute();
recorder.stop();
}
/**
* Execute your operations.
*/
protected abstract void doExecute();
@Override
public void redo() {
recorder.redo();
}
@Override
protected boolean prepare() {
recorder = new ChangedRecorder(resource);
return true;
}
@Override
public void undo() {
recorder.undo();
}
@Override
public boolean canUndo() {
return super.canUndo();
}
}