public static class ShowCategoriesActionListener extends EventListener<UIPortletInfo> {
@Override
public void execute(Event<UIPortletInfo> event) throws Exception {
UIPortletInfo uiPortletInfo = event.getSource();
PortletExtra portlet = uiPortletInfo.getPortlet();
uiPortletInfo.removeChild(UICategorySelector.class);
UICategorySelector selector = uiPortletInfo.addChild(UICategorySelector.class, null, CATEGORY_ID);
Application app = new Application();
app.setApplicationName(portlet.getName());
// I really hate the fact that the code to create Applications is spread all over and doesn't properly deal with
// application types
if (portlet.isRemote()) {
app.setType(ApplicationType.WSRP_PORTLET);
} else {
app.setType(ApplicationType.PORTLET);
}
app.setDisplayName(portlet.getDisplayName());
app.setContentId(portlet.getId());
app.setAccessPermissions(new ArrayList<String>());
selector.setApplication(app);
selector.setRendered(true);
}