- 浏览: 2444432 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (574)
- Book (62)
- Architecture (6)
- Java (39)
- Taobao (41)
- Distributed (4)
- Life (72)
- Database (7)
- Spring (16)
- Photography (15)
- Bicycle (41)
- Test (20)
- jBPM (8)
- Business (12)
- Movie (3)
- Ajax (15)
- Code (7)
- Eclipse (96)
- VIM (2)
- Music (6)
- Groovy (10)
- AutoHotKey (3)
- Dorado (10)
- Maven (7)
- Scrum (5)
- English (20)
- Financial (12)
- OSGi (3)
- Other (4)
- Tool (6)
- Browser (1)
- PPT (1)
- Project Management (4)
- Agile (6)
- Nosql (1)
- Search engine (6)
- Shell (2)
- Open Source (4)
- Storm (10)
- Guava (3)
- Baby (1)
- netty (1)
- Algorithm (1)
- Linux (1)
- Python (2)
最新评论
-
roy2011a:
https://github.com/ebottabi/sto ...
storm的序列化问题及与spring的结合方式 -
roy2011a:
能抗能打 写道哥们儿,你好!能共享下那个storm与sprin ...
storm的序列化问题及与spring的结合方式 -
Alick1:
兄弟,你之前是不是在深圳的正阳公司呆过啊?
storm的ack和fail -
liuleixwd:
先点个赞,写的非常好!有个问题请教下,如果我再bolt里不用e ...
storm的ack和fail -
yao-dd:
solr的facet查询
最近开发中碰到要在EMF中对某个模型的内容放到JFace Text Editor中去编辑,于是把Text Editor研究了一番,发现其默认的实现是基于文件的,而我希望对一段字符串进行编辑,看了半天代码没有找到突破口,曾经想过使用临时文件来处理这个问题,好在eclipse.org上找到一篇文章解决了我们的问题,其做法就是使用IStorageEditerInput 来作为Text Editor的输入。原文如下:
FROM:http://wiki.eclipse.org/index.php/FAQ_How_do_I_open_an_editor_on_something_that_is_not_a_file%3F
Most editors will accept as input either an IFileEditorInput or an IStorageEditorInput. The former can be used only for opening files in the workspace, but the latter can be used to open a stream of bytes from anywhere. If you want to open a file on a database object, remote file, or other data source, IStorage is the way to go. The only downside is that this is a read-only input type, so you can use it only for viewing a file, not editing it. To use this approach, implement IStorage so that it returns the bytes for the file you want to display. Here is an IStorage that returns the contents of a string:
- class StringStorage extends PlatformObject
- implements IStorage {
- private String string;
- StringStorage(String input) {this.string = input;}
- public InputStream getContents() throws CoreException {
- return new ByteArrayInputStream(string.getBytes());
- }
- public IPath getFullPath() {return null;}
- public String getName() {
- int len = Math.min(5, string.length());
- return string.substring(0, len).concat("...");
- }
- public boolean isReadOnly() {return true;}
- }
The class extends PlatformObject to inherit the standard implementation of IAdaptable, which IStorage extends. The getName and getFullPath methods can return null if they are not needed. In this case, we've implemented getName to return the first five characters of the string.
The next step is to create an IStorageEditorInput implementation that returns your IStorage object:
- class StringInput extends PlatformObject
- implements IStorageEditorInput {
- private IStorage storage;
- StringInput(IStorage storage) {this.storage = storage;}
- public boolean exists() {return true;}
- public ImageDescriptor getImageDescriptor() {return null;}
- public String getName() {
- return storage.getName();
- }
- public IPersistableElement getPersistable() {return null;}
- public IStorage getStorage() {
- return storage;
- }
- public String getToolTipText() {
- return "String-based file: " + storage.getName();
- }
- }
Again, many of the methods here are optional. The getPersistable method is used for implementing persistence of your editor input, so the platform can automatically restore your editor on start-up. Here, we've implemented the bare essentials: the editor name, and a tool tip.
The final step is to open an editor with this input. This snippet opens the platform's default text editor on a given string:
- IWorkbenchWindow window = ...;
- String string = "This is the text file contents";
- IStorage storage = new StringStorage(string);
- IStorageEditorInput input = new StringInput(storage);
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
评论
看了文章后,做了个只有这个编辑器的实例,但是运行不起,其它的代码都一样,只是在一个视图中点击tableview的一列表打开编辑器,代码:PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new StringEditorInput("text to be edited"), "org.eclipse.ui.DefaultTextEditor");
但是没有达到效果,确认依赖包都有,不知道使IStorageEditorInput还有什么地方需要注意的,可否给个IStorageEditorInput能运行的简单例子,感激不尽!
jjgoooooole@126.com
发表评论
-
Java程序员25个必备的Eclipse插件
2012-01-12 22:36 21868原文:http://www.fromdev.com/2012/ ... -
关于插件更新安装的错误
2007-12-21 20:12 2174在更新插件的时候出现这样的错误: Unable to comp ... -
最近做eclipse branding, features的一些经验
2007-12-16 01:24 4459知道eclipse的splash怎么做 ... -
GEF学习笔记
2007-12-07 20:20 4112GEF以前学习过, 而且还 ... -
SWT布局深入学习
2007-11-30 23:00 7897以下内容是学习"The Definitive Gui ... -
Eclipse Action 深入学习笔记(3)
2007-11-25 17:59 4036filter元素是用来指定当 ... -
Eclipse Action 深入学习笔记(2)
2007-11-25 17:14 5140Object Action 这种Action是跟弹出的上下文菜 ... -
Eclipse Action 深入学习笔记(1)
2007-11-25 17:07 7614以前做插件用到的ActionSet都只是依葫芦画瓢,没有真正理 ... -
JFace Text Editor完全掌握之终极指南(4)
2007-11-24 17:08 5616错误标识(Error Marking) Error Marki ... -
JFace Text Editor完全掌握之终极指南(3)
2007-11-24 16:56 5450内容大纲 之所以要给编 ... -
JFace Text Editor完全掌握之终极指南(2)
2007-11-24 16:53 6673最后一步就是实现各种功能 语法高亮 首先我们要实现的是语法高亮 ... -
JFace Text Editor完全掌握之终极指南(1)
2007-11-24 16:17 9923JFace Text Editor是JFace里面一个功能强大 ... -
最近的Eclipse plugin开发总结
2007-11-24 11:30 4888List控件没有提供addDblClickListener方法 ... -
eclipse3.3关于JavaFileEditorInput兼容性问题的解决
2007-11-24 11:22 4630在eclipse3.3中,JavaFileEditor ... -
Eclipse WTP Projects Facets实战指南(2)
2007-11-21 21:13 5193修饰工作 给facet在选择列表中添加图标 格式如下: xml ... -
Eclipse WTP Projects Facets实战指南(1)
2007-11-21 20:21 9536这个文章基本是"Building Project F ... -
也说关于WizardPage的动态生成
2007-11-05 14:26 5119在Eclipse中一个Wizard=Wiza ... -
关于多页编辑器中不同Editor之间的Redo&Undo冲突的解决
2007-09-03 15:17 4027在我们的插件工具的开 ... -
TextEditor原理分析笔记
2007-08-23 15:48 3343Editor的语法着色原理:Eclipse使用damage , ... -
最近的Eclipse开发总结
2007-08-23 15:46 2024java.lang.IllegalAccessError: t ...
相关推荐
基于_JFace_Text_Framework_构建全功能代码编辑器
将现有JAR文件直接替换对应的org.eclipse.jface.text_*(后面的是版本号),只能提示增强,能在abcdef....等输入时提示,解决空格和=不能输入的问题(第一次自己编译的插件 嘎嘎)只能提示增强方法自己搜,这个是解决...
最新版Eclipse代码上屏jar包,取消空格、点以及分号的代码自动补全上屏,增加tab键上屏,将jar包复制到eclipse根目录下的plugins文件夹,替换源文件即可。
IBM官方网站的JFace Text Framework教程,教大家如何实现代码提示,字体着色,语法分析等方法。是一个非常好的教程。
swt JFace的API文档,给有需要的人,可能别处也能下载到
因为10.7.1已经完美破解(修正了war文件到处问题),故放上该版本修改过的org.eclipse.jface.text_3.7.2.v20111213-1208.jar 代码补全空格不上屏,适合习惯使用vs等工具的用户 详细描述参见10.0时的插件 ...
将现有JAR文件直接替换对应的org.eclipse.jface.text_*(后面的是版本号),只能提示增强,能在abcdef....等输入时提示,解决空格和=不能输入的问题, 这个版本适用于Eclipse 4.3.2,其他版本的可以参看博客自行修改...
jface.text - Jar [去掉 空格 + 等号的提示] by 970655147
eclipse org.eclipse.jface.text插件,取消等号、空格和分号触发的自动补全
eclipse 取消 "=",空格,“.”的自动补全。org.eclipse.jface.text_3.9.2.v20141003-1326.jar修改版。 使用方法:解压复制到安装目录的同级目录替换即可。安全起见,可以先备份原文件。
这个是针对Eclipse SDK Version: 3.7 jface.text._3.7.2源码。可直接修改该版本的内容。实现自己想要的功能。
eclipse_4.7.3a,eclipse/plugins里面的org.eclipse.jface.text,按“=”和空格以后不会自动补完代码,防止eclipse过于的智能
将压缩包放在eclipse根目录下 解压缩全替换 注意备份 org.eclipse.jface.text_3.12
eclipse代码自动提示有bug,按空格和=号后会在变量名后面自动追加变量类型,将此jar文件替换到plugins文件夹后,可解决这一bug,具体编译教程可以百度
这个是针对Eclipse SDK Version: 4.3. jface.text._3.8.1源码。可直接修改该版本的内容。实现自己想要的功能。
最新版Eclipse代码自动补全,替换Eclipse安装目录下制定jar包,实现只有tab下智能提示代码上屏,回车空格状态下正常!
修改后的org.eclipse.jface.text_3.13.0.v20180527-1819 修改代码提示 tab上代码。 空格和= ; 号 还有我开发时用到数组的 [ 这几个符号时不上屏, 爽的不行
这个是针对Eclipse SDK Version: 4.2.0 jface.text._3.8.0源码。可直接修改该版本的内容。实现自己想要的功能。
org.eclipse.jface.text_3.16.300.v20200526-0811.jar