Package tool.commands

Source Code of tool.commands.FindType

package tool.commands;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.FileEditorInput;

import tool.action.OpenClassDelegate;
import tool.model.ToolComponent;
import tool.search.FindTypeDialog;



public class FindType extends CommonHandler{

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IProject project = null;
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    HandlerUtil.getActiveContexts(event);
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if ((selection instanceof TextSelection) && (editor != null)){
      FileEditorInput input = (FileEditorInput)editor.getEditorInput();
      project = input.getFile().getProject();
    } else if (selection instanceof TreeSelection){
      project = getProjectFromSelection(selection);
    }
    if (project != null){
      ToolComponent cls = FindTypeDialog.show(project, selection);
      if (cls != null){
        OpenClassDelegate.showInEditor(cls);
      }
    }
    return null;
  }

}
TOP

Related Classes of tool.commands.FindType

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.