Package edu.zao.fire.commands

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

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.metadata.MetadataRuleEditor;
import edu.zao.fire.editors.metadata.MetadataRuleEditorInput;

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

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

    try {
      page.openEditor(new MetadataRuleEditorInput(), MetadataRuleEditor.ID);
    } catch (PartInitException e) {
      e.printStackTrace();
    }
    return null;
  }
}
TOP

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

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.