Package ch.fusun.baron.serverapp.command

Source Code of ch.fusun.baron.serverapp.command.LoadStateCommand

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;
  }
}
TOP

Related Classes of ch.fusun.baron.serverapp.command.LoadStateCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.