How to create a page that contains a form instead of a table? [message #1001776] |
Thu, 17 January 2013 11:00 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
I wanted a page to show a form instead of a table. After failed attempts at trying this with an AbstractPage I reverted to using a AbstractPageWithTable and then added the following code to execPageActivated:
@Override
protected void execPageActivated() throws ProcessingException {
if (getCompanyNr() != null) {
form = new TabbedForm();
form.setCompanyNr(getCompanyNr());
form.setDisplayViewId(IForm.VIEW_ID_PAGE_TABLE);
form.setEnabledGranted(false);
setDetailForm(form);
form.startDisplay();
}
}
This works nicely in my Swing client, but causes problems in the SWT client (see Bug 398305).
Is this the recommended way of doing it? Or is there a better way to show a form instead of the table?
Another question is how I would show the table again on this page instead of the form?
[Updated on: Thu, 17 January 2013 11:01] Report message to a moderator
|
|
|
|
Re: How to create a page that contains a form instead of a table? [message #1002271 is a reply to message #1001797] |
Fri, 18 January 2013 09:42 |
|
Hello Urs and Jeremie
Let me describe a clean test-bed project for our case With some steps.
Step 1.
Create a new Scout project with "Otline Tree and Table Form" template let's say xx.xx.
Step 2.
Goto ScoutExplorer xx.xx --> client --> Desktop --> StandardOutline --> Child Pages and create three new pages using AbstractPage template with the following names.
- FirstPage
- SecondPage
- ThirdPage
Step 3.
Goto ScoutExplorer xx,xx --> client --> Desktop --> Forms and create five new forms with the following names
- FirstPageMainForm
- FirstPageSecondaryForm
- FirstPageThirdForm
- SecondPageMainForm
- SecondPageSecondaryForm
Step 4.
Now goto FirstPage.java and add the following code.
FirstPageMainForm mainForm;
FirstPageSecondaryForm secondaryForm;
FirstPageThirdForm thirdForm;
@Override
protected void execPageActivated() throws ProcessingException {
mainForm = new FirstPageMainForm();
mainForm.setDisplayHint(IForm.DISPLAY_HINT_VIEW);
mainForm.setDisplayViewId(IForm.VIEW_ID_PAGE_TABLE);
mainForm.startModify();
secondaryForm = new FirstPageSecondaryForm();
secondaryForm.setDisplayHint(IForm.DISPLAY_HINT_VIEW);
secondaryForm.setDisplayViewId(IForm.VIEW_ID_E);
secondaryForm.startModify();
thirdForm = new FirstPageThirdForm();
thirdForm.setDisplayHint(IForm.DISPLAY_HINT_VIEW);
thirdForm.setDisplayViewId(IForm.VIEW_ID_CENTER);
thirdForm.startModify();
}
@Override
protected void execPageDeactivated() throws ProcessingException {
if (mainForm != null) {
mainForm.doClose();
mainForm = null;
}
if (secondaryForm != null) {
secondaryForm.doClose();
secondaryForm = null;
}
if (thirdForm != null) {
thirdForm.doClose();
thirdForm = null;
}
}
Step 5.
Also goto SecondPage.java and add the following code.
SecondPageMainForm mainForm;
SecondPageSecondaryForm secondaryForm;
@Override
protected void execPageActivated() throws ProcessingException {
mainForm = new SecondPageMainForm();
mainForm.setDisplayHint(IForm.DISPLAY_HINT_VIEW);
mainForm.setDisplayViewId(IForm.VIEW_ID_PAGE_TABLE);
mainForm.startModify();
secondaryForm = new SecondPageSecondaryForm();
secondaryForm.setDisplayHint(IForm.DISPLAY_HINT_VIEW);
secondaryForm.setDisplayViewId(IForm.VIEW_ID_E);
secondaryForm.startModify();
}
@Override
protected void execPageDeactivated() throws ProcessingException {
if (mainForm != null) {
mainForm.doClose();
mainForm = null;
}
if (secondaryForm != null) {
secondaryForm.doClose();
secondaryForm = null;
}
}
Step 6.
Run the Server and the SWT.
Step 7.
Navigate as follows
- FirstPage
- ThirdPage
- SecondPage
- ThirdPage
- FirstPage
Everything works fine. Isnt it?
|
|
|
Re: How to create a page that contains a form instead of a table? [message #1002275 is a reply to message #1002271] |
Fri, 18 January 2013 09:49 |
|
If you think that it worths to check the behavior of that test project, let me say my opinion.
I believe that either something is missing in the sequence (execPageActivated, execPageDeactivated) or something is going wrong with asyncexec. In my computer can sometimes observe the creation of the new page before the final blank.
Do you have some idea about it?
|
|
|
|
|
|
Re: How to create a page that contains a form instead of a table? [message #1004303 is a reply to message #1003962] |
Wed, 23 January 2013 00:11 |
|
Quote:Everything works fine. Isnt it?
In my first post, the previous comment was ironic. That's why in my second post i proposed two possible explanations.
The code i provided it works only if the user follows the proposed navigation or in any way avoid to navigate directly from one page with forms to another page with forms.
In my experiments i noticed that navigating from the first page to second, the second page was drawed before disappearing. Also if you navigate to fast the sequence first->third->second the screen was still cluttered. These two observations made me to suspected that there is an issue about asyncExec(). So, i did a little hack with the following code at the end of execPageDeactivated()
try {
Thread.sleep(600);
}
catch (InterruptedException e) {}
The result is that you can navigate from one page to another without any problem. Please have in mind that 600 milliseconds is not an absolute number. In the second page for example a delay of 100 milliseconds is good enough.
So, there is a solution if we follow the first approach. Not so elegant, but simple enough and almost harmless.
|
|
|
|
|
|
|
Re: How to create a page that contains a form instead of a table? [message #1062417 is a reply to message #1001776] |
Fri, 07 June 2013 15:03 |
Ken Lee Messages: 97 Registered: March 2012 |
Member |
|
|
After having analyzed and solved the problems with a dirty workaround described in bug 406764, the bug 387625 also seems to have been gone with the latest Scout Kepler 3.9 RC3.
So I was hoping that this would also be the solution to the problem posted by Stathis Alexopoulos. Unfortunately, it is not
What we've found out so far is that this is definitely an E4 bug that we already reported in bug 385618. The bug does not appear if the Eclipse platform 3.x is used.
In summary, there is probably a multi-threading issue in E4 while hiding and re-opening a view. Somehow, a close event is fired after re-opening the view. More details can be found in the reported bug above.
The difference between the previous mentioned Scout bugs and the problem described in this forum post is that we have several forms in this example.
In the FirstPage we close the mainForm, secondaryForm and thirdForm first before opening the mainForm and secondayForm of the SecondPage. Since this is done in the model code, Scout will delegate these changes to the SWT GUI thread which handles the view hide / show events asynchronously.
So postponing the thread that handles the close view event may work if a single view is hidden / re-opened but since we have 3 "hide" threads and 2 "show" view threads in the queue, we cannot guarantee that the "hiding" threads are executed AFTER the "showing" threads.
Since I cannot find any reasonable solution in Scout, I hope that the bug 385618 will be fixed in E4 soon.
[Updated on: Fri, 07 June 2013 15:03] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04729 seconds