xiaoxiaoleemin

          天道酬勤,小小加油
          posts - 19, comments - 12, trackbacks - 0, articles - 0

          如何顯示Outline視圖

          Posted on 2007-05-06 18:03 xiaoxiaoleemin 閱讀(779) 評論(0)  編輯  收藏
              上個帖子介紹了如何顯示PropertySheet視圖,這里繼續介紹如何顯示Outline視圖,還是只關心與顯示大綱視圖相關的代碼:
          public class MySchoolEditor extends EditorPart implements ISelectionListener {
              ...
              protected IContentOutlinePage contentOutlinePage;

              public void init(IEditorSite site, IEditorInput input) throws PartInitException {
                  ...
                 contentOutlinePage = getContentOutlinePage();
              }
             
              public ContentOutlinePage getContentOutlinePage() {
                  if (contentOutlinePage == null) {
                      contentOutlinePage = new MyContentOutlinePage();
                  }
                  return (ContentOutlinePage) contentOutlinePage;
             
              public Object getAdapter(Class key) {
                  if (key.equals(IContentOutlinePage.class))
                      return getContentOutlinePage();
                  else
                      return super.getAdapter(key);
              }

              class MyContentOutlinePage extends ContentOutlinePage {
                  TreeViewer contentOutlineViewer;

                  public void createControl(Composite parent) {
                      super.createControl(parent);
                      contentOutlineViewer = getTreeViewer();
                     
                      // Set up the tree viewer.
                      contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
                      contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
                      contentOutlineViewer.setInput(school);
                  }
              }
          }
              ContentOutlinePage類是一個抽象類,不能直接創建對象,所以我們要繼承它實現自己的大綱頁,主要任務是為它的treeViewer設置一些屬性值。


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 益阳市| 汝南县| 双桥区| 漳平市| 灵石县| 临武县| 曲沃县| 平舆县| 佛教| 南宫市| 紫阳县| 新干县| 湖南省| 涡阳县| 上饶市| 太白县| 长武县| 马公市| 金阳县| 和平县| 长春市| 黔南| 铜梁县| 界首市| 泊头市| 年辖:市辖区| 鄂尔多斯市| 中阳县| 罗山县| 集安市| 保康县| 桑日县| 翼城县| 台州市| 绥江县| 旬邑县| 富民县| 平安县| 成安县| 庄河市| 修水县|