<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 單飛 閱讀(363) 評論(0)  編輯  收藏 所屬分類: Eclipse Plugin
    主站蜘蛛池模板: 美女被免费视频网站| 99视频在线免费观看| 日韩亚洲精品福利| www在线观看免费视频| 亚洲国产日韩一区高清在线| 四虎永久在线精品免费观看视频| 国产99久久亚洲综合精品| 亚洲日产无码中文字幕| av大片在线无码免费| 无码免费又爽又高潮喷水的视频| 亚洲AV色香蕉一区二区| 美女被免费视频网站a国产| A级毛片成人网站免费看| 91亚洲精品自在在线观看| 一区二区三区亚洲视频| 永久免费视频网站在线观看| 男男gay做爽爽的视频免费| 亚洲午夜久久影院| 又粗又大又硬又爽的免费视频| 久久国产精品免费专区| 亚洲AV色无码乱码在线观看| 亚洲成a人片在线看| 亚洲AV无码不卡在线观看下载| 无码中文字幕av免费放dvd| 亚洲AV永久无码精品一福利| 亚洲va无码专区国产乱码| 国产精品免费视频网站| 91香蕉在线观看免费高清| 一级做a毛片免费视频| 亚洲一线产品二线产品| 亚洲AV无码成人精品区在线观看| 国产成人高清精品免费软件| 18禁止看的免费污网站| 99精品免费视频| 国产亚洲综合视频| 国产精品亚洲精品| 亚洲国产精品久久久久婷婷软件| 亚洲熟女乱综合一区二区| 在线观看永久免费视频网站| 国产成人福利免费视频| 国产一区二区免费视频|