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.templates;
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.core.UIContainer;
24  import org.exoplatform.webui.event.Event;
25  import org.exoplatform.webui.event.EventListener;
26  
27  /**
28   * Created by The eXo Platform SARL
29   * Author : pham tuan
30   *          phamtuanchip@yahoo.de
31   * Oct 03, 2006
32   * 9:43:23 AM
33   */
34  @ComponentConfig(template = "system:/groovy/webui/core/UITabPane_New.gtmpl", 
35  events = { @EventConfig(listeners = UIViewTemplate.SelectTabActionListener.class) })
36  
37  public class UIViewTemplate extends UIContainer {
38    private String nodeTypeName_ ;
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 UIViewTemplate() throws Exception {
58      addChild(UITemplateEditForm.class, null, null) ;
59      setSelectedTab("UITemplateEditForm");
60      addChild(UIDialogTab.class, null, null);
61      addChild(UIViewTab.class, null, null);
62      addChild(UISkinTab.class, null, null);
63    }
64  
65    public void refresh() throws Exception {
66      getChild(UIDialogTab.class).updateGrid(nodeTypeName_);
67      getChild(UIViewTab.class).updateGrid(nodeTypeName_);
68      getChild(UISkinTab.class).updateGrid(nodeTypeName_);
69    }
70    public void setNodeTypeName(String nodeType) { nodeTypeName_ = nodeType ; }
71  
72    public String getNodeTypeName() { return nodeTypeName_ ; }
73  
74    static public class SelectTabActionListener extends EventListener<UIViewTemplate>
75    {
76      public void execute(Event<UIViewTemplate> 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  }