View Javadoc
1   /*
2    * Copyright (C) 2003-2007 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.component.admin.unlock;
18  
19  import org.exoplatform.webui.config.annotation.ComponentConfig;
20  import org.exoplatform.webui.core.UIPopupWindow;
21  import org.exoplatform.webui.ext.manager.UIAbstractManager;
22  
23  /**
24   * Created by The eXo Platform SARL
25   * Author : Dang Van Minh
26   *          minh.dang@exoplatform.com
27   * Dec 29, 2006
28   * 11:27:14 AM
29   */
30  @ComponentConfig(template = "system:/groovy/webui/core/UITabPane.gtmpl")
31  public class UIUnLockManager extends UIAbstractManager {
32  
33    public UIUnLockManager() throws Exception {
34      addChild(UILockNodeList.class, null, null).setRendered(true);
35      addChild(UILockHolderContainer.class, null, null).setRendered(false);
36    }
37  
38    public void refresh() throws Exception {
39      update();
40    }
41  
42    public void update() throws Exception{
43      UILockNodeList uiLockNodeList = getChild(UILockNodeList.class);
44      uiLockNodeList.refresh(uiLockNodeList.getUIPageIterator().getCurrentPage());
45      UILockHolderContainer uiHolderContainer = getChild(UILockHolderContainer.class);
46      if (uiHolderContainer != null) {
47        UILockHolderList uiLockHolderList = uiHolderContainer.getChild(UILockHolderList.class);
48        uiLockHolderList.refresh(uiLockHolderList.getUIPageIterator().getCurrentPage());
49      }
50    }
51  
52    public void initFormPopup(String id) throws Exception {
53      removeChildById(id);
54      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, id);
55      uiPopup.setShowMask(true);
56      uiPopup.setWindowSize(600, 500);
57      UIUnLockForm uiForm = createUIComponent(UIUnLockForm.class, null, null);
58      uiPopup.setUIComponent(uiForm);
59      uiPopup.setRendered(true);
60      uiPopup.setShow(true);
61      uiPopup.setResizable(true);
62    }
63  
64    public void initPermissionPopup(String membership) throws Exception {
65      removeChildById("PermissionPopup");
66      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "PermissionPopup");
67      uiPopup.setShowMask(true);
68      uiPopup.setWindowSize(560, 300);
69      UIPermissionSelector uiECMPermission =
70        createUIComponent(UIPermissionSelector.class, null, "GroupsOrUsersBrowse");
71      uiECMPermission.setSelectedMembership(true);
72      if(membership != null && membership.indexOf(":/") > -1) {
73        String[] arrMember = membership.split(":/");
74        uiECMPermission.setCurrentPermission("/" + arrMember[1]);
75      }
76      uiPopup.setUIComponent(uiECMPermission);
77      UIUnLockForm uiForm = findFirstComponentOfType(UIUnLockForm.class);
78      uiECMPermission.setSourceComponent(uiForm, new String[] {UIUnLockForm.GROUPS_OR_USERS});
79      uiPopup.setRendered(true);
80      uiPopup.setShow(true);
81      uiPopup.setResizable(true);
82    }
83  }