View Javadoc
1   /*
2    * Copyright (C) 2003-2009 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.wcm.webui.dialog;
18  
19  import org.exoplatform.wcm.webui.Utils;
20  import org.exoplatform.wcm.webui.dialog.permission.UIPermissionManager;
21  import org.exoplatform.webui.config.annotation.ComponentConfig;
22  import org.exoplatform.webui.config.annotation.EventConfig;
23  import org.exoplatform.webui.core.UIPopupContainer;
24  import org.exoplatform.webui.core.UITabPane;
25  import org.exoplatform.webui.event.Event;
26  import org.exoplatform.webui.event.EventListener;
27  
28  /**
29   * Created by The eXo Platform SAS
30   * Author : Phan Le Thanh Chuong
31   *          chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com
32   * Oct 29, 2009
33   */
34  @ComponentConfig (
35    template = "system:/groovy/webui/form/ext/UITabPaneWithAction.gtmpl",
36    events = {
37      @EventConfig(listeners = UIContentDialogPreference.BackActionListener.class)
38    }
39  )
40  public class UIContentDialogPreference extends UITabPane {
41  
42    public String[] getActions() {
43      return new String[] {"Back"};
44    }
45  
46    public void init() throws Exception {
47      UIPermissionManager permissionManager = addChild(UIPermissionManager.class, null, null);
48      permissionManager.updateGrid();
49      setSelectedTab(permissionManager.getId());
50    }
51  
52    public static class BackActionListener extends EventListener<UIContentDialogPreference> {
53  
54      public void execute(Event<UIContentDialogPreference> event) throws Exception {
55        UIContentDialogPreference contentDialogPreference = event.getSource();
56        UIPopupContainer popupContainer = contentDialogPreference.getAncestorOfType(UIPopupContainer.class);
57        UIContentDialogForm contentDialogForm = popupContainer.getChild(UIContentDialogForm.class);
58        popupContainer.removeChildById(contentDialogForm.getId());
59        Utils.updatePopupWindow(contentDialogPreference, contentDialogForm, UIContentDialogForm.CONTENT_DIALOG_FORM_POPUP_WINDOW);
60      }
61    }
62  }