package ch.fusun.baron.serverapp.command;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import ch.fusun.baron.serverapp.Activator;
import ch.fusun.baron.serverapp.messages.Messages;
/**
* Command to save the state of the server in a file
*/
public class SaveStateCommand extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
FileDialog fd = new FileDialog(new Shell(), SWT.SAVE);
fd.setText(Messages.SaveStateCommand_Save);
String[] filterExt = { "*.baron", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
fd.setFilterExtensions(filterExt);
String selected = fd.open();
if (selected != null) {
Activator.getDefault().getServer().saveState(selected);
}
return null;
}
}