Author: julien(a)jboss.com
Date: 2007-02-28 14:24:22 -0500 (Wed, 28 Feb 2007)
New Revision: 6467
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml
Log:
started to add instance pagination
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2007-02-28
16:16:20 UTC (rev 6466)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2007-02-28
19:24:22 UTC (rev 6467)
@@ -73,52 +73,40 @@
private InstanceContainer instanceContainer;
/** . */
- private String selectedId;
+ private AuthorizationDomainRegistry authorizationDomainRegistry;
/** . */
- private String selectedPlugin;
+ private RoleModule roleModule;
/** . */
- private AuthorizationDomainRegistry authorizationDomainRegistry;
+ private String selectedId;
/** . */
- private RoleModule roleModule;
+ private String selectedPlugin;
/** . */
- private PreferencesBean selectedPreferences;
+ private int selectedFrom;
/** . */
- private AbstractAuthorizationBean auth = new AuthorizationBean();
+ private PreferencesBean selectedPreferences;
/** . */
private Integer selectedRow;
/** . */
- private String sortColumn;
+ private AbstractAuthorizationBean auth = new AuthorizationBean();
- /** . */
- private boolean sortAscending;
- public String getSortColumn()
+ public int getSelectedFrom()
{
- return sortColumn;
+ return selectedFrom;
}
- public void setSortColumn(String sortColumn)
+ public void setSelectedFrom(int selectedFrom)
{
- this.sortColumn = sortColumn;
+ this.selectedFrom = selectedFrom;
}
- public boolean getSortAscending()
- {
- return sortAscending;
- }
-
- public void setSortAscending(boolean sortAscending)
- {
- this.sortAscending = sortAscending;
- }
-
public Integer getSelectedRow()
{
return selectedRow;
@@ -201,13 +189,6 @@
this.selectedPlugin = selectedPlugin;
}
- public void selectPlugin()
- {
- // Get id
- Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
- selectedPlugin = (String)pmap.get("plugin");
- }
-
public AbstractAuthorizationBean getAuth()
{
return auth;
@@ -216,25 +197,43 @@
/** Return an array of all instances known in this container. */
public Collection getInstances()
{
- List instances = new ArrayList();
- for (Iterator i = instanceContainer.getDefinitions().iterator(); i.hasNext();)
- {
- Instance instance = (Instance)i.next();
- instances.add(instance);
- }
+ List instances = new ArrayList(instanceContainer.getDefinitions());
- try
- {
- sortInstances(instances, sortColumn, sortAscending);
- }
- catch (Exception e)
- {
- log.warn("Error during sorting instances list");
- }
+// try
+// {
+// sortInstances(instances, sortColumn, sortAscending);
+// }
+// catch (Exception e)
+// {
+// log.warn("Error during sorting instances list");
+// }
- return instances;
+ //
+ int to = Math.min(selectedFrom + 5, instances.size());
+
+ //
+ return instances.subList(selectedFrom, to);
}
+ public int getInstanceCount()
+ {
+ return instanceContainer.getDefinitions().size();
+ }
+
+ public void selectFrom()
+ {
+ Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedFrom = Integer.parseInt((String)pmap.get("from"));
+ selectedPlugin = null;
+ selectedId = null;
+ }
+
+ public void selectPlugin()
+ {
+ Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedPlugin = (String)pmap.get("plugin");
+ }
+
public void selectInstance()
{
FacesContext ctx = FacesContext.getCurrentInstance();
@@ -247,26 +246,20 @@
public void deleteInstance()
{
- FacesContext ctx = FacesContext.getCurrentInstance();
- ExternalContext ectx = ctx.getExternalContext();
- Map params = ectx.getRequestParameterMap();
- String id = (String)params.get("id");
-
- if (id == null)
- {
- // Error
- }
-
try
{
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ ExternalContext ectx = ctx.getExternalContext();
+ Map params = ectx.getRequestParameterMap();
+ String id = (String)params.get("id");
+
+ //
instanceContainer.destroyDefinition(id);
//
- if (id.equals(selectedId))
- {
- selectedId = null;
- selectedPreferences = null;
- }
+ selectedId = null;
+ selectedPreferences = null;
+ selectedFrom = 0;
}
catch (NoSuchInstanceException e)
{
@@ -274,7 +267,7 @@
}
catch (PortletInvokerException e)
{
- e.printStackTrace(); //To change body of catch statement use File | Settings |
File Templates.
+ e.printStackTrace();
}
}
@@ -284,126 +277,119 @@
selectedPreferences = null;
//
- Instance selectedInstance = getSelectedInstance();
- if (selectedInstance != null)
+ if ("preferences".equals(selectedPlugin))
{
- PreferencesInfo prefsInfo = null;
- try
- {
- prefsInfo = selectedInstance.getPortlet().getInfo().getPreferences();
- }
- catch (PortletInvokerException e)
- {
- log.warn("Couldn't access portlet invoker associated to instance
" + selectedInstance.getId()
- + ". This instance won't be refreshed.\nReason:\n\t" +
e.getLocalizedMessage());
- }
+ Instance selectedInstance = getSelectedInstance();
- if (prefsInfo != null)
+ //
+ if (selectedInstance != null)
{
- RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
-
- //
- PropertyMap prefs;
try
{
- prefs = getSelectedInstance().getProperties();
- }
- catch (PortletInvokerException e)
- {
- throw new Error("Handle me gracefully please", e);
- }
+ PreferencesInfo prefsInfo =
selectedInstance.getPortlet().getInfo().getPreferences();
+ if (prefsInfo != null)
+ {
+ RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
+ PropertyMap prefs = getSelectedInstance().getProperties();
- //
- int index = 0;
- for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext(); index++)
- {
- String key = (String)i.next();
+ //
+ int index = 0;
+ for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext();
index++)
+ {
+ String key = (String)i.next();
- // Get info for this key
-// PreferenceInfo info = prefsInfo.getPreference(key);
-// boolean readOnly = info.isReadOnly();
- boolean readOnly = false;
-// Value value = info.getValue();
+ // Get info for this key
+ // PreferenceInfo info = prefsInfo.getPreference(key);
+ // boolean readOnly = info.isReadOnly();
+ boolean readOnly = false;
+ // Value value = info.getValue();
- // Get value from the state
- Value value = prefs.getProperty(key);
+ // Get value from the state
+ Value value = prefs.getProperty(key);
- //
- Row row = model.getRow(index);
- row.setReadOnly(readOnly);
+ //
+ Row row = model.getRow(index);
+ row.setReadOnly(readOnly);
- //
- Cell cell = row.getCell();
- cell.setHandback("" + i);
- cell.setValue(value.asStringArray());
+ //
+ Cell cell = row.getCell();
+ cell.setHandback("" + i);
+ cell.setValue(value.asStringArray());
- //
- row.setHandback(key);
- row.setKey(key);
- row.setName("Description");
- row.setReadOnly(false);
- row.setValue(value.asStringArray());
- }
+ //
+ row.setHandback(key);
+ row.setKey(key);
+ row.setName("Description");
+ row.setReadOnly(false);
+ row.setValue(value.asStringArray());
+ }
- //
- selectedPreferences = new PreferencesBean(model);
+ //
+ selectedPreferences = new PreferencesBean(model);
- //
- if (selectedRow != null)
- {
- selectedPreferences.selectRow(selectedRow);
- }
- }
- }
- }
-
- public static void sortInstances(List instances, final String column, final boolean
ascending)
- {
- Comparator comparator = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- if (column == null)
- {
- return 0;
- }
- if (column.equals("id"))
- {
- Instance i1 = (Instance)((Object[])o1)[0];
- Instance i2 = (Instance)((Object[])o2)[0];
- return ascending ? i1.getId().compareToIgnoreCase(i2.getId()) :
i2.getId()
- .compareToIgnoreCase(i1.getId());
- }
- if (column.equals("portlet"))
- {
- Portlet p1 = (Portlet)((Object[])o1)[1];
- Portlet p2 = (Portlet)((Object[])o2)[1];
-
- LocalizedString displayName =
p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
- FacesContext ctx = FacesContext.getCurrentInstance();
- Locale locale = ctx.getExternalContext().getRequestLocale();
- String name1 = displayName.getString(locale, true);
- displayName = p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
- String name2 = displayName.getString(locale, true);
-
- if (name1 == null || name2 == null)
- {
- return 0;
+ //
+ if (selectedRow != null)
+ {
+ selectedPreferences.selectRow(selectedRow);
+ }
}
-
- return ascending ? name1.compareToIgnoreCase(name2) : name2
- .compareToIgnoreCase(name1);
}
-
- else
+ catch (PortletInvokerException e)
{
- return 0;
+ log.warn("Couldn't access portlet invoker associated to instance
" + selectedInstance.getId()
+ + ". This instance won't be refreshed.\nReason:\n\t" +
e.getLocalizedMessage());
}
}
- };
- Collections.sort(instances, comparator);
+ }
}
+// public static void sortInstances(List instances, final String column, final boolean
ascending)
+// {
+// Comparator comparator = new Comparator()
+// {
+// public int compare(Object o1, Object o2)
+// {
+// if (column == null)
+// {
+// return 0;
+// }
+// if (column.equals("id"))
+// {
+// Instance i1 = (Instance)((Object[])o1)[0];
+// Instance i2 = (Instance)((Object[])o2)[0];
+// return ascending ? i1.getId().compareToIgnoreCase(i2.getId()) :
i2.getId()
+// .compareToIgnoreCase(i1.getId());
+// }
+// if (column.equals("portlet"))
+// {
+// Portlet p1 = (Portlet)((Object[])o1)[1];
+// Portlet p2 = (Portlet)((Object[])o2)[1];
+//
+// LocalizedString displayName =
p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+// FacesContext ctx = FacesContext.getCurrentInstance();
+// Locale locale = ctx.getExternalContext().getRequestLocale();
+// String name1 = displayName.getString(locale, true);
+// displayName =
p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+// String name2 = displayName.getString(locale, true);
+//
+// if (name1 == null || name2 == null)
+// {
+// return 0;
+// }
+//
+// return ascending ? name1.compareToIgnoreCase(name2) : name2
+// .compareToIgnoreCase(name1);
+// }
+//
+// else
+// {
+// return 0;
+// }
+// }
+// };
+// Collections.sort(instances, comparator);
+// }
+
public class AuthorizationBean extends AbstractAuthorizationBean
{
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml 2007-02-28
16:16:20 UTC (rev 6466)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml 2007-02-28
19:24:22 UTC (rev 6467)
@@ -47,6 +47,9 @@
</c:forEach>
</tbody>
</table>
+ <c:forEach begin="0" end="#{instancemgr.instanceCount}"
step="5" var="index">
+ <h:commandLink action="#{instancemgr.selectFrom}"><f:param
name="from" value="#{index}"/><h:outputText
value="#{index}"/></h:commandLink>
+ </c:forEach>
</h:form>
Show replies by date