【JfaceTextFramework学习笔记之三】大纲视图
来源:互联网 发布:淘宝 0.0.0.1 编辑:程序博客网 时间:2024/06/02 12:23
1-通用的 TextEditor 由于不知道要编辑的文本结构,所以不能提供大纲视图
2-
public Object getAdapter(Class required) {if (IContentOutlinePage.class.equals(required)) {if (fOutlinePage == null) {fOutlinePage= new JavaContentOutlinePage(getDocumentProvider(), this);if (getEditorInput() != null)fOutlinePage.setInput(getEditorInput());}return fOutlinePage;}return super.getAdapter(required);}
3-A content outliner page must implement IContentOutlinePage.
This interface combines the ability to notify selection change
listeners (ISelectionProvider) with the behavior of being a page
in a view (IPage). 通常在该视图中使用JFace的 TreeViewer来显示文本结构
4- 编辑器的EditInput也要传入大概视图中的Viewer
public void createControl(Composite parent) {super.createControl(parent);TreeViewer viewer= getTreeViewer();viewer.setContentProvider(new ContentProvider());viewer.setLabelProvider(new LabelProvider());viewer.addSelectionChangedListener(this);if (fInput != null)viewer.setInput(fInput);}The tree viewer creation is inherited from ContentOutlinePage.
The standard label provider is used.
The content provider is provided inside JavaContentOutlinePage
and is responsible for parsing the editor input into individual
segments whenever it changes.
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {...if (newInput != null) {IDocument document= fDocumentProvider.getDocument(newInput);if (document != null) {document.addPositionCategory(SEGMENTS);document.addPositionUpdater(fPositionUpdater);parse(document);}}}5-When the selection changes, the selected segment is retrieved.
Its offsets are used to set the highlight range in the editor.
public void selectionChanged(SelectionChangedEvent event) {super.selectionChanged(event);ISelection selection= event.getSelection();if (selection.isEmpty())fTextEditor.resetHighlightRange();else {Segment segment= (Segment) ((IStructuredSelection) selection).getFirstElement();int start= segment.position.getOffset();int length= segment.position.getLength();try {fTextEditor.setHighlightRange(start, length, true);} catch (IllegalArgumentException x) {fTextEditor.resetHighlightRange();}}}
- 【JfaceTextFramework学习笔记之三】大纲视图
- 【JfaceTextFramework学习笔记之二】内容提示
- 【JfaceTextFramework学习笔记之五】积累
- 【JfaceTextFramework学习笔记之四】TextViewer实现原理简单分析
- 【JfaceTextFramework学习笔记之一】语法高亮
- 【JfaceTextFramework学习笔记之六】Jface提供的Rule基类总结
- Python学习笔记--大纲
- JavaScript学习笔记大纲
- Kotlin学习笔记-大纲
- 黑马程序员之HTML学习笔记:HTML学习大纲
- RHCA之学习大纲
- java学习笔记(2)基本概念之面向对象大纲
- Thinkphp5 学习笔记之视图
- [maya学习笔记(7)] 物体的显示与隐藏 大纲视图的使用
- (13)关卡编辑器之大纲视图
- Android学习大纲三 Android emulator 优化
- oralce学习笔记之视图篇
- oracle9i学习笔记之十 创建视图
- delphi 线程学习 转发与 KeyLife富翁笔记
- POSIX.1 and ISO C标准头文件
- SPLIT应用
- html做闪光字
- 安装SQL Server 2005之后找不到SQL Server Management Studio Express
- 【JfaceTextFramework学习笔记之三】大纲视图
- C++的static关键字
- java-Vector类在Java编程中的应用
- 查询数据库中的表名
- C++实现的lambda Y算子
- AssemblyBuilder..::.GetManifestResourceStream (08_10_09)
- 七个受用一生的心理寓言
- JSON的使用
- 学习PetShop3.0(5)生成定单