2. 覆寫 MyEditor.getContentFormatter
3. 實作 MyStrategy extends ContextBasedFormattingStrategy
4. 在 plugin.xml 加入: plugin.xml
5. 新增 Action
<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="MyEditor Action set"
description="Action set description"
visible="false"
id="MY_PLUGIN.myActionSet">
<action
definitionId="*MY_PLUGIN_ACTION_NAME*"
label="Format"
retarget="true"
menubarPath="org.eclipse.dltk.ui.source.menu/editGroup"
id="MY_PLUGIN.MY_ACTION_FORMAT_ID">
</action>
</actionSet>
</extension>
6. 新增 Key binding
7. 新增 Command
8. MyScriptEditor implementation override method createActions(){
super.createActions();
action= new TextOperationAction(DLTKEditorMessages.getBundleForConstructedKeys(), "Format.", this, ISourceViewer.FORMAT);
action.setActionDefinitionId("*MY_PLUGIN.MY_ACTION_NAME*");
setAction("Format", action);
markAsStateDependentAction("Format", true);
markAsSelectionDependentAction("Format", true);
}
9. Editor context parent 必須是:
"org.eclipse.dltk.ui.scriptEditorScope"
沒有留言:
張貼留言