Defining the default perspective

Summary

Before PIM 7.1.01 the default perspective of the PIM workbench was defined in the plugin_customization.ini. Now there is another possibility to determine which perspective is the default perspective.

The extension point "com.heiler.ppm.shared.ui.perspectiveAdditions" got a new element - "defaultPerspectiveResolver". By contributing of this element you can affect which perspective will be shown in the workbench by default. In the standard PIM there is a default contribution of the resolver which provides the ID of the "Explorer (items)" perspective:

images/download/attachments/50365530/image2014-6-18_11_33_0.png images/download/attachments/50365530/image2014-6-18_11_33_22.png

The "rank" attribute of the defaultPerspectiveResolver contribution determines which resolver is used. You can contribute many resolver, but only one with the highest rank will be used. The standard resolver has the rank "1". So if you contribute another resolver - use a higher rank for your contribution.

IMPORTANT: do not set the defaultPerspectiveId preference into the plugin_customization.ini if you want to use this extension point. The framework asks the preference first and, if it's set, this one will be used.

Example

A possible custom implementation of the DefaultPerspectiveResolver were a resolver which provides the default perspective ID dependent on the user group of the logged user. Here is an example how to implement such a one resolver.

The source code of the example implementation you can also find in the SDK example (com.heiler.ppm.customizing.ui).

This example implementation uses a simple mapping of the user group identifiers to the corresponding perspective IDs:

/**
* The {@link DefaultPerspectiveResolver} implementation which resolves the ID of the default perspective dependent on
* the user group of the current user.
* @author WMichel
* @since 7.1.01.00
*/
public class UserGroupDefaultPerspectiveResolver implements DefaultPerspectiveResolver
{
public UserGroupDefaultPerspectiveResolver()
{
}
@Override
public String getDefaultPerspectiveId()
{
LoginToken loginToken = LoginManager.getInstance()
.getLoginToken();
Group[] groups = loginToken.getGroups();
// what about users who are in several user groups?
for ( Group group : groups )
{
if ( group instanceof UserGroupPrincipal )
{
UserGroupPrincipal groupPrincipal = ( UserGroupPrincipal ) group;
String identifier = groupPrincipal.getIdentifier();
// in this sample implementation we have just a mapping of "UserGroupIdentifier" to the corresponding "perspectiveId" in the resource bundle
// but this is not really a smart solution ;)
// in you customizing you can certainly implement another kind of mapping
return Messages.getString( identifier );
}
}
return null;
}
}

Then the resolver should be contributed with a higher rank as the standard one:

<extension
point="com.heiler.ppm.shared.ui.perspectiveAdditions">
<defaultPerspectiveResolver
class="com.heiler.ppm.customizing.ui.perspective.UserGroupDefaultPerspectiveResolver"
rank="2">
</defaultPerspectiveResolver>
</extension>