![Stefano Mazzocchi](/assets/img/avatar_default.png)
(no functional changes) git-svn-id: http://google-refine.googlecode.com/svn/trunk@62 7d457c2a-affb-35e4-300a-418c747d4874
66 lines
1.6 KiB
Java
66 lines
1.6 KiB
Java
package com.metaweb.gridworks.history;
|
|
|
|
import java.util.Properties;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONWriter;
|
|
|
|
import com.metaweb.gridworks.model.Project;
|
|
import com.metaweb.gridworks.process.Process;
|
|
import com.metaweb.gridworks.process.ProcessManager;
|
|
|
|
public class HistoryProcess extends Process {
|
|
final protected Project _project;
|
|
final protected long _lastDoneID;
|
|
final protected String _description;
|
|
|
|
protected boolean _done = false;
|
|
|
|
public HistoryProcess(Project project, long lastDoneID) {
|
|
_project = project;
|
|
_lastDoneID = lastDoneID;
|
|
|
|
if (_lastDoneID == 0) {
|
|
_description = "Undo all";
|
|
} else {
|
|
HistoryEntry entry = _project.history.getEntry(_lastDoneID);
|
|
_description = "Undo/redo until after " + entry.description;
|
|
}
|
|
}
|
|
|
|
public void cancel() {
|
|
throw new RuntimeException("Not a long-running process");
|
|
}
|
|
|
|
public boolean isImmediate() {
|
|
return true;
|
|
}
|
|
|
|
public void performImmediate() {
|
|
_project.history.undoRedo(_lastDoneID);
|
|
_done = true;
|
|
}
|
|
|
|
public void startPerforming(ProcessManager manager) {
|
|
throw new RuntimeException("Not a long-running process");
|
|
}
|
|
|
|
public void write(JSONWriter writer, Properties options)
|
|
throws JSONException {
|
|
|
|
writer.object();
|
|
writer.key("description"); writer.value(_description);
|
|
writer.key("immediate"); writer.value(true);
|
|
writer.key("status"); writer.value(_done ? "done" : "pending");
|
|
writer.endObject();
|
|
}
|
|
|
|
public boolean isDone() {
|
|
throw new RuntimeException("Not a long-running process");
|
|
}
|
|
|
|
public boolean isRunning() {
|
|
throw new RuntimeException("Not a long-running process");
|
|
}
|
|
}
|