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;
18  
19  import org.exoplatform.ecm.webui.tree.selectone.UIOneNodePathSelector;
20  import org.exoplatform.ecm.webui.tree.selectone.UIWorkspaceList;
21  import org.exoplatform.services.cms.drives.DriveData;
22  import org.exoplatform.services.cms.drives.ManageDriveService;
23  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
24  import org.exoplatform.webui.config.annotation.ComponentConfig;
25  import org.exoplatform.webui.core.UIContainer;
26  import org.exoplatform.webui.core.UIPopupWindow;
27  import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
28  import org.exoplatform.webui.form.UIFormSelectBox;
29  
30  /**
31   * Created by The eXo Platform SARL
32   * Author : Ly Dinh Quang
33   *          quang.ly@exoplatform.com
34   *          xxx5669@gmail.com
35   * 4 févr. 09
36   */
37  @ComponentConfig(
38      lifecycle = UIContainerLifecycle.class
39  )
40  public class UIJcrExplorerEditContainer extends UIContainer {
41  
42    public UIJcrExplorerEditContainer() throws Exception {
43      addChild(UIJcrExplorerEditForm.class, null, null);
44    }
45  
46    public UIPopupWindow initPopup(String id) throws Exception {
47      removeChildById(id);
48      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, id);
49      uiPopup.setShowMask(true);
50      uiPopup.setWindowSize(700, 350);
51      uiPopup.setShow(true);
52      uiPopup.setResizable(true);
53      return uiPopup;
54    }
55  
56    public UIPopupWindow initPopupDriveBrowser(String id, String driveName) throws Exception {
57      String repository = getAncestorOfType(UIJCRExplorerPortlet.class).getPreferenceRepository();
58      UIPopupWindow uiPopup = initPopup(id);
59      UIOneNodePathSelector uiOneNodePathSelector = createUIComponent(UIOneNodePathSelector.class, null, null);
60      UIWorkspaceList uiWorkspaceList= uiOneNodePathSelector.getChild(UIWorkspaceList.class);
61      uiOneNodePathSelector.setShowRootPathSelect(true);
62      uiWorkspaceList.getChild(UIFormSelectBox.class).setRendered(false);
63      ManageDriveService manageDrive = getApplicationComponent(ManageDriveService.class);
64      DriveData driveData = manageDrive.getDriveByName(driveName);
65      uiOneNodePathSelector.setRootNodeLocation(repository, driveData.getWorkspace(), driveData.getHomePath());
66      uiOneNodePathSelector.init(WCMCoreUtils.getUserSessionProvider());
67      uiPopup.setUIComponent(uiOneNodePathSelector);
68      uiOneNodePathSelector.setSourceComponent(this.getChild(UIJcrExplorerEditForm.class),
69          new String[] { UIJcrExplorerEditForm.PARAM_PATH_INPUT });
70      uiPopup.setRendered(true);
71      uiPopup.setShow(true);
72      uiPopup.setShowMask(true);
73      return uiPopup;
74    }
75  }