Eclipse Forms. Problem with Sections [message #444897] |
Thu, 23 February 2006 02:56  |
Eclipse User |
|
|
|
Originally posted by: pverma.gmail.com
Hi,
I am facing a strange problem with Eclipse Forms. In my
View::CreatePartControl(), I have code for creating 5 identical sections.
Each section contains a title, description and 2 radio buttons. The
problem is that strangely enough, Section 4 does not show up. There is
blank space where the fourth section should be.
I would appreciate it if someone could try out the running code provided
below and see what the problem could be. This code is repetitive and very
simple.
I am providing the code below.
public class ProjectView extends ViewPart {
public static final String ID = "MyView";
private FormToolkit toolkit;
private ScrolledForm form;
public void createPartControl(Composite parent) {
this.setPartName("My ViewPart");
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText("My Form");
TableWrapLayout layout = new TableWrapLayout();
form.getBody().setLayout(layout);
layout.numColumns = 2;
////////////////////////////Section 1
Section section = toolkit.createSection(form.getBody(),
Section.DESCRIPTION|Section.TITLE_BAR|
Section.TWISTIE|Section.EXPANDED);
TableWrapData td = new TableWrapData(TableWrapData.FILL);
td.colspan = 1;
section.setLayoutData(td);
section.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
//form.reflow(true);
}
});
section.setText("Section 1");
section.setDescription("Section 1 Description");
Composite sectionClient = toolkit.createComposite(section);
sectionClient.setLayout(new GridLayout());
Button button = toolkit.createButton(sectionClient, "Radio 1",
SWT.RADIO);
button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO);
section.setClient(sectionClient);
////////////////////////////Section 2
Section section2 = toolkit.createSection(form.getBody(),
Section.DESCRIPTION|Section.TITLE_BAR|
Section.TWISTIE|Section.EXPANDED);
TableWrapData td2 = new TableWrapData(TableWrapData.FILL);
td2.colspan = 1;
section2.setLayoutData(td2);
section2.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
//form.reflow(true);
}
});
section2.setText("Section 2");
section2.setDescription("Section 2 Description");
Composite sectionClient2 = toolkit.createComposite(section2);
sectionClient2.setLayout(new GridLayout());
Button button2 = toolkit.createButton(sectionClient2, "Radio 1",
SWT.RADIO);
button2 = toolkit.createButton(sectionClient2, "Radio 2", SWT.RADIO);
section2.setClient(sectionClient2);
////////////////////////////Section 3
Section section3 = toolkit.createSection(form.getBody(),
Section.DESCRIPTION|Section.TITLE_BAR|
Section.TWISTIE|Section.EXPANDED);
TableWrapData td3 = new TableWrapData(TableWrapData.FILL);
td3.colspan = 1;
section3.setLayoutData(td3);
section3.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
//form.reflow(true);
}
});
section3.setText("Section 3");
section3.setDescription("Section 3 Description");
Composite sectionClient3 = toolkit.createComposite(section3);
sectionClient3.setLayout(new GridLayout());
Button button3 = toolkit.createButton(sectionClient3, "Radio 1",
SWT.RADIO);
button3 = toolkit.createButton(sectionClient3, "Radio 2", SWT.RADIO);
section3.setClient(sectionClient3);
////////////////////////////Section 4
Section section4 = toolkit.createSection(form.getBody(),
Section.DESCRIPTION|Section.TITLE_BAR|
Section.TWISTIE|Section.EXPANDED);
TableWrapData td4 = new TableWrapData(TableWrapData.FILL);
td4.colspan = 1;
section4.setLayoutData(td4);
section4.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
//form.reflow(true);
}
});
section4.setText("Section 4");
section4.setDescription("Section 4 Description");
Composite sectionClient4 = toolkit.createComposite(section4);
sectionClient4.setLayout(new GridLayout());
Button button4 = toolkit.createButton(sectionClient4, "Radio 1",
SWT.RADIO);
button4 = toolkit.createButton(sectionClient4, "Radio 2", SWT.RADIO);
section4.setClient(sectionClient4);
////////////////////////////Section 5
Section section5 = toolkit.createSection(form.getBody(),
Section.DESCRIPTION|Section.TITLE_BAR|
Section.TWISTIE|Section.EXPANDED);
TableWrapData td5 = new TableWrapData(TableWrapData.FILL);
td5.colspan = 1;
section5.setLayoutData(td4);
section5.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
//form.reflow(true);
}
});
section5.setText("Section 5");
section5.setDescription("Section 5 Description");
Composite sectionClient5 = toolkit.createComposite(section5);
sectionClient5.setLayout(new GridLayout());
Button button5 = toolkit.createButton(sectionClient5, "Radio 1",
SWT.RADIO);
button5 = toolkit.createButton(sectionClient5, "Radio 2", SWT.RADIO);
section5.setClient(sectionClient5);
}
public void setFocus() {
form.setFocus();
}
/**
* Disposes the toolkit
*/
public void dispose() {
toolkit.dispose();
super.dispose();
}
}
The code should work fine if you import the following packages:
///////////////////////////////////////////////
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.forms.widgets.*;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.swt.widgets.Button;
///////////////////////////////////////////////
Thanks.
|
|
|
|
Re: Eclipse Forms. Problem with Sections [message #444906 is a reply to message #444902] |
Thu, 23 February 2006 10:30  |
Eclipse User |
|
|
|
Originally posted by: pverma.gmail.com
Reinhard Moser wrote:
>> section5.setLayoutData(td4);
Hi Reinhard,
You are a genius for spotting that bad line of code. It worked after the
correction, thanks very much!
Regards,
pv
|
|
|
Powered by
FUDForum. Page generated in 0.03826 seconds