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.action;
18  
19  import javax.jcr.nodetype.NodeType;
20  import javax.jcr.nodetype.PropertyDefinition;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.exoplatform.webui.config.annotation.ComponentConfig;
24  import org.exoplatform.webui.core.UIComponent;
25  import org.exoplatform.webui.core.UIPopupWindow;
26  import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
27  import org.exoplatform.webui.ext.manager.UIAbstractManager;
28  
29  /**
30   * Created by The eXo Platform SARL
31   * Author : pham tuan
32   *          phamtuanchip@yahoo.de
33   * September 20, 2006
34   * 16:37:15 AM
35   */
36  @ComponentConfig(
37      lifecycle = UIContainerLifecycle.class
38  )
39  
40  public class UIActionManager extends UIAbstractManager {
41  
42    public UIActionManager() throws Exception {
43      addChild(UIActionTypeList.class, null, null) ;
44    }
45  
46    public void refresh() throws Exception {
47      UIActionTypeList list = getChild(UIActionTypeList.class) ;
48      list.refresh(1);
49    }
50    
51    public String getScriptLabel(NodeType nodeType) throws Exception {
52      if(nodeType.isNodeType("exo:scriptAction")) {
53        PropertyDefinition[] arrProperties = nodeType.getPropertyDefinitions();
54        for(PropertyDefinition property : arrProperties) {
55          if(property.getName().equals("exo:scriptLabel")) {
56            return property.getDefaultValues()[0].getString();
57          }
58        }
59      }
60      return StringUtils.EMPTY;
61    }  
62  
63    public void initPopup(UIComponent uiActionForm, int width) throws Exception {
64      UIPopupWindow uiPopup = getChild(UIPopupWindow.class) ;
65      if(uiPopup == null) {
66        uiPopup = addChild(UIPopupWindow.class, null, "ActionPopup") ;
67        uiPopup.setUIComponent(uiActionForm) ;
68        uiPopup.setWindowSize(width, 0) ;
69        uiPopup.setShow(true) ;
70        return ;
71      }
72      uiPopup.setRendered(true) ;
73      uiPopup.setShow(true) ;
74      uiPopup.setResizable(true) ;
75    }
76  }