大夢想家

          5年開發工程師,2年實施經理,X年售前顧問,......
          數據加載中……
          一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~



          我用代碼硬生生的把Eclipse-RCP丑陋的Coolbar替換掉了,但是不爽的是,Viewer上使用的是CTabFolder,而這個CTabFolder的產生,我沒有辦法操控,希望有高手指點。
          修改代碼如下:
           1package test;
           2
           3import org.eclipse.swt.SWT;
           4import org.eclipse.swt.graphics.Point;
           5import org.eclipse.swt.layout.FillLayout;
           6import org.eclipse.swt.widgets.Composite;
           7import org.eclipse.swt.widgets.Shell;
           8import org.eclipse.ui.application.ActionBarAdvisor;
           9import org.eclipse.ui.application.IActionBarConfigurer;
          10import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
          11import org.eclipse.ui.application.WorkbenchWindowAdvisor;
          12import org.eclipse.ui.internal.WindowTrimProxy;
          13import org.eclipse.ui.internal.WorkbenchMessages;
          14import org.eclipse.ui.internal.WorkbenchWindowConfigurer;
          15import org.eclipse.ui.internal.layout.TrimLayout;
          16
          17import com.hexapixel.widgets.generic.ColorCache;
          18import com.hexapixel.widgets.ribbon.RibbonTab;
          19import com.hexapixel.widgets.ribbon.RibbonTabFolder;
          20
          21public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
          22
          23    private TrimLayout defaultLayout;
          24    private Composite topComposite;
          25    private WindowTrimProxy topCompositeTrim;
          26    private Composite pageComposite;
          27    
          28    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
          29        super(configurer);
          30    }

          31
          32    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
          33        return new ApplicationActionBarAdvisor(configurer);
          34    }

          35    
          36    public void preWindowOpen() {
          37        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
          38        configurer.setInitialSize(new Point(400300));
          39        configurer.setShowCoolBar(false);
          40        configurer.setShowStatusLine(false);
          41        configurer.setTitle("Hello RCP");
          42    }

          43
          44    @Override
          45    public void createWindowContents(Shell shell) {
          46        shell.setBackground(ColorCache.getInstance().getColor(182206238));
          47        // TODO Auto-generated method stub
          48        defaultLayout = new TrimLayout();
          49        defaultLayout.setSpacing(2222);
          50        defaultLayout.setMargins(22);
          51        shell.setLayout(defaultLayout);
          52        
          53        //topComposite
          54        topComposite = new Composite(shell, SWT.None);
          55        topComposite.setLayout(new FillLayout(SWT.VERTICAL)); 
          56        topComposite.setBackground(ColorCache.getInstance().getColor(182206238));
          57        
          58            final RibbonTabFolder ftf = new RibbonTabFolder(topComposite, SWT.NONE);
          59            RibbonTab ft0 = new RibbonTab(ftf, "Home");
          60            RibbonTab ft1 = new RibbonTab(ftf, "Insert");
          61            new RibbonTab(ftf, "Page Layout");
          62            new RibbonTab(ftf, "References");
          63        
          64        topCompositeTrim = new WindowTrimProxy(topComposite,"org.eclipse.ui.internal.WorkbenchWindow.topBar", WorkbenchMessages.TrimCommon_Main_TrimName, SWT.NONE, true);
          65        
          66        
          67        
          68        
          69        pageComposite = (Composite) ((WorkbenchWindowConfigurer) getWindowConfigurer()).createPageComposite(shell);
          70        setLayoutDataForContents();
          71    }

          72
          73    private void setLayoutDataForContents() {
          74        updateLayoutDataForContents();
          75        
          76    }

          77
          78    private void updateLayoutDataForContents() {
          79        if (defaultLayout == null{
          80            return;
          81        }

          82        defaultLayout.addTrim(SWT.TOP, topCompositeTrim);
          83        topComposite.setVisible(true);
          84        
          85        pageComposite.setBackground(ColorCache.getInstance().getColor(182206238));
          86        defaultLayout.setCenterControl(pageComposite);
          87        
          88    }

          89    
          90}

          91



          客戶虐我千百遍,我待客戶如初戀!

          posted on 2007-10-09 11:52 阿南 閱讀(3823) 評論(11)  編輯  收藏 所屬分類: Eclipse-RCP

          評論

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 12:03 千里冰封

          不錯,挺好看的,我還是喜歡swing
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 12:03 千里冰封

          不錯,挺好看的,我還是喜歡swing
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 12:11 阿南

          本地化有時候也不是什么好事!
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 13:05 交口稱贊

          樓主這么用累不?
          不如直接用swing得了

          好像有人用swing實現了rcp
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 13:14 阿南

          哎~等著IBM繼續開源一點吧~
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~[未登錄] 2007-10-09 14:23 test

          估計得修改eclipse底層了
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 16:51 Pande

          自定義一個org.eclipse.ui.presentationFactories擴展點就行了
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 17:29 Pande

          這和本地化不本地化沒有絲毫關系!!!
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 17:33 阿南

          謝謝提醒~
          請問,上面的那塊灰色的區域怎么修改阿?
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 18:33 Pande

          你是不是不想要View的Title?

          用addStandaloneView(id, false)就行了

          如果用org.eclipse.ui.presentationFactories,你可以完全控制圍繞View或者Editor的Trimming的,寫一個StackPresentation的子類。eclipse.org的cvs里有例子的。好像是Project org.eclipse.ui.examples.presetation. 有興趣可以看看。

          其實Eclipse RCP是非常靈活的,Rich Client Platform這本書的第18和19章講得很詳細,你可以參考。只要你愿意,可以很方便的定制RCP程序的每一處細節。

          費事的是Design,實現是很簡單。
            回復  更多評論    

          # re: 一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-16 13:12 翔南

          沒見過的東東!
          學習啦 呵呵
            回復  更多評論    
          主站蜘蛛池模板: 绥宁县| 正阳县| 伊春市| 奇台县| 嘉峪关市| 桂林市| 敦化市| 肇东市| 浮山县| 稻城县| 上犹县| 淮安市| 蓝山县| 镇雄县| 永兴县| 吴忠市| 杭州市| 安远县| 辽阳县| 万全县| 黄骅市| 托里县| 八宿县| 万盛区| 炉霍县| 石台县| 霸州市| 宣汉县| 宁乡县| 京山县| 长沙市| 大埔区| 荔浦县| 平顺县| 彭州市| 丰县| 崇信县| 湛江市| 烟台市| 读书| 茌平县|