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  package org.exoplatform.ecm.webui.component.explorer.control.action;
18  
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import javax.jcr.Node;
23  
24  import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
25  import org.exoplatform.ecm.webui.component.explorer.auditing.UIActivateAuditing;
26  import org.exoplatform.ecm.webui.component.explorer.auditing.UIAuditingInfo;
27  import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter;
28  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter;
29  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter;
30  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter;
31  import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener;
32  import org.exoplatform.ecm.webui.utils.Utils;
33  import org.exoplatform.webui.config.annotation.ComponentConfig;
34  import org.exoplatform.webui.config.annotation.EventConfig;
35  import org.exoplatform.webui.core.UIPopupContainer;
36  import org.exoplatform.webui.event.Event;
37  import org.exoplatform.webui.ext.filter.UIExtensionFilter;
38  import org.exoplatform.webui.ext.filter.UIExtensionFilters;
39  import org.exoplatform.webui.ext.manager.UIAbstractManager;
40  import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
41  
42  /**
43   * Created by The eXo Platform SAS
44   * Author : eXoPlatform
45   *          nicolas.filotto@exoplatform.com
46   * 6 mai 2009
47   */
48  @ComponentConfig(
49       events = {
50         @EventConfig(listeners = ManageAuditingActionComponent.ManageAuditingActionListener.class)
51       }
52   )
53  public class ManageAuditingActionComponent extends UIAbstractManagerComponent {
54  
55    private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotRootNodeFilter(),
56        new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter()});
57  
58    @UIExtensionFilters
59    public List<UIExtensionFilter> getFilters() {
60      return FILTERS;
61    }
62  
63    public static class ManageAuditingActionListener extends UIActionBarActionListener<ManageAuditingActionComponent> {
64      public void processEvent(Event<ManageAuditingActionComponent> event) throws Exception {
65        UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class);
66        UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class);
67        Node currentNode = uiExplorer.getCurrentNode();
68        if (!currentNode.isNodeType(Utils.EXO_AUDITABLE)) {
69          UIPopupContainer.activate(UIActivateAuditing.class, 400);
70          event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer);
71          return;
72        }
73        UIAuditingInfo uiAuditingInfo = uiExplorer.createUIComponent(UIAuditingInfo.class, null, null);
74        UIPopupContainer.activate(uiAuditingInfo, 700, 500);
75        uiAuditingInfo.updateGrid();
76        event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer);
77      }
78    }
79  
80    @Override
81    public Class<? extends UIAbstractManager> getUIAbstractManagerClass() {
82      return null;
83    }
84  }