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.admin.views;
18  
19  import org.exoplatform.webui.application.WebuiRequestContext;
20  import org.exoplatform.webui.config.annotation.ComponentConfig;
21  import org.exoplatform.webui.config.annotation.EventConfig;
22  import org.exoplatform.webui.core.UIComponent;
23  import org.exoplatform.webui.event.Event;
24  import org.exoplatform.webui.event.EventListener;
25  import org.exoplatform.webui.ext.manager.UIAbstractManager;
26  
27  /**
28   * Created by The eXo Platform SARL
29   * Author : Tran The Trong
30   *          trongtt@exoplatform.com
31   * Sep 25, 2006
32   * 11:45:11 AM
33   */
34  
35  @ComponentConfig(template = "system:/groovy/webui/core/UITabPane_New.gtmpl", 
36  events = { @EventConfig(listeners = UIViewManager.SelectTabActionListener.class) })
37  
38  public class UIViewManager extends UIAbstractManager {
39  
40    private String selectedTabId = "";
41  
42    public String getSelectedTabId()
43    {
44      return selectedTabId;
45    }
46  
47    public void setSelectedTab(String renderTabId)
48    {
49      selectedTabId = renderTabId;
50    }
51  
52    public void setSelectedTab(int index)
53    {
54      selectedTabId = getChild(index - 1).getId();
55    }
56  
57    public UIViewManager() throws Exception{	
58      addChild(UIViewContainer.class, null, null);
59      UITemplateContainer uiECMTemp = addChild(UITemplateContainer.class, null, "ECMTemplate") ;
60      uiECMTemp.addChild(UIECMTemplateList.class, null, null) ;
61      setSelectedTab("UIViewContainer");
62    }
63  
64    public void refresh() throws Exception {
65      update();
66    }
67  
68    public void update() throws Exception {
69      getChild(UIViewContainer.class).update() ;
70      UIECMTemplateList uiECMTemplateList = ((UITemplateContainer)getChildById("ECMTemplate")).getChild(UIECMTemplateList.class);
71      uiECMTemplateList.refresh(uiECMTemplateList.getUIPageIterator().getCurrentPage());
72    }
73  
74    static public class SelectTabActionListener extends EventListener<UIViewManager>
75    {
76      public void execute(Event<UIViewManager> event) throws Exception
77      {
78        WebuiRequestContext context = event.getRequestContext();
79        String renderTab = context.getRequestParameter(UIComponent.OBJECTID);
80        if (renderTab == null)
81          return;
82        event.getSource().setSelectedTab(renderTab);
83        WebuiRequestContext parentContext = (WebuiRequestContext)context.getParentAppRequestContext();
84        if (parentContext != null)
85        {
86          parentContext.setResponseComplete(true);
87        }
88        else
89        {
90          context.setResponseComplete(true);
91        }
92      }
93    } 
94  }
95