use of org.eclipse.swt.layout.GridLayout in project cogtool by cogtool.
the class Keypad method buildDialog.
@Override
protected void buildDialog() {
GridLayout grid = new GridLayout();
switch(keypadType) {
case FULL_KEYPAD:
{
grid.numColumns = 2;
makeLetters();
makeNumbers();
makeEntry();
break;
}
case NUMPAD_ONLY:
{
grid.numColumns = 1;
makeNumbers();
makeEntry();
break;
}
}
dialog.setLayout(grid);
}
use of org.eclipse.swt.layout.GridLayout in project cogtool by cogtool.
the class Keypad method makeNumbers.
/**
* Creates and lays out the buttons for the keypad's number pad.
*
* @author Paul Rubritz (ptr@andrew.cmu.edu)
*/
protected void makeNumbers() {
GridLayout grid = new GridLayout();
grid.numColumns = 3;
GridData gridKeysOption = new GridData();
gridKeysOption.horizontalIndent = (keypadType == FULL_KEYPAD) ? 60 : 0;
gridKeysOption.verticalAlignment = SWT.TOP;
Composite numbers = new Composite(dialog, SWT.NONE);
numbers.setLayoutData(gridKeysOption);
numbers.setLayout(grid);
Button keypadButton;
for (int i = 0; i < numberKeys.length; i++) {
gridKeysOption = new GridData();
if (i < numberKeys.length - 1) {
gridKeysOption.widthHint = 50;
} else if (keypadType == NUMPAD_ONLY) {
gridKeysOption.widthHint = 160;
gridKeysOption.horizontalSpan = 3;
} else {
break;
}
gridKeysOption.heightHint = 50;
keypadButton = makeButton(numbers, numberKeys[i], gridKeysOption);
// (see IntegerEntry)
if ((keypadType == NUMPAD_ONLY) && numberKeys[i].equals("-")) {
keypadButton.setBackground(getDisabledColor());
keypadButton.setEnabled(false);
}
}
}
use of org.eclipse.swt.layout.GridLayout in project cogtool by cogtool.
the class AboutView method buildDialog.
@Override
public void buildDialog() {
GridLayout layout = new GridLayout(4, false);
if (OSUtils.MACOSX) {
layout.marginLeft = 21;
layout.marginRight = 21;
layout.marginTop = 10;
layout.marginBottom = 15;
}
dialog.setLayout(layout);
// Centered logo, filling width
Label logo = new Label(dialog, SWT.CENTER);
logo.setImage(logoImg);
GridData imgLayout = new GridData();
imgLayout.horizontalSpan = 4;
imgLayout.horizontalAlignment = GridData.FILL;
imgLayout.grabExcessHorizontalSpace = true;
logo.setLayoutData(imgLayout);
// Current version, centered
Text version = new Text(dialog, SWT.CENTER | SWT.READ_ONLY);
GridData versionLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
versionLayout.horizontalSpan = 4;
version.setLayoutData(versionLayout);
version.setText(CogTool.getVersion());
// Copyright and URL (as Link), centered
Label copyright = new Label(dialog, SWT.NONE);
GridData copyrightLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
copyrightLayout.horizontalSpan = 4;
copyright.setLayoutData(copyrightLayout);
// © is the (c) copyright symbol
copyright.setText(L10N.get("CT.Copyright", "© 2012 CogTool@Carnegie Mellon University"));
// Be careful if you modify the following: the SWT Link object seems
// to behave most bizarrely if you combine a tilde in the middle of
// a URL with a trailing slash at its end.
addLink("Download updates from", L10N.get("CT.MainURL", "https://github.com/cogtool/cogtool/releases/latest"));
addLink("Documentation", L10N.get("CT.UserGuideURL", "https://github.com/cogtool/cogtool/releases/download/1.2.2/CogToolUserGuide_1_2.pdf"));
Label memory = new Label(dialog, SWT.NONE);
GridData memoryLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
memoryLayout.horizontalSpan = 4;
memory.setLayoutData(memoryLayout);
memory.setText(CogTool.getMemoryUsage());
Label props = new Label(dialog, SWT.NONE);
GridData propsLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
propsLayout.horizontalSpan = 4;
props.setLayoutData(propsLayout);
props.setText(CogTool.getConfigurationProperties());
addButtons();
}
use of org.eclipse.swt.layout.GridLayout in project flux by eclipse.
the class ConnectionPreferencePage method createConnectionGroup.
private Control createConnectionGroup(Composite parent) {
Group group = new Group(parent, SWT.BORDER_SOLID);
group.setText("Connection Settings");
group.setToolTipText("Flux messaging server connection info");
group.setLayout(new GridLayout(2, false));
Label label = new Label(group, SWT.NONE);
label.setText("Server URL:");
GridData gridData = new GridData();
label.setLayoutData(gridData);
url = new Text(group, SWT.BORDER);
url.setText(editable ? getPreferenceStore().getString(IPreferenceConstants.PREF_URL) : Activator.getHostUrl());
url.setEnabled(editable);
url.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (url.getText().isEmpty()) {
setErrorMessage(null);
setValid(true);
} else {
try {
new URL(url.getText());
setErrorMessage(null);
setValid(true);
} catch (MalformedURLException e) {
setErrorMessage(e.getMessage());
setValid(false);
}
}
}
});
gridData = new GridData(GridData.FILL_HORIZONTAL);
url.setLayoutData(gridData);
label = new Label(group, SWT.NONE);
label.setText("GitHub ID:");
label.setLayoutData(new GridData());
user = new Text(group, SWT.BORDER);
user.setText(editable ? getPreferenceStore().getString(IPreferenceConstants.PREF_USER_ID) : Activator.getUserId());
user.setEnabled(editable);
user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label = new Label(group, SWT.NONE);
label.setText("GitHub Token:");
label.setLayoutData(new GridData());
token = new Text(group, SWT.BORDER);
token.setText(editable ? getPreferenceStore().getString(IPreferenceConstants.PREF_USER_TOKEN) : Activator.getUserToken());
token.setEnabled(editable);
token.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return group;
}
use of org.eclipse.swt.layout.GridLayout 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