Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Using Forms to view and edit properties
Using Forms to view and edit properties [message #457512] Mon, 27 June 2005 15:12 Go to next message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
Hello,

I was looking at using Eclipse Forms to view and edit properties on my
model objects instead of the standard table-based properties view. I
want it to function similarly e.g. when you click on the object in the
resource view, the view would display the Forms page for the currently
selected object. Obviously, I will have to write the code to build the
page for each model object. However, I'm mainly worried about
performance and resource allocation/de-allocation. So my questions are:

1. Do you think using a Forms-based properties page is reasonable?
2. What do I need to do to ensure that I have no resource or memory
leaks? Is it as simple as calling disposing on each of the components
in the view before replacing them with the components from the new view?

And if this is not the right place to be inquiring about this, please
point me to the correct newsgroup.

Thanks,
Josh Reed
Re: Using Forms to view and edit properties [message #457641 is a reply to message #457512] Wed, 29 June 2005 21:37 Go to previous messageGo to next message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
I'm going to keep thinking aloud here...

I worked on implementing this approach. I created an interface:

public interface IFormsPropertyPage {
public void createPage(FormToolkit toolkit,
ScrolledForm form,
IWorkbenchPart part,
Object selection);
public void dispose();
}

It is my intention that each model object would have a forms property
page associated with it (like ILabelProvider). Then the FormsView class
would just swap pages by calling createPage on the appropriate
IFormsPropertyPage based on the current selection.

I implemented a simple example with two pages:

public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (page != null) {
page.dispose();
}

if (selection instanceof IStructuredSelection) {
Object target =
((IStructuredSelection)selection).getFirstElement();
if (target == null) {
System.out.println("target == null");
page = new NullFormsPropertyPage();
page.createPage(toolkit, form, part, target);
} else {
if (target instanceof SiteResource) {
System.out.println("target instanceof SiteResource");
page = new SiteFormsPropertyPage();
page.createPage(toolkit, form, part, target);
} else {
System.out.println("else");
page = new NullFormsPropertyPage();
page.createPage(toolkit, form, part, target);
}
}
form.pack();
}
}

This works somewhat but there are some painting issues. I played around
with various combinations of form.redraw(), form.pack(), form.update()
but nothing seems to work quite right. If I do a redraw or update,
nothing happens. Though as soon as I resize the view, everything gets
painted properly. If I do a pack() or pack(true) I see the new contents
of the form but the white background only gets painted behind the
content. The rest of the view is the dialog color. But again, as soon
as I resize the view, I get the full white background.

I don't know if it is worth it. I like the look of the Forms but
perhaps I should just stick with the standard dialog...
Re: Using Forms to view and edit properties [message #457879 is a reply to message #457641] Wed, 06 July 2005 11:00 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Does this help?

ec.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
Re: Using Forms to view and edit properties [message #457889 is a reply to message #457879] Wed, 06 July 2005 13:57 Go to previous message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
Wim Jongman wrote:
> Does this help?
>
> ec.addExpansionListener(new ExpansionAdapter() {
> public void expansionStateChanged(ExpansionEvent e) {
> form.reflow(true);
> }
> });
>
>

I didn't try the form.reflow() method. My main problem stemmed from
repainting--when I forced it to repaint, the actual components had the
proper white background but the unused space in the parent was the
standard dialog color. In any event, I got it to work with standard
SWT. I also ran into a problem when I wanted to put a slider on the
form. It probably wasn't intended to be used in the Forms so it didn't
look right and wouldn't toolkit.adapt() properly either. So I'll
probably stick with standard SWT.


Thanks for the suggestion!
Josh
Previous Topic:WMPlayer.OCX (Windows Media Player) trouble
Next Topic:Icon Colors on a Sun Blade
Goto Forum:
  


Current Time: Fri Apr 26 10:14:11 GMT 2024

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

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

Back to the top