Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Page templates(How to reuse pages?)
Page templates [message #1402861] Thu, 17 July 2014 21:29 Go to next message
Dennis Geesen is currently offline Dennis GeesenFriend
Messages: 46
Registered: June 2014
Member
Hi there,

I have the following scenario. I want to have different pages for an outline where the difference between the pages is only the loaded data and not the layout of the table/columns.
So one simple example would be a page showing the users. So i want to reuse this page, e.g.:
Users
|- All users
|- Only active users
|- Female users
|- Male users


So, I extracted an AbstractUserPage (like a template) and used it as the superclass for the four pages and each page overrides the execLoadTableData to load its appropriate data. This seems to work, but now I cannot change the table/columns of AbstractUserPage (to get all changes also for the four implementations) within the scout explorer.
Is this the right approach for page templates or is there another possibility, so I have the full scout explorer support? I think it is very similar to form field templates, but for pages Smile

Re: Page templates [message #1402875 is a reply to message #1402861] Fri, 18 July 2014 05:38 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 971
Registered: October 2011
Senior Member
Dennis Geesen wrote on Thu, 17 July 2014 23:29
So, I extracted an AbstractUserPage (like a template) and used it as the superclass for the four pages and each page overrides the execLoadTableData to load its appropriate data. This seems to work, but now I cannot change the table/columns of AbstractUserPage (to get all changes also for the four implementations) within the scout explorer.
Is this the right approach for page templates or is there another possibility, so I have the full scout explorer support? I think it is very similar to form field templates, but for pages Smile


I think this is a brilliant idea. It is consistent with the pattern used for fields.

I am afraid that every possibility offered by the java language and supported by Scout RT is not always supported by the Scout perspective.
You should open a enhancement request Bug in bugzilla.


I really like you "template" and class overriding approach, but you asked if there is an other possibility.

Some applications I know are using a "presentation type" approach.

@PageData(UsersTablePageData.class)
public class UsersTablePage extends AbstractPageWithTable<Table> {

  public enum PresentationType {
    ALL_USERS,
    ONLY_ACTIVE_USERS,
    FEMALE_USERS,
    MALE_USERS
  }

  private final PresentationType m_presentationType;

  /**
   * @param presentationType
   */
  public UsersTablePage(PresentationType presentationType) {
    super(presentationType.toString());
    m_presentationType = presentationType;
  }

  @Override
  protected void execLoadData(SearchFilter filter) throws ProcessingException {
    UsersTablePageData pageData;
    IStandardOutlineService service = SERVICES.getService(IStandardOutlineService.class);
    switch (m_presentationType) {
      case ALL_USERS:
        //import page data for all users:
        pageData = service.getAllUsers();
        break;
      case ONLY_ACTIVE_USERS:
        //import page data for active users:
        pageData = service.getActiveUsers();
        break;
      case FEMALE_USERS:
        //import page data for female users:
        pageData = service.getFemaleUsers();
        break;
      case MALE_USERS:
        //import page data for male users:
        pageData = service.getMaleUsers();
        break;
      default:
        throw new IllegalStateException("Unexpected presentation type");
    }
    importPageData(pageData);
  }
  
  //...
}


Notice that the userPreferenceContext will be set by calling super(String) in the constructor. This is important because otherwise, Scout RT will not have enough information to distinguish the page instances especially if they are in the same NodePage (for bookmarks, table preferences...).

.
Re: Page templates [message #1402897 is a reply to message #1402875] Fri, 18 July 2014 09:29 Go to previous messageGo to next message
Dennis Geesen is currently offline Dennis GeesenFriend
Messages: 46
Registered: June 2014
Member
Thanks for your answer.

First, I created an enhancement bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=439873

Second, a question according to your "presentation type approach": Am I right that you also have four subpages that implement the UsersTablePage to pass the PresentationType parameter in the constructor? Or where do you set the PresentationType and how are the different pages linked to the outline?
Are you setting this in the execCreateChildPages of the outline?

[Updated on: Fri, 18 July 2014 09:31]

Report message to a moderator

Re: Page templates [message #1402913 is a reply to message #1402897] Fri, 18 July 2014 10:37 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 971
Registered: October 2011
Senior Member
Dennis Geesen wrote on Fri, 18 July 2014 11:29
Second, a question according to your "presentation type approach": Am I right that you also have four subpages that implement the UsersTablePage to pass the PresentationType parameter in the constructor? Or where do you set the PresentationType and how are the different pages linked to the outline?
Are you setting this in the execCreateChildPages of the outline?


You do not need to create create subpages. Here is how the outline could look like:

public class StandardOutline extends AbstractExtensibleOutline {

  @Override
  protected String getConfiguredTitle() {
    return TEXTS.get("StandardOutline");
  }

  @Override
  protected void execCreateChildPages(Collection<IPage> pageList) throws ProcessingException {
    UsersTablePage allUsersTablePage = new UsersTablePage(PresentationType.ALL_USERS);
    pageList.add(allUsersTablePage);
    UsersTablePage onlyActiveUsersTablePage = new UsersTablePage(PresentationType.ONLY_ACTIVE_USERS);
    pageList.add(onlyActiveUsersTablePage);
    UsersTablePage femaleUsersTablePage = new UsersTablePage(PresentationType.FEMALE_USERS);
    pageList.add(femaleUsersTablePage);
    UsersTablePage maleUsersTablePage = new UsersTablePage(PresentationType.MALE_USERS);
    pageList.add(maleUsersTablePage);
  }
}


You do not have a proper SDK support for this pattern either.
Re: Page templates [message #1402943 is a reply to message #1402913] Fri, 18 July 2014 14:54 Go to previous message
Dennis Geesen is currently offline Dennis GeesenFriend
Messages: 46
Registered: June 2014
Member
ok, that is what I thought too, because it is also a nice approach.
However, I have used it as follows:

The main class for all Users:
public class UsersTablePage extends AbstractPageWithTable<Table>{
...
  protected PresentationType getPresentationType(){
    return PresentationType.ALL_USERS;
  }
...
}



the getPresentationType is used in the execLoadTableData to

Then i derived from this class and override the method:

public class ActiveUsersTablePage extends UsersTablePage{
...
  @Override
  protected PresentationType getPresentationType(){
    return PresentationType.ACTIVE_USERS;
  }
...
}


There are two benefits:
1) you can edit the UsersTablePage class via the SDK and you get all changes also in the derived pages.
2) you can override and set other configuration data (e.g. like title, icon id and so on) using the SDK. The table is the only thing that is missing.





Previous Topic:Target and Tycho
Next Topic:Value Field / Error handling / invalid value
Goto Forum:
  


Current Time: Thu Jul 02 12:40:34 GMT 2015

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

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