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.queries;
18  
19  import org.exoplatform.ecm.webui.selector.UIGroupMemberSelector;
20  import org.exoplatform.webui.config.annotation.ComponentConfig;
21  import org.exoplatform.webui.core.UIPopupWindow;
22  import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
23  import org.exoplatform.webui.ext.manager.UIAbstractManager;
24  
25  /**
26   * Created by The eXo Platform SARL
27   * Author : Dang Van Minh
28   *          minh.dang@exoplatform.com
29   * Dec 29, 2006
30   * 11:27:14 AM
31   */
32  @ComponentConfig(lifecycle = UIContainerLifecycle.class)
33  public class UIQueriesManager extends UIAbstractManager {
34  
35    public UIQueriesManager() throws Exception {
36      addChild(UIQueriesList.class, null, null) ;
37    }
38  
39    public void refresh() throws Exception {
40      update();
41    }
42  
43    public void update() throws Exception {
44      getChild(UIQueriesList.class).refresh(1) ;
45    }
46    public void initFormPopup(String id) throws Exception {
47      removeChildById(id) ;
48      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, id) ;
49      uiPopup.setShowMask(true);
50      uiPopup.setWindowSize(600, 325) ;
51      UIQueriesForm uiForm = createUIComponent(UIQueriesForm.class, null, null) ;
52      uiForm.setIsAddNew(true) ;
53      uiPopup.setUIComponent(uiForm) ;
54      uiPopup.setRendered(true) ;
55      uiPopup.setShow(true) ;
56      uiPopup.setResizable(true) ;
57    }
58  
59    public void initPermissionPopup(String membership) throws Exception {
60      removeChildById("PermissionPopup") ;
61      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "PermissionPopup");
62      uiPopup.setShowMask(true);
63      uiPopup.setWindowSize(560, 250);
64      UIGroupMemberSelector uiECMPermission =
65        createUIComponent(UIGroupMemberSelector.class, null, null) ;
66      uiECMPermission.setSelectedMembership(true);
67      if(membership != null && membership.indexOf(":/") > -1) {
68        String[] arrMember = membership.split(":/") ;
69        uiECMPermission.changeGroup("/" + arrMember[1]) ;
70      }
71      uiPopup.setUIComponent(uiECMPermission);
72      UIQueriesForm uiForm = findFirstComponentOfType(UIQueriesForm.class) ;
73      uiECMPermission.setSourceComponent(uiForm, new String[] {UIQueriesForm.PERMISSIONS}) ;
74      uiPopup.setRendered(true) ;
75      uiPopup.setShow(true) ;
76      uiPopup.setResizable(true) ;
77    }
78  }