下面列出了怎么用org.eclipse.swt.widgets.CoolBar的API类实例代码及写法,或者点击链接到github查看源代码。
public void createToolBar() {
bar = new CoolBar(shell, SWT.FLAT | SWT.TOP);
// bars
bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
createFileSection();
createEditBar();
createFontSection();
createSettingsBar();
bar.pack();
bar.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(Event arg0) {
pmTrans.adjustLayout();
}
});
}
public void createToolBar() {
Composite compCoolBar = new Composite(shell, SWT.BORDER);
compCoolBar.setLayout(new FillLayout());
CoolBar coolBarSort = new CoolBar(compCoolBar, SWT.NONE);
CoolItem coolItemSort = new CoolItem(coolBarSort, SWT.NONE);
Combo prjCombo = new Combo(coolBarSort, SWT.READ_ONLY);
prjCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
prjCombo.setItems(new String[] { "显示所有用例", "只显示成功的用例", "只显示失败的用例" });
prjCombo.select(0);
Point p = prjCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT);
prjCombo.setSize(p);
Point p2 = coolItemSort.computeSize(p.x, p.y);
coolItemSort.setSize(p2);
coolItemSort.setControl(prjCombo);
coolBarSort.pack();
}
/**
*
*/
protected void createToolBar() {
CoolBar bar = new CoolBar(shell, SWT.FLAT);
bar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
bar.setLayout(new RowLayout());
CoolItem item = new CoolItem(bar, SWT.NONE);
Button button = new Button(bar, SWT.FLAT);
// button.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
button.setText("Button");
Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
item.setPreferredSize(item.computeSize(size.x, size.y));
item.setControl(button);
Rectangle clientArea = shell.getClientArea();
bar.setLocation(clientArea.x, clientArea.y);
bar.pack();
}
private void createStatusBar() {
coolBar1 = new CoolBar(shell, SWT.NONE);
FormData formData1 = new FormData();
formData1.left = new FormAttachment(0, 0);
formData1.right = new FormAttachment(100, 0);
formData1.top = new FormAttachment(100, -24);
formData1.bottom = new FormAttachment(100, 0);
coolBar1.setLayoutData(formData1);
CoolItem coolItem1 = new CoolItem(coolBar1, SWT.NONE);
toolBar1 = new ToolBar(coolBar1, SWT.NONE);
ToolItem tiStatusBarTotal = new ToolItem(toolBar1, SWT.NONE);
ToolItem tiStatusBarPass = new ToolItem(toolBar1, SWT.NONE);
ToolItem tiStatusBarFail = new ToolItem(toolBar1, SWT.NONE);
ToolItem tiStatusBarRate = new ToolItem(toolBar1, SWT.NONE);
tiStatusBarPass.setText("通过:0");
tiStatusBarFail.setText("失败:0");
tiStatusBarRate.setText("通过率:0%");
tiStatusBarTotal.setText("总用例数:0");
coolItem1.setControl(toolBar1);
Control control = coolItem1.getControl();
Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
pt = coolItem1.computeSize(pt.x, pt.y);
coolItem1.setSize(pt);
coolBar1.pack();
}
@Override
public void fill(CoolBar parent, int index) {
throw new UnsupportedOperationException();
}
@Override
public void fill(CoolBar parent, int index) {
throw new UnsupportedOperationException();
}
public CoolBar getCoolBar() {
return this.coolBar;
}
@Override
public void fill(CoolBar parent, int index) {
}