Author: liem_nguyen
Date: 2009-11-26 00:01:55 -0500 (Thu, 26 Nov 2009)
New Revision: 807
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java
Log:
GTNPORTAL-283 Should page break when so many choose a category to add the gadget into
category in Gadget item
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java 2009-11-26
04:31:46 UTC (rev 806)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java 2009-11-26
05:01:55 UTC (rev 807)
@@ -84,6 +84,13 @@
setSelectedCategory(categories.get(0));
}
+ if (getParent() != null)
+ {
+ UIGadgetManagement gadgetManager =
getParent().findFirstComponentOfType(UIGadgetManagement.class);
+ if (gadgetManager != null)
+ gadgetManager.reload();
+ }
+
PortalRequestContext portalContext =
org.exoplatform.portal.webui.util.Util.getPortalRequestContext();
UIPortal uiPortal = org.exoplatform.portal.webui.util.Util.getUIPortal();
MonitorEvent<UIPortal> pnevent = new MonitorEvent<UIPortal>(uiPortal,
"ChangeApplicationList", portalContext);
@@ -122,7 +129,8 @@
{
selectedCategory = category;
ApplicationRegistryService service =
getApplicationComponent(ApplicationRegistryService.class);
- applications = service.getApplications(selectedCategory, new
Util.ApplicationComparator(), new ApplicationType[0]);
+ applications =
+ service.getApplications(selectedCategory, new Util.ApplicationComparator(), new
ApplicationType[0]);
if (applications == null || applications.isEmpty())
{
setSelectedApplication(null);
@@ -196,7 +204,7 @@
}
}
}
-
+
public boolean isShowImport()
{
PortletRequestContext pcontext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
@@ -239,7 +247,7 @@
{
UIApplicationOrganizer uiOrganizer = event.getSource();
ApplicationRegistryService service =
uiOrganizer.getApplicationComponent(ApplicationRegistryService.class);
-
+
service.importAllPortlets();
service.importExoGadgets();
uiOrganizer.reload();
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2009-11-26
04:31:46 UTC (rev 806)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2009-11-26
05:01:55 UTC (rev 807)
@@ -3,8 +3,7 @@
import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.exoplatform.applicationregistry.webui.Util;
-import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
@@ -15,7 +14,7 @@
import org.exoplatform.webui.form.UIFormCheckBoxInput;
import org.exoplatform.webui.form.UIFormInputInfo;
import org.exoplatform.webui.form.UIFormInputSet;
-import org.exoplatform.webui.form.UIFormTableInputSet;
+import org.exoplatform.webui.form.UIFormPageIterator;
import java.util.ArrayList;
import java.util.List;
@@ -30,49 +29,41 @@
@EventConfig(listeners = UICategorySelector.CancelActionListener.class, phase =
Phase.DECODE)})
public class UICategorySelector extends UIForm
{
- private List<ApplicationCategory> categories;
-
private Application application;
private final static String[] ACTIONS = new String[]{"Save",
"Cancel"};
private final static String[] TABLE_COLUMNS = {"choose",
"categoryName"};
- public UICategorySelector()
+ public UICategorySelector() throws Exception
{
+ init();
}
- @Override
- public boolean isRendered()
+ public List<ApplicationCategory> getAllCategories()
{
- ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
- List<ApplicationCategory> categories;
try
{
- categories = appRegService.getApplicationCategories();
+ ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> categories =
appRegService.getApplicationCategories();
+ categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
+ return categories;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
- categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
- if (categories.isEmpty())
- return false;
- return super.isRendered();
}
- /**
- * @see Refresh each render time
- */
@Override
- public void processRender(WebuiRequestContext context) throws Exception
+ public boolean isRendered()
{
- setChildren(null);
- ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
- List<ApplicationCategory> categories =
appRegService.getApplicationCategories(new Util.CategoryComparator());
- categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
+ return (getAllCategories().size() > 0 && super.isRendered());
+ }
- UIFormTableInputSet uiTableInputSet = createUIComponent(UIFormTableInputSet.class,
null, null);
+ public void init() throws Exception
+ {
+ UIFormTableIteratorInputSet uiTableInputSet =
createUIComponent(UIFormTableIteratorInputSet.class, null, null);
uiTableInputSet.setName(getClass().getSimpleName());
uiTableInputSet.setId(getClass().getSimpleName());
uiTableInputSet.setColumns(TABLE_COLUMNS);
@@ -81,6 +72,9 @@
UIFormInputSet uiInputSet;
UIFormCheckBoxInput<Boolean> checkBoxInput;
UIFormInputInfo uiInfo;
+ ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> categories = getAllCategories();
+ List<UIFormInputSet> uiInputSetList = new ArrayList<UIFormInputSet>();
for (ApplicationCategory category : categories)
{
uiInputSet = new UIFormInputSet(category.getName());
@@ -88,23 +82,26 @@
if (application != null)
{
String definitionName = application.getDisplayName().replace(' ',
'_');
- defaultValue =
- appRegService.getApplication(category.getName(), definitionName) != null;
+ defaultValue = appRegService.getApplication(category.getName(),
definitionName) != null;
}
checkBoxInput = new UIFormCheckBoxInput<Boolean>("category_" +
category.getName(), null, defaultValue);
uiInfo = new UIFormInputInfo("categoryName", null,
category.getDisplayName());
uiInputSet.addChild(checkBoxInput);
uiInputSet.addChild(uiInfo);
uiTableInputSet.addChild(uiInputSet);
+ uiInputSetList.add(uiInputSet);
}
-
- super.processRender(context);
+
+ UIFormPageIterator uiIterator =
uiTableInputSet.getChild(UIFormPageIterator.class);
+ LazyPageList<UIFormInputSet> pageList =
+ new LazyPageList<UIFormInputSet>(new
FormInputSetListAccess(uiInputSetList), 5);
+ uiIterator.setPageList(pageList);
}
public String[] getActions()
{
return ACTIONS;
- }
+ }
public void setApplication(Application app)
{
@@ -124,7 +121,7 @@
ApplicationRegistryService appRegService =
selector.getApplicationComponent(ApplicationRegistryService.class);
List<ApplicationCategory> categories =
appRegService.getApplicationCategories();
categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
- UIFormCheckBoxInput<Boolean> chkInput;
+ UIFormCheckBoxInput<Boolean> chkInput;
for (ApplicationCategory category : categories)
{
chkInput = selector.getUIInput("category_" + category.getName());
@@ -163,4 +160,17 @@
}
+ static public class ShowPageActionListener extends
EventListener<UICategorySelector>
+ {
+ public void execute(Event<UICategorySelector> event) throws Exception
+ {
+ UICategorySelector selector = event.getSource();
+ int page =
Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
+ UIFormTableIteratorInputSet inputSet =
selector.getChild(UIFormTableIteratorInputSet.class);
+ inputSet.getUIFormPageIterator().setCurrentPage(page);
+ selector.init();
+ event.getRequestContext().addUIComponentToUpdateByAjax(selector);
+ }
+ }
+
}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2009-11-26
04:31:46 UTC (rev 806)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2009-11-26
05:01:55 UTC (rev 807)
@@ -226,8 +226,8 @@
}
Gadget gadget = gadgetInfo.getGadget();
- UICategorySelector selector = gadgetInfo.getChild(UICategorySelector.class);
-
+ gadgetInfo.removeChild(UICategorySelector.class);
+ UICategorySelector selector = gadgetInfo.addChild(UICategorySelector.class,
null, null);
Application app = new Application();
app.setApplicationName(gadget.getName());
app.setType(ApplicationType.GADGET);
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java 2009-11-26
04:31:46 UTC (rev 806)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java 2009-11-26
05:01:55 UTC (rev 807)
@@ -121,12 +121,8 @@
public void setSelectedGadget(Gadget gadget) throws Exception
{
selectedGadget_ = gadget;
- UIGadgetInfo uiGadgetInfo = getChild(UIGadgetInfo.class);
- if (uiGadgetInfo == null)
- {
- getChildren().clear();
- uiGadgetInfo = addChild(UIGadgetInfo.class, null, null);
- }
+ getChildren().clear();
+ UIGadgetInfo uiGadgetInfo = addChild(UIGadgetInfo.class, null, null);
uiGadgetInfo.setGadget(selectedGadget_);
uiGadgetInfo.getChild(UICategorySelector.class).setRendered(false);
}