用JBuilder实现类似Visual Studio的宏扩展功能 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-23
ode.Node; import com.borland.primetime.vfs.Url; import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.PrintStream; import javax.swing.*; import javax.swing.text.JTextComponent; import javax.swing.text.Keymap; public class JavaCommentSwitch extends EditorAction implements PropertyChangeListener { private static final String versionString = "0.1"; public static EditorAction ACTION_CreateJavaCommentSwitch = new JavaCommentSwitch("JavaCommentSwitch"); protected static String STR_LONG_DESCRIPTION = "Comment/Uncomment for selection."; // 状态条显示 protected static String STR_SHORT_DESCRIPTION = "Comment/Uncomment for selection."; public static EditorAction ACTION_GenerateJavaCommentSwitch = new JavaCommentSwitch("JavaCommentSwitch", true); protected static String MENU_STR_LONG_DESCRIPTION = "Comment/Uncomment for selection"; protected static String MENU_STR_SHORT_DESCRIPTION = "Comment/Uncomment"; static Browser browser = null; private EditorPane target; private String errorMessageText; private boolean isMenuAction; public JavaCommentSwitch(String name) { super(name); target = null; errorMessageText = ""; isMenuAction = false; } public JavaCommentSwitch(String name, boolean isMenuAction) { super(name); target = null; errorMessageText = ""; this.isMenuAction = isMenuAction; } public static void initOpenTool(byte majorVersion, byte minorVersion) { if(majorVersion < 4) // 支持Jbuilder 4.0以上 return; EditorManager.registerContextActionProvider(IDEActions.CONTEXTMENU_ActionProvider); ACTION_GenerateJavaCommentSwitch.putValue("LongDescription", MENU_STR_LONG_DESCRIPTION); ACTION_GenerateJavaCommentSwitch.putValue("ShortDescription", MENU_STR_SHORT_DESCRIPTION); EditorActions.addBindableEditorAction(ACTION_CreateJavaCommentSwitch); ACTION_CreateJavaCommentSwitch.putValue("LongDescription", STR_LONG_DESCRIPTION); ACTION_CreateJavaCommentSwitch.putValue("ShortDescription", STR_SHORT_DESCRIPTION); Keymap keymap = EditorManager.getKeymap(); // 支持快捷键 ALT + F10 if(keymap != null) { KeyStroke stroke[] = keymap.getKeyStrokesForAction(ACTION_CreateJavaCommentSwitch); if(stroke == null) keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(java.awt.Event.F10, java.awt.Event.ALT_MASK ), ACTION_CreateJavaCommentSwitch); } EditorManager.addPropertyChangeListener((PropertyChangeListener)ACTION_CreateJavaCommentSwitch); } public void actionPerformed(ActionEvent evt) { target = getEditorTarget(evt); Node theNode = getNode(); if(theNode == null) return; JBProject proj = (JBProject)theNode.getProject(); JotClass theClass = getClass(theNode); if(isMenuAction) if(theClass != null) runJavaCommentSwitch(); else JOptionPane.showMessageDialog(null, "Current Editor target is not a java class.", "Erro |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于用JBuilder实现类似Visual Studio的宏扩展功能 - 编程入门网的所有评论