程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> 【Eclipse插件開發】基於WTP開發自定義的JSP編輯器(四)

【Eclipse插件開發】基於WTP開發自定義的JSP編輯器(四)

編輯:關於JSP

Strucutured Document分析視圖

在上一篇中,我們詳細闡述了WTP中最重要的數據模型之一IStructuredDocument(我們就稱之為WTP Document吧,和另外一個核心數據模型WTP Model----IStructuredModel對應),本節中我們將自己開發 一個工具來分析IStrucutredDocument。

PS:千萬別著急,後面的文章會對WTP StructuredTextEditor進行功能特征定制的,在真正定制之前 一定要搞清楚WTP Document(IStructuredDocument)和WTP Model(IStructuredModel),連核心數據 模型都不熟悉,後面談何定制^_^

【WTP提供的Properteis視圖擴展】

說明:Properteis視圖是Eclipse固有的,允許用戶通過相應的類型擴展機制來定制Properties視圖 中的內容,涉及到的主要知識點包括:

1、Eclipse的Adapter機制(IAdaptable、IAdapterFactory、AdapterManager),關於Eclipse中的 類型適配擴展機制,博客中的另外一篇文章做了分析:

【Eclipse插件開發】Eclipse中類型擴展機制分析

2、Properties視圖相關的幾個重要接口:

org.eclipse.ui.views.properties.IPropertySource.class

org.eclipse.ui.views.properties.PropertySheetPage

...

3、WTP就是借助於Eclipse類型擴展機制,實現了對應的功能。我們看一下在WTP的 StructuredTextEditor中的getAdapter方法中提供了擴展服務(IWorkbenchPart本身就是聲明為 IAdaptable):

1 /*
2 * (non-Javadoc)
3 *
4 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
5 */
6 public Object getAdapter(Class required) {
7 //
8 else if (IPropertySheetPage.class.equals(required) && isEditable()) {
9 if (fPropertySheetPage == null || fPropertySheetPage.getControl() == null || fPropertySheetPage.getControl().isDisposed()) {
10 PropertySheetConfiguration cfg = createPropertySheetConfiguration();
11 if (cfg != null) {
12 ConfigurablePropertySheetPage propertySheetPage = new ConfigurablePropertySheetPage();
13 propertySheetPage.setConfiguration(cfg);
14 fPropertySheetPage = propertySheetPage;
15 }
16 }
17 result = fPropertySheetPage;
18 }
19 //.
20 }

ConfigurablePropertySheetPage^_^ (org.eclipse.wst.sse.ui.internal.properties.ConfigurablePropertySheetPage)。

WTP的properties視圖的主要功能就是,根據用戶在編輯器中光標的位置,在Properties視圖中展示 對應的標簽內容,並支持用戶編輯,例如:

當前編輯器中,用戶光標位於jsp:directive.page標簽內,屬性視圖就列舉了對應的標簽內容,允許 用戶編輯。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved