package com.cedarsoft.utils.springrcp.beanlist.command;
import com.cedarsoft.utils.springrcp.beanlist.BeanListView;
import org.jetbrains.annotations.NotNull;
import org.springframework.richclient.command.ActionCommand;
import org.springframework.richclient.dialog.ConfirmationDialog;
/**
* <p/>
* Date: 29.08.2006<br>
* Time: 14:49:40<br>
*
* @author <a href="http://johannes-schneider.info">Johannes Schneider</a> -
* <a href="http://www.xore.de">Xore Systems</a>
*/
@Deprecated
public class DeleteCommand<T> extends ActionCommand {
private BeanListView<T> listView;
public DeleteCommand( @NotNull BeanListView<T> listView ) {
super( "deleteAction" );
this.listView = listView;
}
@Override
protected void doExecuteCommand() {
final T bean = listView.getSelectedBean();
if ( bean == null ) {
throw new IllegalStateException( "Bean is null" );
}
String title = "delete." + listView.getBeanType().getName();
String message = "delete." + listView.getBeanType().getName() + bean; //TODO message format
ConfirmationDialog dialog = new ConfirmationDialog( title, listView.getContext().getWindow().getControl(), message ) {
@Override
protected void onConfirm() {
listView.getBeanManager().delete( bean );
}
};
dialog.showDialog();
}
}