|
Re: Using Forms to view and edit properties [message #457641 is a reply to message #457512] |
Wed, 29 June 2005 21:37 |
Josh Reed 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...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03955 seconds