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;
/**
* Loads state of the game
*/
public class LoadStateCommand extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
FileDialog fd = new FileDialog(new Shell(), SWT.OPEN);
fd.setText(Messages.LoadStateCommand_Open);
String[] filterExt = { "*.baron", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
fd.setFilterExtensions(filterExt);
String selected = fd.open();
if (selected != null) {
Activator.getDefault().getServer().loadState(selected);
}
return null;
}
}