JDT의 "리팩터링"컨텍스트 메뉴와 유사한 퀵메뉴에 대한 키 바인딩을 어떻게 추가 할 수 있습니까?
기존 바인딩으로 빠른 메뉴를 표시하기 위해 이클립스 플러그인에 바로 가기를 추가하고 싶습니다. JDT의 "리팩터링"퀵 메뉴처럼 작동합니다.
JDT의 빠른 메뉴 바로 가기 :
JDT 빠른 메뉴 :
이미 바인딩과 명령을 추가했지만 뭔가 빠진 것 같습니다. 삭제 뭔가 항목이 또한 상황에 맞는 메뉴를 위해 노력하고, 빠른 메뉴로 바로 가기가 없습니다. 아무도 이것을하는 방법이 있습니까?
<extension point="org.eclipse.ui.bindings">
<key
commandId="myplugin.refactoring.actions.DeleteSomething"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+5">
</key>
<key
commandId="myplugin.refactoring.quickMenu"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+9">
</key>
<extension point="org.eclipse.ui.commands">
<command
categoryId="myplugin.category.refactor"
description="Delete Something"
id="myplugin.refactoring.actions.DeleteSomething"
name="Extract Method">
</command>
<command
categoryId="myplugin.category.refactor"
id="myplugin.refactoring.quickMenu"
name="Show Refactor Quick Menu">
</command>
<category
id="myplugin.category.refactor"
name="Refactor">
</category>
다음과 같이 할 수도 있습니다.
빠른 메뉴에 대한 명령을 추가하고 기본 처리기를 설정합니다.
<command
defaultHandler="myplugin.refactoring.QuickmenuHandler"
id="myplugin.refactoring.quickMenu"
name="Show Refactor Quick Menu">
</command>
핸들러는 메뉴를 생성 할 수 있어야합니다. 이 같은:
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
...
Menu menu = new Menu(some parent);
new MenuItem(menu, SWT.PUSH).setText("...");
menu.setVisible(true);
return null;
}
명령에 바로 가기를 추가합니다 (예 :
<key
commandId="myplugin.refactoring.quickMenu"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+9">
</key>
마지막으로 메뉴 확장 점에서이 모든 것을 함께 묶습니다.
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:ch.arenae.dnp.frame.popup?after=additions">
<menu
commandId="myplugin.refactoring.quickMenu"
label="Refactor">
<command
commandId="<first refactoring command>"
style="push">
</command>
</menu>
...
</menuContribution>
The important point is the commandId attribute in the menu element. It is used to display the keyboard shortcut in the menu.
You can have a look at how JDT implements the same. For instance, when looking at the Eclipse 3.8.2 source code, you'll see interesting method:
org.eclipse.jdt.ui.actions.RefactorActionGroup.installQuickAccessAction()
which is called when Java editor is opened. This is were programmatic handler association with current editor takes place.
To summarize how it's done in JDT:
First, they have a command declaration in plugin.xml:
<command name="%ActionDefinition.refactorQuickMenu.name" description="%ActionDefinition.refactorQuickMenu.description" categoryId="org.eclipse.jdt.ui.category.refactoring" id="org.eclipse.jdt.ui.edit.text.java.refactor.quickMenu">
They declare a key binding:
<key sequence = "M2 + M3 + T"commandId = "org.eclipse.jdt.ui.edit.text.java.refactor.quickMenu"schemeId = "org.eclipse.ui.defaultAcceleratorConfiguration"/>
편집기가 생성되면이 명령을 핸들러와 연결합니다. 핸들러 자체 (
org.eclipse.jdt.internal.ui.actions.JDTQuickMenuCreator
)는 빠른 메뉴를 항목으로 채우는 작업을 처리합니다.
프로그래밍 방식으로 명령을 핸들러와 연관시킬 필요가 없습니다. 다른 옵션은 org.eclipse.ui.handlers 확장 점을 사용하는 것입니다.
'Programing' 카테고리의 다른 글
jQuery에서 특정 ID를 가진 모든 요소를 선택하는 방법은 무엇입니까? (0) | 2020.11.06 |
---|---|
배치 스크립트에서 파일에 "2"(따옴표 없음)를 에코하는 방법은 무엇입니까? (0) | 2020.11.06 |
knitr / Rmd : n 줄 / n 거리 이후 페이지 나누기 (0) | 2020.11.06 |
DotNetOpenAuth ServiceProvider에서 PLAINTEXT 서명을 사용할 수 없습니다. (0) | 2020.11.06 |
EF : 지연로드 된 필수 속성을 사용할 때 업데이트시 유효성 검사 실패 (0) | 2020.11.05 |