Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Can't get SWT CheckBox Button and a Link to share row in GridLayout
Can't get SWT CheckBox Button and a Link to share row in GridLayout [message #954032] Mon, 22 October 2012 18:35
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 175
Registered: July 2009
Senior Member
I am creating a PropertyPage for Eclilpse 4.2 and I want to have a CheckBox Button with a Link beside it on the right.

I create a Composite which I give a GridLayout with 2 columns. I add the CheckBox and the Link to the Composite but I cannot get that Link to appear to the right of the CheckBox. I can get it to go the far right as desired, but it always appears on the next row. There is more than enough space to add the Link to the right and clicking on the text of the CheckBox shows a selection that does not extend beyond the end of the text.

The following is the relevant code snippet of my createContents(). I have removed my preference store stuff and hard-coded the text strings here so it is easier to read. I also add a RadioGroupFieldEditor to the composite in my original code and that appears below the Link. I originally tried a BooleanFieldEditor instead of the CheckBox but had the same issue so tried falling back to a CheckBox.

I must be missing something obvious, so if anybody can see it, please let me know. I have tried adding more columns to the GridLayout, but that doesn't help.

@Override
protected Control createContents(final Composite parent) {
composite = new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout( new GridLayout(2, false));

useProjectSetting = new Button(composite, SWT.CHECK);
useProjectSetting.setText("Enable project-specific settings");
useProjectSetting.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
useProjectSetting.setSelection(false);
useProjectSetting.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateOptionsEnable();
}
});

fLink= new Link(composite, SWT.NULL);
fLink.setText("<a>Configure Workspace Settings...</a>");
fLink.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false, 1, 1));
fLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), getPrefPageId(), null, null).open();
}
});
Previous Topic:Eclipse 4.2 appearance
Next Topic:Indigo: Prespective is not changeable any more!!
Goto Forum:
  


Current Time: Fri Nov 21 16:45:38 GMT 2014

Powered by FUDForum. Page generated in 0.03590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software