import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
public class Panel extends Composite {
public Panel(Composite composite, int style) {
super(composite, style);
this.setLayout(new FillLayout());
SashForm sashForm = new SashForm(this, SWT.HORIZONTAL);
sashForm.setLayout(new FillLayout());
final TableViewer tableViewer = new TableViewer(sashForm, SWT.BORDER);
Table table = tableViewer.getTable();
table.setFont(new Font(Display.getDefault(), new FontData("", 11, SWT.NORMAL)));
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableLayout layout = new TableLayout();// 用于表格的布局
table.setLayout(layout);
{
layout.addColumnData(new ColumnWeightData(30));
TableColumn col1 = new TableColumn(table, SWT.CENTER);
col1.setText("ID");
layout.addColumnData(new ColumnWeightData(40));
TableColumn col2 = new TableColumn(table, SWT.CENTER);
col2.setText("状态");
layout.addColumnData(new ColumnWeightData(60));
TableColumn col3 = new TableColumn(table, SWT.CENTER);
col3.setText("任务名称");
layout.addColumnData(new ColumnWeightData(60));
TableColumn col4 = new TableColumn(table, SWT.CENTER);
col4.setText("时间计划");
layout.addColumnData(new ColumnWeightData(60));
TableColumn col5 = new TableColumn(table, SWT.CENTER);
col5.setText("创建者");
layout.addColumnData(new ColumnWeightData(80));
TableColumn col6 = new TableColumn(table, SWT.CENTER);
col6.setText("下次运行时间");
layout.addColumnData(new ColumnWeightData(80));
TableColumn col7 = new TableColumn(table, SWT.CENTER);
col7.setText("上次运行结果");
}
SashForm sashForm1=new SashForm(sashForm,SWT.VERTICAL);
final TableViewer tableViewer1 = new TableViewer(sashForm1, SWT.BORDER);
Table table1 = tableViewer1.getTable();
table1.setFont(new Font(Display.getDefault(), new FontData("", 11, SWT.NORMAL)));
table1.setLinesVisible(true);
table1.setHeaderVisible(true);
TableLayout layout1 = new TableLayout();// 用于表格的布局
table1.setLayout(layout1);
{
layout1.addColumnData(new ColumnWeightData(60));
TableColumn col1 = new TableColumn(table1, SWT.CENTER);
col1.setText("启动时间");
layout1.addColumnData(new ColumnWeightData(60));
TableColumn col2 = new TableColumn(table1, SWT.CENTER);
col2.setText("结束时间");
layout1.addColumnData(new ColumnWeightData(60));
TableColumn col3 = new TableColumn(table1, SWT.CENTER);
col3.setText("执行时间");
layout1.addColumnData(new ColumnWeightData(60));
TableColumn col4 = new TableColumn(table1, SWT.CENTER);
col4.setText("执行结果");
layout1.addColumnData(new ColumnWeightData(60));
TableColumn col5 = new TableColumn(table1, SWT.CENTER);
col5.setText("备注");
}
final TableViewer tableViewer2 = new TableViewer(sashForm1, SWT.BORDER);
Table table2 = tableViewer2.getTable();
table2.setFont(new Font(Display.getDefault(), new FontData("", 11, SWT.NORMAL)));
table2.setLinesVisible(true);
table2.setHeaderVisible(true);
TableLayout layout2 = new TableLayout();// 用于表格的布局
table2.setLayout(layout2);
{
layout2.addColumnData(new ColumnWeightData(60));
TableColumn col1 = new TableColumn(table2, SWT.CENTER);
col1.setText("文件全名");
layout2.addColumnData(new ColumnWeightData(60));
TableColumn col2 = new TableColumn(table2, SWT.CENTER);
col2.setText("最终结果");
layout2.addColumnData(new ColumnWeightData(60));
TableColumn col3 = new TableColumn(table2, SWT.CENTER);
col3.setText("重送次数");
}
sashForm.setWeights(new int[]{2,1});
sashForm1.setWeights(new int[]{1,1});
}
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new Panel(shell, SWT.BORDER);
/*ToolBar toolBar=new ToolBar(shell,SWT.NONE);
ToolItem toolItem1 = new ToolItem(toolBar,SWT.PUSH);
toolItem1.setText("新增任务");
ToolItem toolItem2 = new ToolItem(toolBar,SWT.PUSH);
toolItem2.setText("计划调度");*/
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}