[gatein-commits] gatein SVN: r544 - in portal/trunk: portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Nov 10 05:21:54 EST 2009
Author: liem_nguyen
Date: 2009-11-10 05:21:54 -0500 (Tue, 10 Nov 2009)
New Revision: 544
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
GTNPORTAL-152 In the portlet/gadget details view, display the categories in which the application is
Added: 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 (rev 0)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2009-11-10 10:21:54 UTC (rev 544)
@@ -0,0 +1,136 @@
+package org.exoplatform.applicationregistry.webui.component;
+
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.form.UIForm;
+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 java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : LiemNC Email:ncliam at gmail.com
+ * November 09, 2009
+ */
+ at ComponentConfig(template = "system:/groovy/webui/form/UIForm.gtmpl", lifecycle = UIFormLifecycle.class, events = {
+ @EventConfig(listeners = UICategorySelector.SaveActionListener.class),
+ @EventConfig(listeners = UICategorySelector.CloseActionListener.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() throws Exception
+ {
+ ApplicationRegistryService appRegService = getApplicationComponent(ApplicationRegistryService.class);
+ categories = appRegService.getApplicationCategories();
+ categories = categories != null ? categories : new ArrayList<ApplicationCategory>();
+ }
+
+ public void setup(Application app) throws Exception
+ {
+ setChildren(null);
+ this.application = app;
+
+ UIFormTableInputSet uiTableInputSet = createUIComponent(UIFormTableInputSet.class, null, null);
+ uiTableInputSet.setName(getClass().getSimpleName());
+ uiTableInputSet.setId(getClass().getSimpleName());
+ uiTableInputSet.setColumns(TABLE_COLUMNS);
+ addChild(uiTableInputSet);
+
+ UIFormInputSet uiInputSet;
+ UIFormCheckBoxInput<Boolean> checkBoxInput;
+ UIFormInputInfo uiInfo;
+
+ ApplicationRegistryService appRegService = getApplicationComponent(ApplicationRegistryService.class);
+ for (ApplicationCategory category : categories)
+ {
+ uiInputSet = new UIFormInputSet(category.getName());
+ boolean defaultValue = appRegService.getApplication(category.getName(), app.getApplicationName()) != 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);
+ }
+ }
+
+ public String[] getActions()
+ {
+ return ACTIONS;
+ }
+
+ public List<ApplicationCategory> getCategories()
+ {
+ return this.categories;
+ }
+
+ public Application getApplication()
+ {
+ return this.application;
+ }
+
+ static public class SaveActionListener extends EventListener<UICategorySelector>
+ {
+ public void execute(Event<UICategorySelector> event) throws Exception
+ {
+ UICategorySelector selector = event.getSource();
+ List<ApplicationCategory> categories = selector.getCategories();
+ UIFormCheckBoxInput<Boolean> chkInput;
+ ApplicationRegistryService appRegService = selector.getApplicationComponent(ApplicationRegistryService.class);
+ for (ApplicationCategory category : categories)
+ {
+ chkInput = selector.getUIInput("category_" + category.getName());
+ if (chkInput != null && chkInput.isChecked())
+ {
+ appRegService.save(category, cloneApplication(selector.getApplication()));
+ }
+ }
+ UIGadgetInfo gadgetInfo = selector.getParent();
+ gadgetInfo.getChild(UICategorySelector.class).setRendered(false);
+ event.getRequestContext().addUIComponentToUpdateByAjax(gadgetInfo);
+ }
+
+ private Application cloneApplication(Application app)
+ {
+ Application newApp = new Application();
+ newApp.setApplicationName(app.getApplicationName());
+ newApp.setDisplayName(app.getDisplayName());
+ newApp.setApplicationType(app.getApplicationType());
+ newApp.setApplicationGroup(app.getApplicationGroup());
+ newApp.setDescription(app.getDescription());
+ newApp.setAccessPermissions(app.getAccessPermissions());
+ newApp.setUri(app.getUri());
+ return newApp;
+ }
+ }
+
+ static public class CloseActionListener extends EventListener<UICategorySelector>
+ {
+ public void execute(Event<UICategorySelector> event) throws Exception
+ {
+ UICategorySelector selector = event.getSource();
+ UIGadgetInfo gadgetInfo = selector.getParent();
+ gadgetInfo.getChild(UICategorySelector.class).setRendered(false);
+ event.getRequestContext().addUIComponentToUpdateByAjax(gadgetInfo);
+ }
+
+ }
+
+}
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-10 10:11:57 UTC (rev 543)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2009-11-10 10:21:54 UTC (rev 544)
@@ -24,6 +24,9 @@
import org.exoplatform.application.gadget.GadgetRegistryService;
import org.exoplatform.application.gadget.Source;
import org.exoplatform.application.gadget.SourceStorage;
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
import org.exoplatform.portal.webui.application.GadgetUtil;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.application.ApplicationMessage;
@@ -32,14 +35,16 @@
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.List;
/**
* Created by The eXo Platform SAS
@@ -50,14 +55,17 @@
@ComponentConfig(template = "app:/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl", events = {
@EventConfig(listeners = UIGadgetInfo.RefreshActionListener.class),
@EventConfig(listeners = UIGadgetInfo.CopyActionListener.class),
- @EventConfig(listeners = UIGadgetInfo.EditActionListener.class)})
-public class UIGadgetInfo extends UIComponent
+ @EventConfig(listeners = UIGadgetInfo.EditActionListener.class),
+ @EventConfig(listeners = UIGadgetInfo.ShowCategoriesActionListener.class)})
+public class UIGadgetInfo extends UIContainer
{
private Gadget gadget_;
- public UIGadgetInfo()
+ public UIGadgetInfo() throws Exception
{
+ UICategorySelector categorySelector = addChild(UICategorySelector.class, null, null);
+ categorySelector.setRendered(false);
}
public Gadget getGadget()
@@ -82,6 +90,29 @@
return null;
}
+ public String getCategorieNames() throws Exception
+ {
+ ApplicationRegistryService appRegService = getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> allCategories = appRegService.getApplicationCategories();
+ List<String> nameList = new ArrayList<String>();
+
+ for (ApplicationCategory category : allCategories)
+ {
+ if (appRegService.getApplication(category.getName(), gadget_.getName()) != null)
+ {
+ nameList.add(category.getDisplayName());
+ }
+ }
+ StringBuffer names = new StringBuffer("");
+ for (String name : nameList)
+ {
+ names.append(name);
+ if (name != nameList.get(nameList.size() - 1))
+ names.append(", ");
+ }
+ return names.toString();
+ }
+
static public class RefreshActionListener extends EventListener<UIGadgetInfo>
{
@@ -179,4 +210,31 @@
}
+ static public class ShowCategoriesActionListener extends EventListener<UIGadgetInfo>
+ {
+ @Override
+ public void execute(Event<UIGadgetInfo> event) throws Exception
+ {
+ UIGadgetInfo gadgetInfo = event.getSource();
+ Gadget gadget = gadgetInfo.getGadget();
+ UICategorySelector selector = gadgetInfo.getChild(UICategorySelector.class);
+
+ Application app = new Application();
+ app.setApplicationName(gadget.getName());
+ app.setApplicationGroup(GadgetApplication.EXO_GADGET_GROUP);
+ app.setApplicationType(org.exoplatform.web.application.Application.EXO_GADGET_TYPE);
+ app.setDisplayName(gadget.getTitle());
+ app.setUri(gadget.getUrl());
+ String description =
+ (gadget.getDescription() == null || gadget.getDescription().length() < 1) ? gadget.getName() : gadget
+ .getDescription();
+ app.setDescription(description);
+ app.setAccessPermissions(new ArrayList<String>());
+
+ selector.setup(app);
+ selector.setRendered(true);
+ event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
+ }
+ }
+
}
\ No newline at end of file
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2009-11-10 10:11:57 UTC (rev 543)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2009-11-10 10:21:54 UTC (rev 544)
@@ -119,10 +119,19 @@
UIGadgetInfo.label.viewUrl=View URL:
UIGadgetInfo.label.editUrl=Edit URL:
UIGadgetInfo.label.reference=Reference:
+UIGadgetInfo.label.categories=Categories:
+UIGadgetInfo.label.categories.guide=You must add this gadget into categories to be able used in Dashboard.
+UIGadgetInfo.label.categories.clickHere=Click here to add into categories
UIGadgetInfo.title.refresh=Refresh information
UIGadgetInfo.title.editGadget=Edit Gadget
UIGadgetInfo.title.copy=Copy this gadget to local repository
UIGadgetInfo.msg.gadgetNotExist=Can not execute action on the gadget that no longer in database.
+
+UICategorySelector.header.choose=Choose
+UICategorySelector.header.categoryName=Category's name
+UICategorySelector.action.Save=Save
+UICategorySelector.action.Cancel=Cancel
+
## org.exoplatform.applicationregistry.webui.component.UIAddGadget
UIAddGadget.action.Add=Add
UIAddGadget.action.Cancel=#{word.cancel}
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2009-11-10 10:11:57 UTC (rev 543)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2009-11-10 10:21:54 UTC (rev 544)
@@ -1,6 +1,10 @@
<%
+ import org.exoplatform.applicationregistry.webui.component.UICategorySelector;
+
def gadget = uicomponent.getGadget();
+ boolean selectorRender = uicomponent.getChild(UICategorySelector.class).isRendered();
String srcBGError = "/eXoResources/skin/sharedImages/Icon80x80/DefaultPortlet.png";
+ String categoryNames = uicomponent.getCategorieNames();
%>
<div class="UIGadgetInfo" id="$uicomponent.id">
<div class="UIBreadcumb">
@@ -45,9 +49,31 @@
<table>
<tr>
<td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.reference")%></td>
- <td class="RightLabel"><%= gadget.getReferenceUrl() %></td>
+ <td class="RightLabel">
+ <%= gadget.getReferenceUrl() %>
+ </td>
</tr>
</table>
+ <table>
+ <tr>
+ <td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.categories")%></td>
+ <td class="RightLabel">$categoryNames
+ <% if (categoryNames.equals("")) { %>
+ <%=_ctx.appRes("UIGadgetInfo.label.categories.guide")%><br/>
+ <% if (!selectorRender) { %>
+ <a href="#" onclick="<%= uicomponent.event("ShowCategories") %>" style="color:red;text-decoration:underline;">
+ <%=_ctx.appRes("UIGadgetInfo.label.categories.clickHere")%>
+ </a>
+ <% } else { %>
+ <div>
+ <% uicomponent.renderChildren() %>
+ </div>
+ <%}%>
+ <%}%>
+
+ </td>
+ </tr>
+ </table>
</div>
</div>
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-11-10 10:11:57 UTC (rev 543)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-11-10 10:21:54 UTC (rev 544)
@@ -22,7 +22,6 @@
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
import org.exoplatform.portal.config.model.Properties;
More information about the gatein-commits
mailing list