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.popup.info;
18  
19  import javax.jcr.Node;
20  
21  import org.exoplatform.webui.core.UIPopupComponent;
22  import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
23  import org.exoplatform.webui.config.annotation.ComponentConfig;
24  import org.exoplatform.webui.core.UIContainer;
25  import org.exoplatform.webui.core.UIPopupWindow;
26  import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
27  
28  /**
29   * Created by The eXo Platform SARL
30   * Author : Dang Van Minh
31   *          minh.dang@exoplatform.com
32   * Jan 30, 2007
33   * 9:27:48 AM
34   */
35  @ComponentConfig(lifecycle = UIContainerLifecycle.class)
36  public class UIViewMetadataManager extends UIContainer implements UIPopupComponent {
37  
38    final static public String METADATAS_POPUP = "metadataForm" ;
39  
40    public UIViewMetadataManager() throws Exception {
41       addChild(UIViewMetadataContainer.class, null, null) ;
42    }
43  
44    public Node getViewNode(String nodeType) throws Exception {
45      return getAncestorOfType(UIJCRExplorer.class).getViewNode(nodeType) ;
46    }
47  
48    public void initMetadataFormPopup(String nodeType) throws Exception {
49      removeChildById(METADATAS_POPUP) ;
50      UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, METADATAS_POPUP) ;
51      uiPopup.setShowMask(true);
52      uiPopup.setWindowSize(650, 300);
53      UIViewMetadataForm uiForm = createUIComponent(UIViewMetadataForm.class, null, null) ;
54      uiForm.getChildren().clear() ;
55      uiForm.setNodeType(nodeType) ;
56      uiForm.setIsNotEditNode(true) ;
57      UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class) ;
58      Node currentNode = uiExplorer.getCurrentNode() ;
59      uiForm.setWorkspace(currentNode.getSession().getWorkspace().getName()) ;
60      uiForm.setStoredPath(currentNode.getPath()) ;
61  //    uiForm.setPropertyNode(getViewNode(nodeType)) ;
62      uiForm.setChildPath(getViewNode(nodeType).getPath()) ;
63      uiPopup.setUIComponent(uiForm) ;
64      uiPopup.setRendered(true);
65      uiPopup.setShow(true) ;
66      uiPopup.setResizable(true) ;
67    }
68  
69    public void activate() {}
70    public void deActivate() {}
71  }