The Case for Profiles (Part 2)
By Geertjan-Oracle on Jun 09, 2011
Going on from yesterday, let's start by looking at the first scenario. If you log on as an administrator, you need to be able to configure profiles, each consisting of a window layout, for standard users. If you log on as a standard user, you shouldn't be able to change the window layout, in fact, the window layout should be assigned to you based on who you are.
We'll not deal with all of the above scenario this time round, just the first part. I.e., based on your login, you can be enabled to configure the window layout.
Here's the login:
If the above is entered, i.e., admin/admin, the following is shown, i.e., the Profiles menu, and the windows can all be moved around to create profiles (i.e., "perspectives", introduced in yesterday's blog entry):
However, if "admin/admin" is not entered, there's no "Profiles" menu and the window layout is fixed, i.e., notice no "x" buttons to close the windows, for example:
How to configure your application to allow for the above two different set ups? Here's the key, in the "branding" folder of the application, create two new Bundle.properties files, next to the existing "Bundle.properties" file that contains a list of properties for enabling/disabling window system features:
In the "Bundle_student_admin.properties", I have this:
Editor.TopComponent.Closing.Enabled=true Splitter.Respect.MinimumSize.Enabled=true TopComponent.DragAndDrop.Enabled=true TopComponent.Maximization.Enabled=true TopComponent.Resizing.Enabled=true TopComponent.Sliding.Enabled=true TopComponent.Undocking.Enabled=true View.TopComponent.Closing.Enabled=true
In the other one, i.e., "Bundle_student_standard.properties", I have the same keys, all set to "false".
Now I create a login screen, as discussed elsewhere, inject a layer, as also discussed elsewhere, to dynamically add the Profiles menu for the administrator, and then I switch branding. So, here's the only new bit:
The above two are called depending on whether "admin/admin" is set (the first one) or not (the second one). That's all, now your branding is set dynamically and the window layout is either feature-rich or fixed.
Next, we'll look at the perspectives created by Anuradha's module, how to persist them into a database, and how to match them to a user and load them on demand.