Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How to create a page that contains a form instead of a table?(Am I on the right track with my code?)
How to create a page that contains a form instead of a table? [message #1001776] Thu, 17 January 2013 06:00 Go to next message
Urs Beeli is currently offline Urs Beeli
Messages: 325
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 06:01]

Report message to a moderator

Re: How to create a page that contains a form instead of a table? [message #1001797 is a reply to message #1001776] Thu, 17 January 2013 06:47 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 676
Registered: October 2011
Senior Member
From: http://wiki.eclipse.org/Scout/Concepts/Page_Detail_Form

@Override
protected void execPageDeactivated() throws ProcessingException {
  if (getDetailForm() != null) {
    getDetailForm().doClose();
    setDetailForm(null);
  }
}


Assuming you have getter / setter to store a "detailForm".
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 04:42 Go to previous messageGo to next message
Stathis Alexopoulos is currently offline Stathis Alexopoulos
Messages: 42
Registered: September 2010
Member
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

  1. FirstPage
  2. ThirdPage
  3. SecondPage
  4. ThirdPage
  5. 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 04:49 Go to previous messageGo to next message
Stathis Alexopoulos is currently offline Stathis Alexopoulos
Messages: 42
Registered: September 2010
Member
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 #1003518 is a reply to message #1002275] Mon, 21 January 2013 07:29 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 325
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks for all your input. With the code provided by Stathis, I have been able to use an AbstractForm instead of an AbstractFormWithTable to display a form. Still, there are two problems I'm seeing with SWT (it works with Swing):

  • when using VIEW_ID_PAGE_TABLE to place the form, I sometimes still have trouble on other pages that contain tables that the table view is not shown, using VIEW_ID_PAGE_DETAIL instead solves this problem
  • switching from a form-page to a table-page back to another form-page works, however when switching from one form-page to another form-page the form on the second page is not shown (this might relate to what Stathis is mentioning in his second post)

Re: How to create a page that contains a form instead of a table? [message #1003913 is a reply to message #1003518] Tue, 22 January 2013 03:17 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 676
Registered: October 2011
Senior Member
When you say SWT, I assume you use a 4.x Branch (like normal Juno Scout Package)... It would be interesting to see if there is also a bug with a 3.x Branch (It requires another target platform)

This might be related to the bugs we have with E4.
Re: How to create a page that contains a form instead of a table? [message #1003962 is a reply to message #1003913] Tue, 22 January 2013 05:28 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 325
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I've been using Juno (4.2) with Scout 3.8.1 for my playground project. Our "real" project will be based on Indigo with Scout Kepler (3.9?) Milestone 4.

I'll try to see if I can reproduce this there.
Re: How to create a page that contains a form instead of a table? [message #1004303 is a reply to message #1003962] Tue, 22 January 2013 19:11 Go to previous messageGo to next message
Stathis Alexopoulos is currently offline Stathis Alexopoulos
Messages: 42
Registered: September 2010
Member
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 #1004408 is a reply to message #1004303] Wed, 23 January 2013 02:15 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 325
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks Stathis for your followup and the workaround. It works for my forms, too (even though my sense of aesthetics is deeply offended at the kludge Wink

[Updated on: Wed, 23 January 2013 02:52]

Report message to a moderator

Re: How to create a page that contains a form instead of a table? [message #1006419 is a reply to message #1004408] Thu, 31 January 2013 05:24 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 676
Registered: October 2011
Senior Member
@Stathis Alexopoulos:
Thanks a lot for your time and your example. Your case might be related to the behavior we have identified in Bug 387625
Re: How to create a page that contains a form instead of a table? [message #1018621 is a reply to message #1006419] Thu, 14 March 2013 03:56 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 676
Registered: October 2011
Senior Member
Urs Beeli provided interesting feedback in this thread (answering a similar question from Andreas Engler).
Re: How to create a page that contains a form instead of a table? [message #1041236 is a reply to message #1018621] Sun, 14 April 2013 17:08 Go to previous messageGo to next message
Andreas Engler is currently offline Andreas Engler
Messages: 10
Registered: January 2013
Junior Member
Hello,

my problem discribed in the thread linked by jeremie, still remains.

I tried to use the nightly build, in hope that way to overcome the issue, but with no success.

Followed the download eclipse-java and add the nightly build way. Created a new project with new rap target. Imported my exisiting Projekt. Am i missing something?

The target definition provided by urs does not work for me, i get errors regarding filechooser as discribed in the linked thread.

Kind regards

Andreas
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 11:03 Go to previous messageGo to next message
Ken Lee is currently offline 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 Sad

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 11:03]

Report message to a moderator

Re: How to create a page that contains a form instead of a table? [message #1062420 is a reply to message #1062417] Fri, 07 June 2013 11:09 Go to previous messageGo to next message
Ken Lee is currently offline Ken Lee
Messages: 97
Registered: March 2012
Member
I've just seen after my submitting my previous post that a patch for bug 385618 has just been pushed to Gerrit.
Re: How to create a page that contains a form instead of a table? [message #1062683 is a reply to message #1062420] Mon, 10 June 2013 07:25 Go to previous message
Ken Lee is currently offline Ken Lee
Messages: 97
Registered: March 2012
Member
As mentioned in my previous post, the E4 bug 385618 makes it impossible to us to provide a solution for this problem in Scout.
The bugfix is planned for Kepler SR1 (4.3.1) that will be released in September this year.

For the time being, I suggest that you use the latest Eclipse 3.8.2 Juno release and update it with Scout 3.9 either from the Scout nightly update site or latest releases update site or the official Kepler update site (RC4 will be published next week).

Please keep it mind that Scout projects generated with Eclipse 4.x and 3.x are different with respect to product files and meta-data. So I recommend to generate a Scout project with Eclipse 3.x if you'd like to use SWT without this bug.

Previous Topic:BrowserField on Mac OS X
Next Topic:renaming/deleting services in scout view
Goto Forum:
  


Current Time: Sat Aug 30 06:35:15 EDT 2014

Powered by FUDForum. Page generated in 0.02227 seconds