use of org.eclipse.swt.layout.FormAttachment in project GT by Tencent.
the class APTStubAnalysisCTabItem method createAPTStubAnalysisCTablItemUI.
/**
* 初始化页面中的所有UI
* @param parent
*/
private void createAPTStubAnalysisCTablItemUI(Composite parent) {
int margin = 5;
/**
* 三种展示视图的CTabFolder
*/
FormData showViewTabFolderFD = new FormData();
showViewTabFolderFD.left = new FormAttachment(0, margin);
showViewTabFolderFD.top = new FormAttachment(0, 25);
showViewTabFolderFD.right = new FormAttachment(100, -margin);
showViewTabFolderFD.bottom = new FormAttachment(100, -margin);
showViewTF = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
showViewTF.setTabHeight(20);
showViewTF.setLayoutData(showViewTabFolderFD);
showViewTF.marginHeight = 10;
showViewTF.marginWidth = 10;
showViewTF.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
showViewTF.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
showViewTF.setUnselectedCloseVisible(true);
showViewTF.pack();
/**
* 详细视图按钮初始化
*/
FormData detailBtnFD = new FormData();
detailBtnFD.left = new FormAttachment(0, margin);
detailBtnFD.top = new FormAttachment(0, margin);
detailBtnFD.height = 16;
detailBtnFD.width = 16;
detailBtn = new Button(parent, SWT.NONE);
detailBtn.setToolTipText(StubAnalysisUtil.DETAIL_TAB_NAME);
detailBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/detail.png").createImage());
detailBtn.setLayoutData(detailBtnFD);
detailBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
detailTabItem = createDetailCTabItem(showViewTF);
detailTabItem.updateData(detailData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
detailTabItem = createDetailCTabItem(showViewTF);
detailTabItem.updateData(detailData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 统计视图按钮初始化
*/
FormData topBtnFD = new FormData();
topBtnFD.left = new FormAttachment(detailBtn, margin);
topBtnFD.top = new FormAttachment(0, margin);
topBtnFD.height = 16;
topBtnFD.width = 16;
topBtn = new Button(parent, SWT.NONE);
topBtn.setToolTipText(StubAnalysisUtil.TOP_TAB_NAME);
topBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/stat.png").createImage());
topBtn.setLayoutData(topBtnFD);
topBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
topTabItem = createTopCTabItem(showViewTF);
topTabItem.updateData(topData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
topTabItem = createTopCTabItem(showViewTF);
topTabItem.updateData(topData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 树形视图按钮初始化
*/
FormData treeBtnFD = new FormData();
treeBtnFD.left = new FormAttachment(topBtn, margin);
treeBtnFD.top = new FormAttachment(0, margin);
treeBtnFD.height = 16;
treeBtnFD.width = 16;
treeBtn = new Button(parent, SWT.NONE);
treeBtn.setToolTipText(StubAnalysisUtil.TREE_TAB_NAME);
treeBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/tree.png").createImage());
treeBtn.setLayoutData(treeBtnFD);
treeBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
treeTabItem = createTreeCTabItem(showViewTF);
treeTabItem.updateData(treeData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
treeTabItem = createTreeCTabItem(showViewTF);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 打开三个视图
*/
detailTabItem = createDetailCTabItem(showViewTF);
topTabItem = createTopCTabItem(showViewTF);
treeTabItem = createTreeCTabItem(showViewTF);
}
use of org.eclipse.swt.layout.FormAttachment in project GT by Tencent.
the class CPUView method createChartPanel.
/**
* 初始化jfreechart
* @param rootFrame
*/
private void createChartPanel(Composite parent) {
// 放置图表的容器对象
chartComposite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
FormData formData = new FormData();
formData.left = new FormAttachment(0, Constant.VIEW_MARGIN_WIDTH);
formData.right = new FormAttachment(cpuViewer.getTable(), -Constant.VIEW_MARGIN_WIDTH);
formData.top = new FormAttachment(0, Constant.VIEW_MARGIN_WIDTH);
formData.bottom = new FormAttachment(100, -Constant.VIEW_MARGIN_WIDTH);
chartComposite.setLayoutData(formData);
// AWT的根容器
Frame frame = SWT_AWT.new_Frame(chartComposite);
// 据说加入这个Panel可以无闪烁
Panel panel = new Panel(new BorderLayout()) {
private static final long serialVersionUID = 1L;
public void update(java.awt.Graphics g) {
/* Do not erase the background */
paint(g);
}
};
frame.add(panel);
JRootPane root = new JRootPane();
panel.add(root);
java.awt.Container contentPane = root.getContentPane();
cpuRealTimeChart = new CPURealTimeChart();
contentPane.add(cpuRealTimeChart);
}
use of org.eclipse.swt.layout.FormAttachment in project GT by Tencent.
the class DevicesView method createSubTitle.
/**
*
* @param parent
*/
private void createSubTitle(Composite parent) {
FormData pkgNameLabelFromData = new FormData();
pkgNameLabelFromData.top = new FormAttachment(0, 5);
pkgNameLabelFromData.left = new FormAttachment(0, 5);
pkgNameLabelFromData.right = new FormAttachment(100, -50);
// 绝对位置
pkgNameLabelFromData.bottom = new FormAttachment(parent, 30);
pkgNameText = new Text(parent, SWT.BORDER);
pkgNameText.setToolTipText("在这里可以手动输入要进行测试的进程名");
pkgNameText.setBackground(new Color(Display.getCurrent(), 192, 192, 192));
pkgNameText.setLayoutData(pkgNameLabelFromData);
FormData addBtnFromData = new FormData();
addBtnFromData.top = new FormAttachment(0, 5);
addBtnFromData.left = new FormAttachment(pkgNameText, 5);
addBtnFromData.right = new FormAttachment(100, -5);
// 绝对位置
addBtnFromData.bottom = new FormAttachment(parent, 30);
addBtn = new Button(parent, SWT.NONE);
addBtn.setText("添加");
addBtn.setLayoutData(addBtnFromData);
addBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
if (isSupportAddOrDeleteOper) {
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
String text = pkgNameText.getText().trim();
if (text.equals("")) {
APTConsoleFactory.getInstance().APTPrint("请输入合法的包名");
return;
}
PkgInfo dataItem = new PkgInfo();
dataItem.contents[PkgInfo.NAME_INDEX] = text;
dataItem.contents[PkgInfo.PID_INDEX] = Constant.PID_NOT_EXSIT;
addDataItem(targetPkgTableViewer, dataItem);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
use of org.eclipse.swt.layout.FormAttachment in project GT by Tencent.
the class DevicesView method createTargetPkgTableView.
/**
* 创建被测进程列表
* @Title: createTargetPkgTableView
* @Description:
* @param parent
* void
* @throws
*/
private void createTargetPkgTableView(Composite parent) {
targetPkgTableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
ctv = new CheckboxTableViewer(targetPkgTableViewer.getTable());
ctv.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (isSupportCheckChangePer) {
GetCurCheckedStateUtil.update();
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
});
// 设置表头内容
for (int i = 0; i < TARGET_COLUMN_NAME.length; i++) {
new TableColumn(targetPkgTableViewer.getTable(), SWT.LEFT).setText(TARGET_COLUMN_NAME[i]);
}
targetPkgTableViewer.getTable().getColumn(0).setWidth(200);
targetPkgTableViewer.getTable().getColumn(1).setWidth(50);
// 设置表头和表格线可见
targetPkgTableViewer.getTable().setHeaderVisible(true);
targetPkgTableViewer.getTable().setLinesVisible(true);
targetPkgTableViewer.setContentProvider(new ViewContentProvider());
targetPkgTableViewer.setLabelProvider(new ViewLabelProvider());
targetPkgTableViewer.getTable().addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
}
@Override
public void mouseDown(MouseEvent e) {
}
@Override
public void mouseDoubleClick(MouseEvent e) {
if (isSupportAddOrDeleteOper) {
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
if (selectData == null || selectData.length == 0) {
return;
}
PkgInfo itemData = (PkgInfo) selectData[0].getData();
targetPkgTableViewer.remove(itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
});
targetPkgTableViewer.getTable().setToolTipText("双击或者右键菜单可删除被测进程");
FormData tableViewFormData = new FormData();
tableViewFormData.left = new FormAttachment(0, 5);
tableViewFormData.right = new FormAttachment(100, -5);
tableViewFormData.top = new FormAttachment(pkgNameText, 10);
tableViewFormData.height = 125;
Table table = targetPkgTableViewer.getTable();
table.setLayoutData(tableViewFormData);
}
use of org.eclipse.swt.layout.FormAttachment in project GT by Tencent.
the class SettingView method createSettingTabItem.
private void createSettingTabItem(TabFolder parent) {
// 创建CPU标签页
TabItem settingTabItem = new TabItem(parent, SWT.NONE);
settingTabItem.setText("首选项");
//CPU标签根容器
Composite settingTabRoot = new Composite(parent, SWT.NONE);
settingTabRoot.setLayout(new FormLayout());
FormData monitorItemGroupFormData = new FormData();
monitorItemGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
monitorItemGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
monitorItemGroupFormData.top = new FormAttachment(settingTabRoot, Constant.MARGIN_WIDTH_NARROW);
Group monitorGroup = new Group(settingTabRoot, SWT.NONE);
monitorGroup.setText("监测项");
monitorGroup.setLayoutData(monitorItemGroupFormData);
monitorGroup.setLayout(new FormLayout());
FormData cpuGroupFormData = new FormData();
cpuGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
cpuGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
cpuGroupFormData.top = new FormAttachment(monitorGroup, Constant.MARGIN_WIDTH_NARROW);
Group cpuGroup = new Group(monitorGroup, SWT.NONE);
cpuGroup.setLayoutData(cpuGroupFormData);
cpuGroup.setLayout(new GridLayout(3, true));
Label cpuLabel = new Label(cpuGroup, SWT.NONE);
cpuLabel.setText("CPU");
itemTestSwitch[Constant.CPU_INDEX] = new Button(cpuGroup, SWT.RADIO);
itemTestSwitch[Constant.CPU_INDEX].setText("开");
itemTestSwitch[Constant.CPU_INDEX].setSelection(false);
itemTestSwitch[Constant.CPU_INDEX].addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
itemTestSwitchClose[Constant.CPU_INDEX] = new Button(cpuGroup, SWT.RADIO);
itemTestSwitchClose[Constant.CPU_INDEX].setText("关");
itemTestSwitchClose[Constant.CPU_INDEX].setSelection(true);
FormData memGroupFormData = new FormData();
memGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
memGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
memGroupFormData.top = new FormAttachment(cpuGroup, Constant.MARGIN_WIDTH_NARROW);
memGroupFormData.bottom = new FormAttachment(100, -Constant.MARGIN_WIDTH);
Group memGroup = new Group(monitorGroup, SWT.NONE);
memGroup.setLayoutData(memGroupFormData);
memGroup.setLayout(new GridLayout(3, true));
Label memLabel = new Label(memGroup, SWT.NONE);
memLabel.setText("内存");
itemTestSwitch[Constant.MEM_INDEX] = new Button(memGroup, SWT.RADIO);
itemTestSwitch[Constant.MEM_INDEX].setText("开");
itemTestSwitch[Constant.MEM_INDEX].setSelection(false);
itemTestSwitch[Constant.MEM_INDEX].addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
itemTestSwitchClose[Constant.MEM_INDEX] = new Button(memGroup, SWT.RADIO);
itemTestSwitchClose[Constant.MEM_INDEX].setText("关");
itemTestSwitchClose[Constant.MEM_INDEX].setSelection(true);
settingTabItem.setControl(settingTabRoot);
}
Aggregations