View Javadoc
1   /*
2    * Copyright (C) 2003-2007 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.upload;
18  
19  import org.exoplatform.services.log.ExoLogger;
20  import org.exoplatform.services.log.Log;
21  import org.exoplatform.webui.core.UIPopupComponent;
22  import org.exoplatform.webui.config.annotation.ComponentConfig;
23  import org.exoplatform.webui.core.UIContainer;
24  import org.exoplatform.webui.core.UIPopupWindow;
25  import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
26  
27  /**
28   * Created by The eXo Platform SARL
29   * Author : Dang Van Minh
30   *          minh.dang@exoplatform.com
31   * May 24, 2007 2:12:48 PM
32   */
33  @ComponentConfig(
34      lifecycle = UIContainerLifecycle.class
35  )
36  public class UIUploadManager extends UIContainer implements UIPopupComponent {
37    private static final Log LOG = ExoLogger.getLogger(UIUploadManager.class.getName());
38  
39    final static public String EXTARNAL_METADATA_POPUP = "AddMetadataPopup" ;
40    final static public String SAMENAME_POPUP = "SameNamePopup" ;
41  
42    public UIUploadManager() throws Exception {
43      addChild(UIUploadForm.class, null, null);
44      addChild(UIUploadContainer.class, null, null).setRendered(false);
45    }
46  
47    public UIPopupWindow initPopupTaxonomy(String id) throws Exception {
48      UIPopupWindow uiPopup = getChildById(id);
49      if (uiPopup == null) {
50        uiPopup = addChild(UIPopupWindow.class, null, id);
51      }
52      uiPopup.setWindowSize(800, 350);
53      uiPopup.setShow(false);
54      uiPopup.setResizable(true);
55      return uiPopup;
56    }
57  
58    public UIPopupWindow initPopupWhenHaveSameName() throws Exception {
59      UIPopupWindow uiPopup = getChildById(SAMENAME_POPUP);
60      if (uiPopup == null) {
61        uiPopup = addChild(UIPopupWindow.class, null, SAMENAME_POPUP);
62      }
63      uiPopup.setWindowSize(500, 180);
64      uiPopup.setShow(false);
65      uiPopup.setResizable(true);
66      return uiPopup;
67    }
68  
69    public void activate() {
70      try {
71        UIUploadForm uiUploadForm = getChild(UIUploadForm.class);
72        uiUploadForm.initFieldInput();
73      } catch (Exception e) {
74        if (LOG.isErrorEnabled()) {
75          LOG.error("Unexpected error!", e.getMessage());
76        }
77      }
78    }
79  
80    public void deActivate() {}
81  
82    public void initMetadataPopup() throws Exception {
83      removeChildById(EXTARNAL_METADATA_POPUP) ;
84      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, EXTARNAL_METADATA_POPUP) ;
85      uiPopup.setShowMask(true);
86      uiPopup.setWindowSize(400, 400);
87      UIExternalMetadataForm uiExternalMetadataForm = createUIComponent(UIExternalMetadataForm.class, null, null) ;
88      uiPopup.setUIComponent(uiExternalMetadataForm) ;
89      uiExternalMetadataForm.renderExternalList() ;
90      uiPopup.setRendered(true);
91      uiPopup.setShow(true) ;
92      uiPopup.setResizable(true) ;
93    }
94  }