package com.cedarsoft.spring.rcp.commands;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NonNls;
import com.cedarsoft.spring.rcp.async.BackgroundAction;
import com.cedarsoft.spring.rcp.async.BlockingBackgroundActionRunner;
/**
* Executes a background action within a command
*/
public class BackgroundActionCommand extends ExtendedCommand {
@NotNull
private final BackgroundAction backgroundAction;
/**
* Creates a new command
*
* @param commandId the command id
* @param backgroundAction the background action that is executed
*/
public BackgroundActionCommand( @NotNull @NonNls String commandId, @NotNull BackgroundAction backgroundAction ) {
super( commandId );
this.backgroundAction = backgroundAction;
}
@Override
protected void executeCommand() throws Exception {
new BlockingBackgroundActionRunner( getApplicationWindow(), backgroundAction ).run();
}
}