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.core;
18  
19  import org.exoplatform.webui.config.annotation.ComponentConfig;
20  import org.exoplatform.webui.config.annotation.EventConfig;
21  import org.exoplatform.webui.core.UIPopupContainer;
22  import org.exoplatform.webui.event.Event;
23  import org.exoplatform.webui.event.EventListener;
24  
25  /**
26   * Created by The eXo Platform SAS
27   * Author : Phan Le Thanh Chuong
28   *          chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com
29   * Oct 29, 2009
30   */
31  @ComponentConfig(
32    template =  "classpath:groovy/wcm/webui/core/UIPopupWindow.gtmpl",
33    events = @EventConfig(listeners = UIPopupWindow.CloseActionListener.class, name = "ClosePopup")
34  )
35  public class UIPopupWindow extends org.exoplatform.webui.core.UIPopupWindow {
36    private int top_ = -1;
37    private int left_ = -1;
38    private boolean isMiddle = false;
39  
40    /**
41     * @return the isMiddle
42     */
43    public boolean isMiddle() {
44      return isMiddle;
45    }
46    
47    /**
48     * @param isMiddle the isMiddle to set
49     */
50    public void setMiddle(boolean isMiddle) {
51      this.isMiddle = isMiddle;
52    }
53    
54    public int getWindowTop()
55    {
56       return top_;
57    }
58    public int getWindowLeft()
59    {
60       return left_;
61    }
62  
63    public void setCoordindate(int top, int left) {
64      top_ = top;
65      left_ = left;
66    }
67    public static class CloseActionListener extends EventListener<UIPopupWindow> {
68      public void execute(Event<UIPopupWindow> event) throws Exception {
69        UIPopupWindow popupWindow = event.getSource();
70        UIPopupContainer popupContainer = popupWindow.getAncestorOfType(UIPopupContainer.class);
71        popupContainer.removeChildById(popupWindow.getId());
72        event.getRequestContext().addUIComponentToUpdateByAjax(popupContainer);
73      }
74    }
75  }