网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>JAVA>>新手入门>>基础入门>查看文档  
  eclipse开发经验:文本替换和操作界面     
  文章作者:未知  文章来源:赛迪网技术社区  
  查看:101次  录入:管理员--2007-11-16  
 

快速eclipse插件开发经验:

1.取得对当前选中文本内容,并转换。

1)定义action实现ieditoractiondelegate接口。

2)取得当前编辑器(geteditor())。

platformui.getworkbench().getactiveworkbenchwindow().getactivepage().getactiveeditor();

3)取得选中文本。

(itextselection) geteditor().geteditorsite().getselectionprovider().getselection();

4)替换选中文本。

abstracttexteditor editor = (abstracttexteditor) geteditor();

editor.getdocumentprovider().getdocument(editor.geteditorinput());

document.replace(offset, length, replacetext);

5)选中替换后的文本。

itextselection tsnew = new textselection(document, offset, length);

geteditor().geteditorsite().getselectionprovider().setselection(tsnew);

2.菜单分组,图标,快捷键,工具条的实现。

1)菜单分组。如下分成4组,组之间有分隔线。

<menu label="xxxxtools(&amp;t)" id="xxxxtoolsmenu">
<separator name="xxxxtoolsgrouptxt"></separator>
<separator name="xxxxtoolsgroupsql"></separator>
<separator name="xxxxtoolsgroupcode"></separator>
<separator name="xxxxtoolsgrouprefrence"></separator>
</menu>

2)分配action到组。设置图标。和工具条。

<action label="to lower case(&amp;l)"
       class="xxxxtools.actions.text.tolowercaseaction"
       icon="icons/lower.gif"
       menubarpath="xxxxtoolsmenu/xxxxtoolsgrouptxt"
       toolbarpath="xxxxtoolsgrouptxt"
       id="xxxxtools.actions.text.tolowercaseaction"
       definitionid="xxxxtools.actions.text.tolowercaseaction">
       <selection class="org.eclipse.jface.text.itextselection" />
</action>

3)设置快捷键。

<extension point="org.eclipse.ui.commands">     
       <command name="to lower case"
                     id="xxxxtools.actions.text.tolowercaseaction" /> 
</extension>
<extension point="org.eclipse.ui.bindings">        
       <key sequence="ctrl+shift+u"
                     contextid="org.eclipse.ui.texteditorscope"
                     commandid="xxxxtools.actions.text.tolowercaseaction"
                     schemeid="org.eclipse.ui.defaultacceleratorconfiguration" />
</extension>

 
 
上一篇: hibernate+struts的j2ee应用开发    下一篇: fckeditor编辑器在java中的使用与配置
  相关文档
mvc 构架学习之渐行渐进(三) 11-17
struts 的汉字显示问题终结解决方案 11-17
使用iterator节省代码 11-17
更好的捕捉鼠标事件 11-17
精通hibernate之映射继承关系五 11-17
java 2 引用类使用指南 11-17
在网页上发布统计曲线(applet) 11-17
无需 jce 用底层 api 实现开发 rsa 11-17
设计模式与java 11-17
如何控制你的屏幕(screen)对象属性 11-17
sun 认证多数考生对教材的选择 11-17
在tomcat5中配置数据库连接池(dbcp) 11-17
一个简单编程思想在php与java中的实现比较:日期类 11-17
采用ant进行诊断测试 11-17
新手入门:写java程序的三十个基本规则 11-17
java ide鱼龙混杂,我们该如何选择呢? 11-17
sql server中可支持web的分析功能 11-17
java中的模式(1) 11-17
在oracle中存取blob对象实现文件的上传和下载 11-17
跨越边界: java 模型以外的类型策略 11-17
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
技术电话:13616026886
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息