[英]How to use the Edit button in eclipse for a plugin eclipse
您可以使用在org.eclipse.ui.editors
擴展點中指定的編輯器操作欄貢獻者類來執行此操作
<extension point="org.eclipse.ui.editors">
<editor
id="com.xyz.Editor"
contributorClass="com.xyz.EditorContributor"
...more ....>
</editor>
</extension>
您的貢獻者類通常將擴展org.eclipse.ui.part.EditorActionBarContributor
。 對於文本編輯器或多頁編輯器,還可以擴展其他貢獻者類。
您可以重寫setActiveEditor
方法,以在編輯器處於活動狀態時被告知。 當您的編輯器處於活動狀態時,您可以為要處理的全局動作設置全局動作處理程序,例如:
public class EditorContributor extends EditorActionBarContributor
{
private IEditorPart activeEditorPart = null;
@Override
public void setActiveEditor(IEditorPart targetEditor)
{
if (activeEditorPart == targetEditor)
return;
activeEditorPart = targetEditor;
if (targetEditor instanceof MyEditor) {
IActionBars actionBars = getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
// ... more global action handlers
}
}
}
其中copyAction
是您編寫的Action
。
您還可以覆蓋contributeToToolBar
和contributeToMenu
方法以添加新操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.