{
SearchForm form = new SearchForm("appSearchForm");
add(form);
// Construct Data View
final JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
final Locale locale = (((AbstractAdminWebApplication) getApplication()).getPortletRequest()).getLocale();
final ApplicationDataProvider applicationDataProvider = new ApplicationDataProvider(locator);
final PortletDataProvider portletListDataProvider = new PortletDataProvider("j2-admin", locale, locator);
final DataView<ApplicationBean> dataView = new DataView<ApplicationBean>(APP_TABLE, applicationDataProvider)
{
private static final long serialVersionUID = 1L;
protected void populateItem(final Item<ApplicationBean> item)
{
final ApplicationBean pa = item.getModelObject();
Link<ApplicationBean> nameLink = new Link<ApplicationBean>("nameLink")
{
private static final long serialVersionUID = 1L;
public void onClick()
{
String appName = this.get("nameLabel").getDefaultModelObjectAsString();
portletListDataProvider.changeAppName(appName);
try
{
PortletMessaging.publish(
((AbstractAdminWebApplication) getApplication()).getPortletRequest(),
ApplicationsListApplication.PRM_TOPIC,
ApplicationsListApplication.SELECTED_APPLICATION_EVENT,
pa
);
DataView portletView = (DataView) getPage().get(PORTLET_TABLE);
PortletDataProvider pdp = (PortletDataProvider) portletView.getDataProvider();
if (pdp.getSearchMode() == true)
{
pdp.setSearchMode(false);
pdp.refresh();
}
}
catch (NotSerializableException e)
{
logger.error("Message to publish is not serializable.", e);
}
}
};
nameLink.add(new Label("nameLabel", pa.getApplicationName()));
item.add(nameLink);
item.add(new Label("version", pa.getVersion()));
item.add(new Label("path", pa.getPath()));
item.add(new RunningPanel("running", item.getModel()));
item.add(new ActionPanel("actions", item.getModel()));
}
};
dataView.setItemsPerPage(((AbstractAdminWebApplication) getApplication()).getPreferenceValueAsInteger("appRows"));
add(new OrderByLink("appOrderByName", "name", applicationDataProvider, VoidCssProvider.getInstance())
{
private static final long serialVersionUID = 1L;
protected void onSortChanged()
{
if (applicationDataProvider.getOrderBy() == AppOrderBy.NAME_ASC)
{
applicationDataProvider.setOrderBy(AppOrderBy.NAME_DESC);
}
else
{
applicationDataProvider.setOrderBy(AppOrderBy.NAME_ASC);
}
applicationDataProvider.sort();
dataView.setCurrentPage(0);
}
});
add(new OrderByLink("appOrderByVersion", "version", applicationDataProvider, VoidCssProvider.getInstance())
{
private static final long serialVersionUID = 1L;
protected void onSortChanged()
{
if (applicationDataProvider.getOrderBy() == AppOrderBy.VERSION_ASC)
{
applicationDataProvider.setOrderBy(AppOrderBy.VERSION_DESC);
}
else
{
applicationDataProvider.setOrderBy(AppOrderBy.VERSION_ASC);
}
applicationDataProvider.sort();
dataView.setCurrentPage(0);
}
});
add(new OrderByLink("appOrderByPath", "path", applicationDataProvider, VoidCssProvider.getInstance())
{
private static final long serialVersionUID = 1L;
protected void onSortChanged()
{
if (applicationDataProvider.getOrderBy() == AppOrderBy.PATH_ASC)
{
applicationDataProvider.setOrderBy(AppOrderBy.PATH_DESC);
}
else
{
applicationDataProvider.setOrderBy(AppOrderBy.PATH_ASC);
}
applicationDataProvider.sort();
dataView.setCurrentPage(0);
}
});
add(dataView);
add(new PagingNavigator("appNavigator", dataView));
FeedbackPanel feedback = new FeedbackPanel("feedback");
feedback.setEscapeModelStrings(false);
add(feedback);
final DataView<PortletDefinitionBean> portletListView = new DataView<PortletDefinitionBean>(PORTLET_TABLE, portletListDataProvider)
{
private static final long serialVersionUID = 1L;
protected void populateItem(final Item<PortletDefinitionBean> item)
{
final PortletDefinitionBean portletDefinitionBean = item.getModelObject();
Link<PortletDefinitionBean> link = new Link<PortletDefinitionBean>("nameLink", item.getModel())
{
private static final long serialVersionUID = 1L;
@Override
public void onClick()
{
try
{
PortletMessaging.publish(
((AbstractAdminWebApplication) getApplication()).getPortletRequest(),
ApplicationsListApplication.PRM_TOPIC,
ApplicationsListApplication.SELECTED_PORTLET_EVENT,
portletDefinitionBean
);
PortletMessaging
.publish(
((AbstractAdminWebApplication) getApplication()).getPortletRequest(),
ApplicationsListApplication.PRM_TOPIC,
ApplicationsListApplication.SELECTED_APPLICATION_EVENT,
new ApplicationBean(
locator.getPortletRegistry()
.getPortletApplication(portletDefinitionBean.getApplicationName()),
locator
.getPortletFactory()
.isPortletApplicationRegistered(
locator
.getPortletRegistry()
.getPortletApplication(
portletDefinitionBean
.getApplicationName()))));
}