Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Eclipse Forms and JFace Dialog
Eclipse Forms and JFace Dialog [message #327207] Mon, 14 April 2008 07:38 Go to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hi!

I want to create a JFace dialog which uses the Eclipse Forms in its dialog
area. But I can't managed it to get it working. The Scrolled Form area is
very small and does not fit into the dialog's area: when I resize the
dialog, the scrolled form does not resize either!

How can I set the default size of the dialog?

Here is my code:

public class MyPropertyDialogextends Dialog {

private FormToolkit toolkit;

private ScrolledForm form;

public MyPropertyDialog(Shell parentShell) {

super(parentShell);

setShellStyle(getShellStyle() | SWT.RESIZE);
}

@Override
protected Control createDialogArea(Composite parent) {

Composite parentComposite = (Composite)super.createDialogArea(parent);

toolkit = new FormToolkit(parent.getDisplay());

form = toolkit.createScrolledForm(parentComposite);
form.setText("Edit trigger");

Composite composite = form.getBody();

final GridLayout layout = new GridLayout(2, true);
composite.setLayout(layout);

GridData gd = new GridData();
Section cronSection = toolkit.createSection(composite,
Section.EXPANDED | Section.TWISTIE | Section.TITLE_BAR);
cronSection.addExpansionListener(new SectionExpansionAdapter());
cronSection.setText("Cron");
gd.horizontalSpan = 1;
cronSection.setLayoutData(gd);

cronSection.setClient(createCronSection(cronSection));

Section tableSection = toolkit.createSection(composite,
Section.TITLE_BAR | Section.EXPANDED);
tableSection.addExpansionListener(new SectionExpansionAdapter());
tableSection.setText("All");
tableSection.setLayoutData(gd);

tableSection.setClient(createTableSection(tableSection));

Section simpleSection = toolkit.createSection(composite,
Section.TWISTIE | Section.TITLE_BAR);
simpleSection.addExpansionListener(new SectionExpansionAdapter());
simpleSection.setText("Simple");
simpleSection.setLayoutData(gd);

simpleSection.setClient(createSimpleSection(simpleSection));

//parentComposite.getShell().setSize(400,400);

return parentComposite;
}

protected Composite createCronSection(Section section) {

Composite container = toolkit.createComposite(section);

return container;
}

protected Composite createSimpleSection(Section section) {

Composite container = toolkit.createComposite(section);

return container;
}

protected Composite createTableSection(Section section) {

Composite container = toolkit.createComposite(section);

return container;
}

class SectionExpansionAdapter extends ExpansionAdapter {

@Override
public void expansionStateChanged(ExpansionEvent e) {

form.reflow(true);
}

}

}




What am I doing wrong here?!?

Best regards,
Matthias
Re: Eclipse Forms and JFace Dialog [message #327215 is a reply to message #327207] Mon, 14 April 2008 10:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom.seidel.spiritlink.de

You don't set a LayoutData on the forms body.

Cheerz,
Tom

Matthias schrieb:
> Hi!
>
> I want to create a JFace dialog which uses the Eclipse Forms in its
> dialog area. But I can't managed it to get it working. The Scrolled Form
> area is very small and does not fit into the dialog's area: when I
> resize the dialog, the scrolled form does not resize either!
>
> How can I set the default size of the dialog?
>
> Here is my code:
>
> public class MyPropertyDialogextends Dialog {
>
> private FormToolkit toolkit;
>
> private ScrolledForm form;
>
> public MyPropertyDialog(Shell parentShell) {
>
> super(parentShell);
>
> setShellStyle(getShellStyle() | SWT.RESIZE);
> }
>
> @Override
> protected Control createDialogArea(Composite parent) {
>
> Composite parentComposite =
> (Composite)super.createDialogArea(parent);
>
> toolkit = new FormToolkit(parent.getDisplay());
>
> form = toolkit.createScrolledForm(parentComposite);
> form.setText("Edit trigger");
>
> Composite composite = form.getBody();
>
> final GridLayout layout = new GridLayout(2, true);
> composite.setLayout(layout);
>
> GridData gd = new GridData();
> Section cronSection = toolkit.createSection(composite,
> Section.EXPANDED | Section.TWISTIE | Section.TITLE_BAR);
> cronSection.addExpansionListener(new SectionExpansionAdapter());
> cronSection.setText("Cron");
> gd.horizontalSpan = 1;
> cronSection.setLayoutData(gd);
>
> cronSection.setClient(createCronSection(cronSection));
>
> Section tableSection = toolkit.createSection(composite,
> Section.TITLE_BAR | Section.EXPANDED);
> tableSection.addExpansionListener(new SectionExpansionAdapter());
> tableSection.setText("All");
> tableSection.setLayoutData(gd);
>
> tableSection.setClient(createTableSection(tableSection));
>
> Section simpleSection = toolkit.createSection(composite,
> Section.TWISTIE | Section.TITLE_BAR);
> simpleSection.addExpansionListener(new SectionExpansionAdapter());
> simpleSection.setText("Simple");
> simpleSection.setLayoutData(gd);
>
> simpleSection.setClient(createSimpleSection(simpleSection));
>
> //parentComposite.getShell().setSize(400,400);
>
> return parentComposite;
> }
>
> protected Composite createCronSection(Section section) {
>
> Composite container = toolkit.createComposite(section);
>
> return container;
> }
>
> protected Composite createSimpleSection(Section section) {
>
> Composite container = toolkit.createComposite(section);
>
> return container;
> }
>
> protected Composite createTableSection(Section section) {
>
> Composite container = toolkit.createComposite(section);
>
> return container;
> }
>
> class SectionExpansionAdapter extends ExpansionAdapter {
>
> @Override
> public void expansionStateChanged(ExpansionEvent e) {
>
> form.reflow(true);
> }
>
> }
>
> }
>
>
>
>
> What am I doing wrong here?!?
>
> Best regards,
> Matthias
>
Re: Eclipse Forms and JFace Dialog [message #327268 is a reply to message #327215] Tue, 15 April 2008 06:27 Go to previous message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hello Tom!

Thank you for your answer!
I think the problem was that I havent set a layout data on the
(Scrolled)form (like new GridData(GridData.FILL_BOTH))!

But anyway now I am using the FormDialog which is a subclass from Dialog
and initializes the form (and some other stuff) for you...

Ok, problem solved, thanks!

Best regards,
Matthias
Previous Topic:Can I add a mouse listener to .java text editor?
Next Topic:Execute a command from code
Goto Forum:
  


Current Time: Sun Oct 06 14:20:28 GMT 2024

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

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

Back to the top