View Javadoc
1   package org.exoplatform.calendar.webui.popup;
2   
3   import org.exoplatform.calendar.util.CalendarUtils;
4   import org.exoplatform.calendar.webui.popup.UISharedForm.Permission;
5   import org.exoplatform.webui.config.annotation.ComponentConfig;
6   import org.exoplatform.webui.core.UIContainer;
7   import org.exoplatform.webui.core.lifecycle.Lifecycle;
8   
9   /**
10   * a grid that contains a list of permission entry
11   *
12   * @author Created by The eXo Platform SEA
13   *         <br>Anh-Tu Nguyen
14   *         <br><a href="mailto:tuna@exoplatform.com">tuna@exoplatform.com</a>
15   *         <br>Jan 25, 2013
16   */
17  @ComponentConfig(
18      lifecycle = Lifecycle.class,
19      template  = "app:/templates/calendar/webui/UIPopup/UIPermissionGrid.gtmpl"
20  )
21  public class UIPermissionGrid extends UIContainer
22  {
23    public UIPermissionGrid(String componentId)
24    {
25      setId(componentId);
26      setComponentConfig(getClass(), null);
27    }
28  
29    /**
30     * add entry to grid to display
31     *
32     * @param aPermission
33     * @throws Exception
34     */
35    public void addEntry(Permission aPermission) throws Exception
36    {
37      UIPermissionEntry permissionEntry = getChildById(UISharedForm.PERMISSION_ENTRY + CalendarUtils.DOT + aPermission.hashCode());
38      if (permissionEntry == null)
39      {
40        permissionEntry = new UIPermissionEntry(aPermission);
41        addChild(permissionEntry);
42      }
43      else /* probably the entry is disabled */
44        permissionEntry.setRendered(true);
45    }
46  
47    /**
48     * un-display a permission entry
49     */
50    public void removeEntry(String permissionId)
51    {
52      UIPermissionEntry permissionEntry = getChildById(UISharedForm.PERMISSION_ENTRY + CalendarUtils.DOT + Math.abs(permissionId.hashCode()));
53      if (permissionEntry != null)
54      {
55        permissionEntry.setRendered(false);
56      }
57    }
58  }