xiaoxiaoleemin

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

          如何顯示Outline視圖

          Posted on 2007-05-06 18:03 xiaoxiaoleemin 閱讀(777) 評論(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設置一些屬性值。


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


          網站導航:
           
          主站蜘蛛池模板: 拉萨市| 龙口市| 绥宁县| 桐庐县| 桂平市| 松潘县| 永定县| 类乌齐县| 鹤岗市| 沁阳市| 璧山县| 巴楚县| 涞源县| 砀山县| 邹城市| 赫章县| 隆林| 宕昌县| 南郑县| 通渭县| 驻马店市| 岱山县| 阿巴嘎旗| 青河县| 延川县| 容城县| 武胜县| 滕州市| 扶余县| 汉阴县| 冷水江市| 双鸭山市| 和政县| 巴彦淖尔市| 叶城县| 通化市| 汝南县| 吉隆县| 葵青区| 达拉特旗| 宝山区|