<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    9910

    單飛

       :: 首頁 :: 聯系 :: 聚合  :: 管理
    MultiPageEditorPart 的addPage方法
    public int addPage(Control control)
        {
            
    int i = getPageCount();
            addPage(i, control);
            
    return i;
        }

        
    public void addPage(int i, IEditorPart ieditorpart, IEditorInput ieditorinput)
            
    throws PartInitException
        {
            IEditorSite ieditorsite 
    = createSite(ieditorpart);
            ieditorpart.init(ieditorsite, ieditorinput);
            Composite composite 
    = new Composite(getContainer(), getOrientation(ieditorpart));
            composite.setLayout(
    new FillLayout());
            ieditorpart.createPartControl(composite);
            ieditorpart.addPropertyListener(
    new IPropertyListener() {

                
    public void propertyChanged(Object obj, int j)
                {
                    handlePropertyChange(j);
                }

            }
    );
            CTabItem ctabitem 
    = createItem(i, composite);
            ctabitem.setData(ieditorpart);
            nestedEditors.add(ieditorpart);
        }

    那么有辦法把一個EditorPart 加入Composite再放到Page里面呢?
    public void addHtmlPage(IEditorPart ieditorpart, IEditorInput ieditorinput) throws PartInitException {
            
    final SashForm sashForm = new SashForm(getContainer(), SWT.NONE);
            
            
    final Composite pageContainer = new Composite(sashForm, SWT.NONE);
            sashForm.setSashWidth(
    1);
            
            
    final Composite resultContainer = new Composite(sashForm, SWT.NONE);
            resultContainer.setLayout(
    new FillLayout());
            
            sashForm.setWeights(
    new int[] {11 });        
            createAnalyzePage(resultContainer);
            
            IEditorSite ieditorsite 
    = createSite(ieditorpart);
            ieditorpart.init(ieditorsite, ieditorinput);

            pageContainer.setLayout(
    new FillLayout());
            ieditorpart.createPartControl(pageContainer);
            ieditorpart.addPropertyListener(
    new IPropertyListener() {

                
    public void propertyChanged(Object obj, int j) {
                    handlePropertyChange(j);
                }

            });
            
            
            
    int index = addPage(sashForm);
            setPageText(index, 
    "html");
        }
    視乎這樣就可以了,但是問題出現了.缺少了父類nestedEditors.add(ieditorpart);對editor生命周期的管理.導致屬性編輯器出問題.怎么解決呢?
        private CTabFolder container;
        
    private ArrayList nestedEditors;

    MultiPageEditorPart 聲明的都是私有的屬性,按照面向對象的設計是不能被繼承者訪問的.
    那怎么辦呢?這時候就該使用錘子了."Reflect"

    CTabFolder container = (CTabFolder) getParentFileValue(MultiPageEditorPart.class,(MultiPageEditorPart)this"container");
            CTabItem ctabitem 
    = new CTabItem(container, 0, i);
            ctabitem.setControl(composite);
            ctabitem.setData(ieditorpart);
            ArrayList nestedEditors 
    = (ArrayList) getParentFileValue(MultiPageEditorPart.class,(MultiPageEditorPart)this"nestedEditors");
            nestedEditors.add(ieditorpart);

    public static Object getParentFileValue(Class parentClassType,Object object, String filedName) {
            Field fild = null;
            Object fildValue = null;
            try {
                fild = parentClassType.getDeclaredField(filedName);
                fild.setAccessible(true);// 設置安全檢查,訪問私有成員變量必須
                fildValue = fild.get(object);

            } catch (NoSuchFieldException ex) {
                ex.printStackTrace();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return fildValue;
        }

    呵呵,問題解決了.

    posted on 2009-05-27 10:31 單飛 閱讀(356) 評論(0)  編輯  收藏 所屬分類: Eclipse Plugin
    主站蜘蛛池模板: 全亚洲最新黄色特级网站| 精品免费人成视频app| 亚洲AV无码一区二区三区在线观看| 亚洲精品福利你懂| 久久久www成人免费毛片| 亚洲AV成人一区二区三区在线看| 国产成人免费高清激情视频| 精品亚洲AV无码一区二区 | 香蕉大伊亚洲人在线观看| 97免费人妻无码视频| 亚洲一级毛片中文字幕| 成人毛片免费观看视频在线| 亚洲精品国产av成拍色拍| 国产免费69成人精品视频| 免费夜色污私人影院网站电影| 久久亚洲2019中文字幕| 亚洲免费人成在线视频观看| 亚洲美女视频一区二区三区| 久久不见久久见中文字幕免费| 亚洲精品无码专区| 亚洲色偷偷综合亚洲AV伊人| 好紧我太爽了视频免费国产 | 亚洲视频在线观看2018| 黄网址在线永久免费观看 | 亚洲国产理论片在线播放| 国产高清视频在线免费观看| 一级日本高清视频免费观看| 久热综合在线亚洲精品| 免费无码A片一区二三区| 黄色网址在线免费观看| 亚洲福利视频导航| 午夜毛片不卡免费观看视频| xxxx日本在线播放免费不卡| 亚洲国产精品国自产电影| 好男人视频在线观看免费看片| 特级做a爰片毛片免费看| 久久亚洲日韩精品一区二区三区| 日本一道综合久久aⅴ免费| 国产精品极品美女自在线观看免费 | 男女啪啪永久免费观看网站| 大地影院MV在线观看视频免费|