我用代码硬生生的把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(400, 300));
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(182, 206, 238));
47 // TODO Auto-generated method stub
48 defaultLayout = new TrimLayout();
49 defaultLayout.setSpacing(2, 2, 2, 2);
50 defaultLayout.setMargins(2, 2);
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(182, 206, 238));
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(182, 206, 238));
86 defaultLayout.setCenterControl(pageComposite);
87
88 }
89
90}
91
客户虐我千百遍,我待客户如初恋!