View Javadoc
1   /***************************************************************************
2    * Copyright (C) 2003-2009 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   **************************************************************************/
18  package org.exoplatform.ecm.webui.component.admin.manager;
19  
20  import javax.jcr.AccessDeniedException;
21  
22  import org.exoplatform.ecm.webui.component.admin.UIECMAdminPortlet;
23  import org.exoplatform.ecm.webui.component.admin.UIECMAdminWorkingArea;
24  import org.exoplatform.ecm.webui.component.admin.listener.UIECMAdminControlPanelActionListener;
25  import org.exoplatform.ecm.webui.component.admin.templates.clv.UICLVTemplatesManager;
26  import org.exoplatform.web.application.ApplicationMessage;
27  import org.exoplatform.webui.config.annotation.ComponentConfig;
28  import org.exoplatform.webui.config.annotation.EventConfig;
29  import org.exoplatform.webui.event.Event;
30  import org.exoplatform.webui.exception.MessageException;
31  import org.exoplatform.webui.ext.manager.UIAbstractManager;
32  import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
33  
34  /**
35   * Created by The eXo Platform SARL
36   * Author : Dang Van Minh
37   *          minh.dang@exoplatform.com
38   * Jan 22, 2013
39   * 9:48:15 AM  
40   */
41  @ComponentConfig(
42          events = {
43            @EventConfig(listeners = UICLVTemplatesManagerComponent.UICLVTemplatesManagerActionListener.class)
44          }
45      )
46  public class UICLVTemplatesManagerComponent extends UIAbstractManagerComponent {
47  
48    public static class UICLVTemplatesManagerActionListener extends UIECMAdminControlPanelActionListener<UICLVTemplatesManagerComponent> {
49      public void processEvent(Event<UICLVTemplatesManagerComponent> event) throws Exception {
50        UIECMAdminPortlet portlet = event.getSource().getAncestorOfType(UIECMAdminPortlet.class);
51        UIECMAdminWorkingArea uiWorkingArea = portlet.getChild(UIECMAdminWorkingArea.class);
52        try {
53          uiWorkingArea.getChild(UICLVTemplatesManager.class).refresh() ;
54          uiWorkingArea.setChild(UICLVTemplatesManager.class) ;
55          event.getRequestContext().addUIComponentToUpdateByAjax(uiWorkingArea) ;
56        } catch(AccessDeniedException ace) {
57          throw new MessageException(new ApplicationMessage("UIECMAdminControlPanel.msg.access-denied",
58                                                            null, ApplicationMessage.WARNING)) ;
59        }
60      }
61    }
62    
63    @Override
64    public Class<? extends UIAbstractManager> getUIAbstractManagerClass() {
65      return UICLVTemplatesManager.class;
66    }
67  
68  }