简体   繁体   English

Eclipse重命名元素键盘快捷键

[英]Eclipse rename element keyboard shortcut

I have written an Eclipse View that displays a tree of elements. 我编写了一个Eclipse View,其中显示了元素树。

How can I hook into the standard Eclipse "Rename - Refactoring" keyboard shortcut so that when I press Shift + Alt + R with an element of my tree selected I can handle renaming that element? 如何连接标准的Eclipse“重命名-重构”键盘快捷键,以便在选择树的某个元素时按Shift + Alt + R时可以处理该元素的重命名?

I think I might need to use one of the LTK extension points. 我认为我可能需要使用LTK扩展点之一。

I found the correct code: 我找到了正确的代码:

IActionBars actionBars = getViewSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), new Action()
{
  @Override
  public void run()
  {
    ISelection viewSelection = viewer.getSelection();
    if (viewSelection instanceof IStructuredSelection)
    {
      IStructuredSelection selection = (IStructuredSelection)viewSelection;
      Object o = selection.getFirstElement();

      ....
    }
  }
});

http://wiki.eclipse.org/FAQ_How_do_I_hook_into_global_actions,_such_as_Copy_and_Delete%3F http://wiki.eclipse.org/FAQ_How_do_I_hook_into_global_actions,_such_as_Copy_and_Delete%3F

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM