Package edu.zao.fire.commands

Source Code of edu.zao.fire.commands.OpenMatchReplaceCommandHandler

package edu.zao.fire.commands;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;

import edu.zao.fire.editors.matchreplace.MatchReplaceRuleEditor;
import edu.zao.fire.editors.matchreplace.MatchReplaceRuleEditorInput;

/**
* Command invoked by the Eclipse RCP framework (as set up in plugin.xml)
* whenever the user selects the "New Match/Replace Rule" option from the menu
* or the toolbar.
*
* @author Dylan
*/
public class OpenMatchReplaceCommandHandler extends AbstractHandler {

  /**
   * Opens a new MatchReplaceRuleEditor in the UI, with a brand new
   * MatchReplaceEditorInput.
   */
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();

    try {
      page.openEditor(new MatchReplaceRuleEditorInput(), MatchReplaceRuleEditor.ID);
    } catch (PartInitException e) {
      e.printStackTrace();
    }
    return null;
  }

}
TOP

Related Classes of edu.zao.fire.commands.OpenMatchReplaceCommandHandler

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.