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.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import com.huawei.enip.esdt.common.ui.esdt.forms.EsdtFormSection;
import com.huawei.enip.esdt.esb.ui.editor.pages.ESBTransportConfigPage;
public class TransportConfigSection extends EsdtFormSection
{
private Table table = null;//表格对象
private ESBTransportConfigPage page = null;//ESBOverViewPage页
private Label pageInfoLab;//页信息标签
private Label protocolLab;
private Label LoadLab;
private Label urlLab;//url标签
private Label formatLab;
private Label retryLab;
private Label iterationLab;
private Label applicationLab;
private Text httpTxt;
private Text numTxt;
private Text nubTxt;
private Combo protocolCombo;
private Combo roundCombo;
private Button yesBut;
private Button noBut;
private Button buttonUp;
private Button buttonAdd;
private Button buttonDown;
private Button buttonDel;
/**
* 构造函数
* @param parent
* @param toolkit
* @param style
*/
public TransportConfigSection(Composite parent, FormToolkit toolkit,
int style)
{
super(parent, toolkit, style);
}
/* (此注释不是Javadoc注释)
* @see
com.huawei.enip.esdt.common.ui.forms.FormSection#createClientArea
(org.eclipse.swt.widgets.Composite,
org.eclipse.ui.forms.widgets.FormToolkit)
*/
@Override
public void createClientArea(Composite parent, FormToolkit
formToolkit)
{
//设置Section标签
getSection().setText("Transport Configuration");
getSection().setLayoutData(new GridLayout());
getSection().setLayoutData(new GridData(
GridData.HORIZONTAL_ALIGN_BEGINNING
| GridData.VERTICAL_ALIGN_FILL
| GridData.FILL_HORIZONTAL));
//设置分割线
formToolkit.createCompositeSeparator(getSection());
//创建页面显示
createDescriptionArea(parent);
}
/**
* 页面显示的方法
* @param parent
*/
private void createDescriptionArea(Composite parent)
{
parent.setLayout(new FillLayout());
//设置全局网格布局方式
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3; //设置网格的列数为4
gridLayout.horizontalSpacing = 50;
parent.setLayout(gridLayout);
pageInfoLab = new Label(parent, SWT.NONE);//定义标签对象
pageInfoLab.setText("Use this page to configure the transport
information for this service.");
GridData gridData = new GridData(SWT.BEGINNING, SWT.CENTER,
false,
false, 3, 1);
pageInfoLab.setLayoutData(gridData);
//第一个标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Protocol");
//下拉列表框
protocolCombo = new Combo(parent, SWT.READ_ONLY);
protocolCombo.add("http");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
2, 1);
gridData.widthHint = 120;
protocolCombo.setLayoutData(gridData);
//第二个标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Load Balancing\nALgorithm");
//下拉列表框
protocolCombo = new Combo(parent, SWT.READ_ONLY);
protocolCombo.add("round-robin");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
2, 1);
gridData.widthHint = 120;
protocolCombo.setLayoutData(gridData);
//URL标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Endpoint URI");
gridData = new GridData(SWT.BEGINNING, SWT.TOP, false, false, 1,
5);
protocolLab.setLayoutData(gridData);
//FORMAT标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Format:http://host:post/soneService");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
2, 1);
gridData.widthHint = 300;
protocolLab.setLayoutData(gridData);
Text text = new Text(parent, SWT.BORDER);
text.setText("http://www.iteye.com");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
1, 1);
gridData.widthHint = 300;
text.setLayoutData(gridData);
Button button = new Button(parent, SWT.PUSH);
button.setText("Add");
gridData = new GridData();
gridData.widthHint = 50;
button.setLayoutData(gridData);
//创建表格样式
table = new Table(parent, 2565);
table.setLinesVisible(true); //设置显示表格线
table.setHeaderVisible(true); //设置显示表头
//设置表头数组
final String[] table_column = {"Existing URIs", ""};
//用于设置列宽的布局管理器
TableLayout tLayout = new TableLayout();
//创建表头
for (int i = 0; i < table_column.length; ++i)
{
TableColumn tableColumn = new TableColumn(table, 0);
tableColumn.setText(table_column[i]);
tableColumn.setWidth(200);
//将列宽设置为50px
tLayout.addColumnData(new ColumnWeightData(100));
}
//创建TableViewer
TableViewer tableViewer = new TableViewer(table);
tableViewer.getTable().setLayout(tLayout);
//将表头填充,并显示
for (int i = 0; i < tableViewer.getTable().getColumnCount(); ++i)
{
tableViewer.getTable().getColumn(i).pack();
}
//设置表格样式
gridData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 3);
table.setLayoutData(gridData);
Button button1 = new Button(parent, SWT.PUSH);
button1.setText("Up");
gridData = new GridData();
gridData.widthHint = 50;
button1.setLayoutData(gridData);
Button button2 = new Button(parent, SWT.PUSH);
button2.setText("Down");
gridData = new GridData();
gridData.widthHint = 50;
button2.setLayoutData(gridData);
Button button3 = new Button(parent, SWT.PUSH);
button3.setText("Delete");
gridData = new GridData();
gridData.widthHint = 50;
button3.setLayoutData(gridData);
//Count标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Retry Count");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
1, 1);
protocolLab.setLayoutData(gridData);
//Count文本框
Text text2 = new Text(parent, SWT.BORDER);
text2.setText("0");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
2, 1);
gridData.widthHint = 135;
text2.setLayoutData(gridData);
//Count标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Retry Iteration\nInterval");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
1, 1);
protocolLab.setLayoutData(gridData);
//Count文本框
Text text3 = new Text(parent, SWT.BORDER);
text3.setText("30");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
2, 1);
gridData.widthHint = 135;
text3.setLayoutData(gridData);
//Count标签
protocolLab = new Label(parent, SWT.NONE);
protocolLab.setText("Retry Application\nErrors");
gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false,
1, 2);
protocolLab.setLayoutData(gridData);
Button button4 = new Button(parent, SWT.RADIO);
button4.setText("男");
gridData = new GridData(SWT.BEGINNING, SWT.TOP, false, false, 2,
1);
button4.setLayoutData(gridData);
Button button5 = new Button(parent, SWT.RADIO);
button5.setText("女");
gridData = new GridData(SWT.BEGINNING, SWT.TOP, false, false, 2,
1);
button5.setLayoutData(gridData);
}
}