一個使用SWT Ribbon代替Eclipse-RCP上面Coolbar的例子~

我用代碼硬生生的把Eclipse-RCP丑陋的Coolbar替換掉了,但是不爽的是,Viewer上使用的是CTabFolder,而這個CTabFolder的產生,我沒有辦法操控,希望有高手指點。
修改代碼如下:
1
package test;
2
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.graphics.Point;
5
import org.eclipse.swt.layout.FillLayout;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.Shell;
8
import org.eclipse.ui.application.ActionBarAdvisor;
9
import org.eclipse.ui.application.IActionBarConfigurer;
10
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
11
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
12
import org.eclipse.ui.internal.WindowTrimProxy;
13
import org.eclipse.ui.internal.WorkbenchMessages;
14
import org.eclipse.ui.internal.WorkbenchWindowConfigurer;
15
import org.eclipse.ui.internal.layout.TrimLayout;
16
17
import com.hexapixel.widgets.generic.ColorCache;
18
import com.hexapixel.widgets.ribbon.RibbonTab;
19
import com.hexapixel.widgets.ribbon.RibbonTabFolder;
20
21
public 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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

客戶虐我千百遍,我待客戶如初戀!
posted on 2007-10-09 11:52 阿南 閱讀(3823) 評論(11) 編輯 收藏 所屬分類: Eclipse-RCP