use of org.eclipse.swt.events.SelectionEvent in project cogtool by cogtool.
the class ActionPropertySet method layoutHelper.
@Override
public void layoutHelper() {
actionSettings = new Composite(parent, SWT.BORDER);
actionSettings.setLayout(actionSettingsLayout);
propLabel = new Label(parent, SWT.CENTER);
propLabel.setText(designPropertiesLabel);
Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
propLabel.setFont(labelFont);
actionType = new DisplayLabel(parent, SWT.NONE);
actionType.setText(actionTypeLabel);
actionChoices = new ComboWithEnableFix(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
actionChoices.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
int currentSelection = actionChoices.getSelectionIndex();
if (currentSelection != chosenActionType) {
editTransitionParms.useWhichParts = choiceUseIndexes[currentSelection];
chosenActionType = currentSelection;
view.performAction(DesignEditorLID.EditTransition, editTransitionParms, true);
}
}
});
delayLabelLabel = new DisplayLabel(parent, SWT.NONE);
delayLabelLabel.setText(DELAY_LABEL_LABEL);
delayLabel = new View.PerformActionText(parent, SWT.SINGLE | SWT.BORDER) {
@Override
protected void onFocus() {
super.onFocus();
view.getTransmuter().setLIDEnabledState();
}
@Override
protected boolean doChangeAction() {
Point labelSelection = getSelection();
if ("".equals(getText())) {
setText(TransitionDelay.DEFAULT_DELAY_LABEL);
labelSelection = null;
}
if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (labelSelection != null) {
setSelection(labelSelection);
}
return true;
}
return false;
}
};
delayInSecsLabel = new DisplayLabel(parent, SWT.NONE);
delayInSecsLabel.setText(DELAY_DURATION_LABEL + ":");
secondsUnit = new Label(parent, SWT.NONE);
secondsUnit.setText(SECONDS);
delayInSecs = new View.PerformActionDouble(parent, SWT.SINGLE | SWT.BORDER) {
@Override
protected void onFocus() {
super.onFocus();
view.getTransmuter().setLIDEnabledState();
}
@Override
protected void onModify() {
super.onModify();
delayLabel.setEnabled(getDoubleValue() > 0.0);
}
@Override
protected boolean doChangeAction() {
Point delaySelection = getSelection();
if (getDoubleValue() == 0.0) {
setText("");
delaySelection = null;
}
if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (delaySelection != null) {
setSelection(delaySelection);
}
return true;
}
return false;
}
};
delayInSecs.setAllowNegative(false);
delayInSecs.setDecimalPlaces(3);
delayInSecs.moveAbove(delayLabel.getOuter());
FormData data = new FormData();
data.left = leftAttachment;
data.right = new FormAttachment(100, -5);
propLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionChoices, 0, SWT.CENTER);
actionType.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(actionType, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
actionChoices.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionChoices, 5, SWT.BOTTOM);
data.right = new FormAttachment(100, -5);
actionSettings.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(actionSettings, 5, SWT.BOTTOM);
delayInSecsLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayInSecsLabel, 5, SWT.BOTTOM);
data.width = 100;
delayInSecs.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(delayInSecs.getOuter(), 5, SWT.RIGHT);
data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
secondsUnit.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayInSecs.getOuter(), 5, SWT.BOTTOM);
delayLabelLabel.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(delayLabelLabel, 5, SWT.BOTTOM);
data.right = new FormAttachment(100, -5);
delayLabel.setLayoutData(data);
emptyParms = createEmptyComposite();
layOutEmptyComposite();
multTransParms = new Composite(actionSettings, SWT.NONE);
multTransParms.setLayout(new FormLayout());
Label multTransLabel = new Label(multTransParms, SWT.WRAP);
multTransLabel.setText(noActionAvailableText);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
multTransLabel.setLayoutData(data);
frameParms = createFrameComposite();
}
use of org.eclipse.swt.events.SelectionEvent in project cogtool by cogtool.
the class ActionSet method createKeyComposite.
protected Composite createKeyComposite() {
Composite keyComp = new Composite(actionSettings, SWT.NONE);
keyComp.setLayout(new FormLayout());
keyboardTextLabel = new DisplayLabel(keyComp, SWT.NONE);
keyboardTextLabel.setText(L10N.get("DE.KeyboardTextCaption", "Text") + ":");
keyboardText = createKeyboardText(keyComp);
keyboardText.setFont(FontUtils.SYMBOL_FONT);
keyboardIsCmd = new Button(keyComp, SWT.CHECK);
keyboardIsCmd.setText(L10N.get("DE.IsCommand", "Is Command"));
keyboardIsCmd.addSelectionListener(deviceActionChange);
// TODO Why is this here rather than in its natural home in the
// overridden method in ActionPropertySet?
transitionDestinationLabelKeyboard = createTransitionDestinationLabel(keyComp);
transitionDestinationNameKeyboard = createTransitionDestinationName(keyComp);
/* TODO: add back in when single character stuff is straightened out
this.keyboardActionLabel = new DisplayLabel(keyComp, SWT.NONE);
this.keyboardActionLabel.setText(L10N.get("DE.KeyActionCaption",
"Action")
+ ":");
this.keyboardActionCombo =
new ComboWithEnableFix(keyComp,
SWT.DROP_DOWN | SWT.READ_ONLY);
for (int i = 0; i < KeyPressType.DISPLAY.length; i++) {
this.keyboardActionCombo.add(KeyPressType.DISPLAY[i].toString());
}
this.keyboardActionCombo.select(0);
this.keyboardActionCombo.addSelectionListener(this.deviceActionChange);
*/
SelectionListener insertSpecial = new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Control source = (Control) e.getSource();
keyboardText.insert((String) source.getData());
Point selection = keyboardText.getSelection();
keyboardText.setFocus();
keyboardText.setSelection(selection);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
// TODO: replace alignTo with this.keyboardActionCombo when the above TODO is done!
// can't assign using ?: because Java is stupid
Control alignTo;
if (vertical) {
alignTo = transitionDestinationNameKeyboard;
} else {
alignTo = keyboardText.getOuter();
}
keyboardSpecials = new KeyboardSpecialChars(alignTo, insertSpecial, vertical);
return keyComp;
}
use of org.eclipse.swt.events.SelectionEvent 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.events.SelectionEvent 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.events.SelectionEvent 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