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 org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
23  import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter;
24  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter;
25  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter;
26  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter;
27  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotSymlinkFilter;
28  import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter;
29  import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener;
30  import org.exoplatform.ecm.webui.component.explorer.symlink.UIAddTranslationManager;
31  import org.exoplatform.webui.config.annotation.ComponentConfig;
32  import org.exoplatform.webui.config.annotation.EventConfig;
33  import org.exoplatform.webui.core.UIPopupContainer;
34  import org.exoplatform.webui.event.Event;
35  import org.exoplatform.webui.ext.filter.UIExtensionFilter;
36  import org.exoplatform.webui.ext.filter.UIExtensionFilters;
37  import org.exoplatform.webui.ext.manager.UIAbstractManager;
38  import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
39  
40  /**
41   * Created by The eXo Platform SAS
42   * Author : eXoPlatform
43   *          nicolas.filotto@exoplatform.com
44   * 6 mai 2009
45   */
46  @ComponentConfig(
47       events = {
48         @EventConfig(listeners = AddLocalizationLinkActionComponent.AddLocalizationLinkActionListener.class)
49       }
50   )
51  
52  public class AddLocalizationLinkActionComponent extends UIAbstractManagerComponent {
53  
54    private static final List<UIExtensionFilter> FILTERS =
55      Arrays.asList(new UIExtensionFilter[]{new CanAddNodeFilter(),
56                                            new IsNotLockedFilter(),
57                                            new IsCheckedOutFilter(),
58                                            new IsNotSymlinkFilter(),
59                                            new IsNotTrashHomeNodeFilter(),
60                                            new IsNotInTrashFilter()});
61  
62    @UIExtensionFilters
63    public List<UIExtensionFilter> getFilters() {
64      return FILTERS;
65    }
66  
67    public static class AddLocalizationLinkActionListener extends UIActionBarActionListener<AddLocalizationLinkActionComponent> {
68      public void processEvent(Event<AddLocalizationLinkActionComponent> event) throws Exception {
69        UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class);
70      UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class);
71      UIAddTranslationManager uiAddTranslationManager =
72          event.getSource().createUIComponent(UIAddTranslationManager.class, null, null);
73      UIPopupContainer.activate(uiAddTranslationManager, 600, 155);
74      event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer);
75      }
76    }
77  
78    @Override
79    public Class<? extends UIAbstractManager> getUIAbstractManagerClass() {
80      return null;
81    }
82  }