用JBuilder实现类似Visual Studio的宏扩展功能 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-23
r creating javadoc", 0);
}
/**
* @description
*
* @param
* @return
* @exception
*/
private boolean runJavaCommentSwitch()
{
String selection = target.getSelectedText();
String newSelection = "";
// 去掉注释
if(selection.trim().startsWith("/*") && selection.trim().endsWith("*/"))
{
StringBuffer sb = new StringBuffer(selection);
newSelection = sb.substring(2, selection.length() - 2);
}
// 添加注释
else
{
newSelection = String.valueOf(String.valueOf((new StringBuffer("/*")).append(selection).append("*/")));
}
target.replaceSelection(newSelection);
return true;
}
public void propertyChange(PropertyChangeEvent evt)
{
String propertyName = evt.getPropertyName();
if(propertyName.equals("keymap"))
{
Keymap keymap = EditorManager.getKeymap();
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);
}
}
}
protected Node getNode()
{
Browser browser = Browser.getActiveBrowser();
Node node = browser.getActiveNode();
if((node instanceof JavaFileNode) && (node.getProject() instanceof JBProject))
return node;
else
return null;
}
protected JotClass getClass(Node node)
{
if((node instanceof JavaFileNode) && (node.getProject() instanceof JBProject))
{
JBProject project = (JBProject)node.getProject();
String filename = ((JavaFileNode)node).getUrl().getFile();
JotPackages pkg = project.getJotPackages();
Url url = new Url(new File(filename));
JotFile jfile = pkg.getFile(url);
JotClass jclasses[] = jfile.getClasses();
if(jclasses.length > 1)
{
System.err.println("More than one class found in source file");
errorMessageText = "More than one class found in source file";
return null;
}
if(jclasses.length == 0)
{
System.err.println("No classes found in source file");
errorMessageText = "No classes found in source file";
return null;
} else
{
return jclasses[0];
}
} else
{
return null;
}
}
} |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于用JBuilder实现类似Visual Studio的宏扩展功能 - 编程入门网的所有评论