1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.cs.common.webui;
18
19 import org.exoplatform.webui.application.WebuiRequestContext;
20 import org.exoplatform.webui.config.annotation.ComponentConfig;
21 import org.exoplatform.webui.core.UIComponent;
22 import org.exoplatform.webui.core.UIContainer;
23 import org.exoplatform.webui.core.UIPopupComponent;
24 import org.exoplatform.webui.core.UIPopupWindow;
25 import org.exoplatform.webui.core.lifecycle.Lifecycle;
26
27
28
29
30
31
32 @ComponentConfig( lifecycle = Lifecycle.class )
33 public class UIPopupAction extends UIContainer {
34 public UIPopupAction() throws Exception {
35 addChild(createUIComponent(UIPopupWindow.class, null, null).setRendered(false));
36 }
37
38 public void processRender(WebuiRequestContext context) throws Exception {
39 context.getWriter().append("<span class=\"").append(getId()).append("\" id=\"").append(getId()).append("\">");
40 renderChildren(context) ;
41 context.getWriter().append("</span>");
42 }
43
44 public <T extends UIComponent> T activate(Class<T> type, int width) throws Exception {
45 return activate(type, null, width, 0);
46 }
47
48 public <T extends UIComponent> T activate(Class<T> type, String configId, int width, int height)
49 throws Exception {
50 T comp = createUIComponent(type, configId, null);
51 activate(comp, width, height);
52 return comp;
53 }
54
55 public void activate(UIComponent uiComponent, int width, int height) throws Exception {
56 activate(uiComponent, width, height, true);
57 }
58
59 public void activate(UIComponent uiComponent, int width, int height, boolean isResizeable)
60 throws Exception {
61 UIPopupWindow popup = getChild(UIPopupWindow.class);
62 popup.setUIComponent(uiComponent);
63 ((UIPopupComponent) uiComponent).activate();
64 popup.setWindowSize(width, height);
65 popup.setRendered(true);
66 popup.setShow(true);
67 popup.setResizable(isResizeable);
68 }
69
70 public void deActivate() throws Exception {
71 UIPopupWindow popup = getChild(UIPopupWindow.class);
72 if (popup.getUIComponent() != null)
73 ((UIPopupComponent) popup.getUIComponent()).deActivate();
74 popup.setUIComponent(null);
75 popup.setRendered(false);
76 }
77
78 public void cancelPopupAction() throws Exception {
79 deActivate();
80 WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
81 context.addUIComponentToUpdateByAjax(this);
82 }
83 }