View Javadoc
1   /*
2    * Copyright (C) 2003-2012 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (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 Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero 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;
18  
19  import org.exoplatform.services.log.ExoLogger;
20  import org.exoplatform.services.log.Log;
21  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
22  import org.exoplatform.wcm.connector.fckeditor.DriverConnector;
23  import org.exoplatform.webui.application.WebuiRequestContext;
24  import org.exoplatform.webui.config.annotation.ComponentConfig;
25  import org.exoplatform.webui.config.annotation.EventConfig;
26  import org.exoplatform.webui.core.UIContainer;
27  import org.exoplatform.webui.event.Event;
28  import org.exoplatform.webui.event.EventListener;
29  
30  /**
31   * Created by The eXo Platform SAS
32   * Author : eXoPlatform
33   *          exo@exoplatform.com
34   * Oct 18, 2012  
35   */
36  @ComponentConfig(
37    template = "app:/groovy/webui/component/explorer/upload/UIMultiUpload.gtmpl",
38    events = {
39        @EventConfig(listeners = UIMultiUpload.RefreshExplorerActionListener.class)
40    }
41  )
42  public class UIMultiUpload extends UIContainer {
43  
44    private static final Log LOG  = ExoLogger.getLogger(UIMultiUpload.class.getName());
45    
46    private DriverConnector driveConnector_;
47    public UIMultiUpload() throws Exception {
48      this.driveConnector_ = WCMCoreUtils.getService(DriverConnector.class);
49    }
50    
51    public int getLimitFileSize() {
52      return driveConnector_.getLimitSize();
53    }
54    
55    public int getMaxUploadCount() {
56      return driveConnector_.getMaxUploadCount();
57    }
58    
59    @Override
60    public void processRender(WebuiRequestContext context) throws Exception {
61  //    context.getJavascriptManager().require("SHARED/explorer-module", "explorer").
62  //    addScripts("explorer.MultiUpload.initDropBox('" + this.getId() + " ');");
63      super.processRender(context);
64    }
65    
66    public static class RefreshExplorerActionListener extends EventListener<UIMultiUpload> {
67      public void execute(Event<UIMultiUpload> event) throws Exception {
68        UIMultiUpload uiUpload = event.getSource();
69        uiUpload.getAncestorOfType(UIJcrExplorerContainer.class).getChild(UIJCRExplorer.class).updateAjax(event);
70      }
71    }
72  
73  }