Package ch.fusun.baron.serverapp.command

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

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

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

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.