Using the widgetSelected event for
MPD virtual support is dangerous. We don't know that filling in the page
composite at that point will necessarily get that content rendered. It
may in WM, but not other implementations. Therefore, i suggest sticking
with setData().
A setPageCount(int) method does not work because page titles are not supplied
and the MPD tabs would be unnamed until the page is actually created.
Here are two alternatives:
1) As normally done now, program creates pages
before dialog is displayed but does not populate them until handleEvent
is called. MPD code must create the composite, but that is only one widget..
When handleEvent is called program can match provided composite to the
originally created one.
2) Instead of getting a composite back
from createPage, that method could return null when SWT.VIRTUAL is used.
Then no widgets are created until needed. However, for that to work, the
handleEvent must pass both the Composite as well as a page number, so the
program knows what page to populate. Can this be done?
Eric MF Hsu <mfhsu@xxxxxxxxxx>
04/13/2008 11:57 AM
To
<Gorkem.Ercan@xxxxxxxxx>,
Mark Rogalski/Austin/IBM@IBMUS, Uriel KL Liu <liukl@xxxxxxxxxx>
cc
Daniel DL Su <dlsu@xxxxxxxxxx>
Subject
eRCP MultiPageDialog Virtual support
issue
Hi....Gorkem et al
I have some issues regarding the new function of virtual support of MultipageDialog.
The sample code in mobile spec is as below
final MultiPageDialog
dialog
=
new
MultiPageDialog(shell,
SWT.PRIMARY_MODAL
|
SWT.VIRTUAL);
dialog.createPage("Page
1",
null);
dialog.createPage("Page
2",
null);
dialog.createPage("Page
3",
null);
dialog.addListener(SWT.SetData,
new
Listener()
{
public void
handleEvent(Event
event)
{
Composite page
=
(Composite)event.item;
//Populate rest
of
the
UI
}
Since dialog.createPage(...) will return a instantiated Composite to developer,
they can just use it without writing any codes in handleEvent() block.
This will break the spirit of virtual style and make virtual useless.
I'd suggest to add a new method ( setPageCount(int PageCount)). Then the
sample code will be :
final MultiPageDialog dialog = new MultiPageDialog(shell, SWT.PRIMARY_MODAL
| SWT.VIRTUAL);
dialog.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
Composite page = (Composite)event.item;
//Populate rest of the UI
}
dialog.setPageCount(3);
However, we noticed that MPD has the method addSelectionListener(SelectionListener
listener) {} already. This will be notified while one page is selected.
The method can be used to simulate similar functionality of virtual MPD.
The sample code can be as below.
final MultiPageDialog dialog = new MultiPageDialog(shell, SWT.PRIMARY_MODAL);
dialog.createPage("Page 1", null);
dialog.createPage("Page 2", null);
dialog.createPage("Page 3", null);
dialog.addSelectionListener(new SelectionListener() {
publicvoid widgetDefaultSelected(SelectionEvent event) {
}
publicvoid widgetSelected(SelectionEvent event) {
//Populate rest of the UI
}
});
However, developer needs to get desired page to complete work, It's not
convenient as virtual MPD.
Do you have any suggestion? Thank you.
Sincerely,
Eric MF Hsu (徐銘法)
eRCP/Lotus Expeditor device development
China Software Development Lab, IBM Taiwan
E-Mail : mfhsu@xxxxxxxxxx Tel : 886-2-8170-6571