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.wcm.extensions.ui;
18  
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace;
23  import org.exoplatform.ecm.webui.component.explorer.UIDrivesArea;
24  import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
25  import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea;
26  import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener;
27  import org.exoplatform.webui.config.annotation.ComponentConfig;
28  import org.exoplatform.webui.config.annotation.EventConfig;
29  import org.exoplatform.webui.core.UIComponent;
30  import org.exoplatform.webui.event.Event;
31  import org.exoplatform.webui.ext.filter.UIExtensionFilter;
32  import org.exoplatform.webui.ext.filter.UIExtensionFilters;
33  
34  /**
35   * Created by The eXo Platform SAS
36   * Author : eXoPlatform
37   *          benjamin.paillereau@exoplatform.com
38   * 27 june 2010
39   */
40  @ComponentConfig(
41      events = {
42          @EventConfig(listeners = ShowDrivesAction.ShowDrivesActionListener.class)
43      }
44  )
45  public class ShowDrivesAction extends UIComponent {
46  
47    private static final List<UIExtensionFilter> FILTERS = Arrays.asList(
48        new UIExtensionFilter[] {});
49  
50    @UIExtensionFilters
51    public List<UIExtensionFilter> getFilters() {
52      return FILTERS;
53    }
54    public static class ShowDrivesActionListener extends UIActionBarActionListener<ShowDrivesAction> {
55  
56      @Override
57      protected void processEvent(Event<ShowDrivesAction> event) throws Exception {
58        UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class);
59          UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class);
60          UIDrivesArea uiDriveArea = uiWorkingArea.getChild(UIDrivesArea.class);
61          if (uiDriveArea.isRendered()) {
62          uiDriveArea.setRendered(false);
63          uiWorkingArea.getChild(UIDocumentWorkspace.class).setRendered(true);
64          } else {
65          uiDriveArea.setRendered(true);
66          uiWorkingArea.getChild(UIDocumentWorkspace.class).setRendered(false);
67          }
68          event.getRequestContext().addUIComponentToUpdateByAjax(uiWorkingArea) ;
69      }
70    }
71  }