use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.
the class NewActionChangeDialog method addMoreFields.
@Override
protected void addMoreFields() {
GridData reqLayout;
if (complaint != null) {
reqLayout = new GridData();
reqLayout.grabExcessHorizontalSpace = true;
reqLayout.horizontalSpan = 4;
complaintLabel = new Label(dialog, SWT.NONE);
complaintLabel.setText(complaint);
complaintLabel.setLayoutData(reqLayout);
complaintLabel.setFont(FontUtils.SYMBOL_FONT);
complaintMode = properties.useWhichParts;
}
reqLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
reqLayout.grabExcessHorizontalSpace = true;
reqLayout.horizontalSpan = 4;
Composite c = new Composite(dialog, SWT.NONE);
c.setLayoutData(reqLayout);
propertySet = new ActionChangePropertySet(deviceTypes, c, this) {
protected ActionProperties testEnableProps = new ActionProperties(ActionProperties.UNSET);
@Override
protected boolean userSelectedMode(int widgetMode) {
boolean enableOK = super.userSelectedMode(widgetMode);
if (complaintLabel != null) {
complaintLabel.setVisible(widgetMode == complaintMode);
}
return enableOK;
}
@Override
protected void enableOKButton(boolean enable) {
// the OK button should be otherwise enabled
if (enable) {
if ((transitionSrc != null) && (properties != null)) {
propertySet.getProperties(testEnableProps);
AAction action = testEnableProps.buildAction();
Transition existingTransition = transitionSrc.getTransition(action);
if ((action != null) && (existingTransition != null)) {
enable = false;
}
}
}
super.enableOKButton(enable);
}
};
propertySet.layOutPropertiesPane();
}
use of org.eclipse.swt.layout.GridData 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.GridData in project cogtool by cogtool.
the class AboutView method addLink.
// buildDialog
protected void addLink(String label, final String url) {
Link link = new Link(dialog, SWT.NONE);
GridData linkLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
linkLayout.horizontalSpan = 4;
link.setLayoutData(linkLayout);
link.setText(label + ": <a href=\"" + url + "\">" + url + "</a>");
link.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
Program.launch(url);
}
});
}
use of org.eclipse.swt.layout.GridData 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.GridData in project cogtool by cogtool.
the class AboutView method addButtons.
protected void addButtons() {
if (OSUtils.WINDOWS) {
// Centered OK button for dismissing the dialog box, set as default button
Button okButton = new Button(dialog, SWT.PUSH);
okButton.setText(L10N.get("B.OK", "OK"));
okButton.setFocus();
dialog.setDefaultButton(okButton);
// boolean ignore = okButton.setFocus();
GridData okLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
okLayout.horizontalSpan = 4;
okButton.setLayoutData(okLayout);
// Dismiss the dialog box when OK button selected
okButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
dialog.close();
}
});
}
}
Aggregations