use of com.intellij.openapi.command.undo.GlobalUndoableAction in project android by JetBrains.
the class AndroidDbManager method processAddOrRemove.
public void processAddOrRemove(final AndroidDataSource dataSource, final boolean add) {
final Project project = myDbFacade.getProject();
final UndoableAction action = new GlobalUndoableAction() {
public void undo() throws UnexpectedUndoException {
if (add) {
removeDataSourceInner(project, dataSource);
} else {
addDataSourceInner(project, dataSource);
}
}
public void redo() throws UnexpectedUndoException {
if (add) {
addDataSourceInner(project, dataSource);
} else {
removeDataSourceInner(project, dataSource);
}
}
};
final String commandName = add ? DatabaseMessages.message("command.name.add.data.source") : DatabaseMessages.message("command.name.remove.data.source");
new WriteCommandAction(project, commandName) {
protected void run(@NotNull final Result result) throws Throwable {
action.redo();
UndoManager.getInstance(project).undoableActionPerformed(action);
}
@Override
protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
return UndoConfirmationPolicy.REQUEST_CONFIRMATION;
}
}.execute();
}
Aggregations