menuContribution 내에서 'visibleWhen'표현식을 사용하여 상황에 맞는 메뉴 내에서 명령의 가시성을 구성하려고합니다.visible 문맥 메뉴에 명령을 표시 할 때
- 마우스 오른쪽 단추로 클릭하고 리소스 뷰에서 특정 파일 형식 (자원) (또는 패키지보기)
- 를 마우스 오른쪽 단추로 클릭 : 내가 뭘하려고 만하면 상황에 맞는 메뉴에서 명령을 볼 수 있도록이다 파일 형식이 열린 적절한 편집기. 내 에디터가 열려 있거나 에디터에 특정 리소스가 열려 있음을 감지 할 수 있습니다.
첫 번째로 'visibleWhen'> '선택 (with)'> 'iterate'> 'org.eclipse.core.resources.IResource (adapt)'를 수행 한 다음 리소스에 대한 파일 확장자를 확인했습니다. . 코드는 다음과 같습니다. 그러나 올바른 확장명 (예 : ext1, ext2)이 설정된 올바른 편집기를 마우스 오른쪽 단추로 클릭 할 때만 동일한 명령을 표시하는 방법을 모르겠습니다.
내 에디터가 활성 상태인지 확인하면 두 번째 문제가 해결되지만 내 유형이 아닌 파일을 클릭해도 컨텍스트 메뉴에 명령이 표시되므로 도움이되지 않습니다.
어떤 권장 사항이 있습니까? "Eclipse Plug-ins (3rd Edition)"은 편집기 상황에 맞는 메뉴의 몇 가지 예를 보여 주지만 액션을 사용하므로 명령을 계속 사용하고자합니다.
감사합니다.
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?before=additions">
<separator
name="com.test.ide.separator1"
visible="true">
</separator>
<menu
icon="icons/sample.gif"
label="Test Menu">
<command
commandId="com.test.commands.testCommand1"
icon="icons/sample.gif"
label="testCommand1"
style="push"
tooltip="This is a test command">
<visibleWhen
checkEnabled="false">
<with
variable="selection">
<iterate
ifEmpty="false"
operator="or">
<adapt
type="org.eclipse.core.resources.IResource">
<or>
<test
property="org.eclipse.core.resources.extension"
value="ext1">
</test>
<test
property="org.eclipse.core.resources.extension"
value="ext2">
</test>
</or>
</adapt>
</iterate>
</with>
</visibleWhen>
</command>
</menu>
</menuContribution>
맞습니다.하지만 약간의 구조 조정 최적화를 제안합니다 : –