大夢想家

          5年開發(fā)工程師,2年實(shí)施經(jīng)理,X年售前顧問,......
          數(shù)據(jù)加載中……
          一個(gè)使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~



          我用代碼硬生生的把Eclipse-RCP丑陋的Coolbar替換掉了,但是不爽的是,Viewer上使用的是CTabFolder,而這個(gè)CTabFolder的產(chǎn)生,我沒有辦法操控,希望有高手指點(diǎn)。
          修改代碼如下:
           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: 一個(gè)使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~ 2007-10-09 12:03 千里冰封

          不錯(cuò),挺好看的,我還是喜歡swing
            回復(fù)  更多評論    

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

          不錯(cuò),挺好看的,我還是喜歡swing
            回復(fù)  更多評論    

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

          本地化有時(shí)候也不是什么好事!
            回復(fù)  更多評論    

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

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

          好像有人用swing實(shí)現(xiàn)了rcp
            回復(fù)  更多評論    

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

          哎~等著IBM繼續(xù)開源一點(diǎn)吧~
            回復(fù)  更多評論    

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

          估計(jì)得修改eclipse底層了
            回復(fù)  更多評論    

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

          自定義一個(gè)org.eclipse.ui.presentationFactories擴(kuò)展點(diǎn)就行了
            回復(fù)  更多評論    

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

          這和本地化不本地化沒有絲毫關(guān)系!!!
            回復(fù)  更多評論    

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

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

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

          你是不是不想要View的Title?

          用addStandaloneView(id, false)就行了

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

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

          費(fèi)事的是Design,實(shí)現(xiàn)是很簡單。
            回復(fù)  更多評論    

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

          沒見過的東東!
          學(xué)習(xí)啦 呵呵
            回復(fù)  更多評論    
          主站蜘蛛池模板: 永福县| 桦川县| 洮南市| 乌海市| 天峨县| 禄劝| 通辽市| 河西区| 商南县| 凤山县| 荔波县| 佛冈县| 资兴市| 金寨县| 琼结县| 石棉县| 营口市| 沿河| 宝丰县| 林西县| 盈江县| 青冈县| 青河县| 阿拉善左旗| 建瓯市| 伊吾县| 蛟河市| 郓城县| 昌宁县| 右玉县| 曲周县| 静乐县| 五原县| 无极县| 古交市| 和硕县| 丹江口市| 武鸣县| 盈江县| 来凤县| 瑞安市|