uiPage = uiPortalToolPanel.findFirstComponentOfType(UIPage.class);
}
String applicationId = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
Application application = event.getSource().getApplication(applicationId);
ApplicationType appType = application.getType();
String portletName = application.getApplicationName();
// String appGroup = application.getApplicationGroup();
// TODO review windowId for eXoWidget and eXoApplication
UIComponent component = null;
if (ApplicationType.GADGET.equals(appType))
{
UIGadget uiGadget = uiPage.createUIComponent(event.getRequestContext(), UIGadget.class, null, null);
uiGadget.setState(new TransientApplicationState<Gadget>(portletName));
// Set Properties For gadget
int posX = (int)(Math.random() * 400);
int posY = (int)(Math.random() * 200);
uiGadget.getProperties().put(UIApplication.locationX, String.valueOf(posX));
uiGadget.getProperties().put(UIApplication.locationY, String.valueOf(posY));
component = uiGadget;
}
else
{
boolean remote = ApplicationType.WSRP_PORTLET.equals(appType);
UIPortlet uiPortlet = uiPage.createUIComponent(UIPortlet.class, null, null);
CloneApplicationState appState;
Object appId;
if (!remote)
{
appState = new CloneApplicationState<Portlet>(application.getId());
}
else
{
appState = new CloneApplicationState<WSRPState>(application.getId());
}
ApplicationType applicationType = remote ? ApplicationType.WSRP_PORTLET : ApplicationType.PORTLET;
PortletState portletState = new PortletState(appState, applicationType);
uiPortlet.setState(portletState);
uiPortlet.setPortletInPortal(false);
if (atStartup)
{
uiPortlet.getProperties().setProperty("appStatus", "HIDE");
}
if (application != null)
{
String displayName = application.getDisplayName();
if (displayName != null)
{
uiPortlet.setTitle(displayName);
}
else if (portletName != null)
{
uiPortlet.setTitle(portletName);
}
uiPortlet.setDescription(application.getDescription());
List<String> accessPers = application.getAccessPermissions();
String[] accessPermissions = accessPers.toArray(new String[accessPers.size()]);
uiPortlet.setAccessPermissions(accessPermissions);
component = uiPortlet;
}