大梦想家

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 阿南 阅读(3774) 评论(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 翔南

没见过的东东!
学习啦 呵呵
  回复  更多评论    

只有注册用户登录后才能发表评论。


网站导航: