在JBuilder5中增加注释与反注释工具 (转)

在JBuilder5中增加注释与反注释工具 (转)[@more@]

看了levin_zhang写的注释与反注释Comment/Uncomment selected code in Visual C++ 文章, 也想到在JBuilder5中没有这样的功能, 于是也写了一个Comment/Uncomment工具.

JBuilder5提供了一个Open Tools开发工具给使用者来增强JBuilder5的功能。更多的这样的Open tools工具请看www.borland.com  的community中的code contral.

实现comment/uncomment的功能代码如下:

  private boolean CreateComment()
  {
  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 = "/*" + selection + "*/";
  }
  target.replaceSelection(newSelection);
  return true;

  }

感谢.NET">Christopher Fitch,  我的这个程式参考了他的JavaDocCreator.

这个工具的名字是JavaCommentCreator.jar,使用时将其放到jbuilder5/lib/ext/目录中,重新启动jbuilder即可.

使用方法,选取一段文字,点右键出现菜单,选 Comment/Uncomment Selection即可。在所选 文字的两端加上的/*和*/, Uncomment时从/*选到*/再点Comment/Uncomment Selection菜单即可.

下载地址:

ASP?id=856">http://www.****.net/filebbs/read_topic.asp?id=856