Package tool.action

Source Code of tool.action.FindTypeDelegate

package tool.action;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.part.FileEditorInput;

import tool.editors.ToolEditor;
import tool.editors.method.MethodEditor;
import tool.editors.method.MethodEditorInput;
import tool.model.ToolComponent;
import tool.search.FindTypeDialog;

public class FindTypeDelegate  extends ActionDelegate implements IEditorActionDelegate {

  private static final String ID = "tool.editor.findType";
  protected MethodEditor currentEditorPart;
  protected ISelectionService selectionService;
 
  @Override
  public void setActiveEditor(IAction action, IEditorPart editorPart) {
    if (editorPart != null && editorPart instanceof MethodEditor){
      this.currentEditorPart = (MethodEditor)editorPart;
      this.selectionService = editorPart.getSite().getWorkbenchWindow().getSelectionService();
    }
  }

  @Override
  public void run(IAction action) {
    ISelection selection = this.selectionService.getSelection();
    MethodEditorInput input = (MethodEditorInput)this.currentEditorPart.getEditorInput();
    IProject project = input.getFile().getProject();
    ToolComponent cls = FindTypeDialog.show(project, selection);
    if (cls != null){
      OpenClassDelegate.showInEditor(cls);
    }
  }
}
TOP

Related Classes of tool.action.FindTypeDelegate

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.