1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer.upload;
18
19 import org.exoplatform.ecm.webui.component.explorer.UIConfirmMessage;
20 import org.exoplatform.webui.config.annotation.ComponentConfig;
21 import org.exoplatform.webui.config.annotation.EventConfig;
22 import org.exoplatform.webui.core.UIPopupWindow;
23 import org.exoplatform.webui.event.Event;
24 import org.exoplatform.webui.event.EventListener;
25
26
27
28
29
30
31
32
33 @ComponentConfig(
34 template = "classpath:groovy/ecm/webui/UIConfirmMessage.gtmpl",
35 events = {
36 @EventConfig(listeners = UIUploadBehaviorWithSameName.ReplaceDataActionListener.class),
37 @EventConfig(listeners = UIUploadBehaviorWithSameName.BackActionListener.class),
38 @EventConfig(listeners = UIUploadBehaviorWithSameName.KeepfileActionListener.class)
39 }
40 )
41 public class UIUploadBehaviorWithSameName extends UIConfirmMessage {
42
43 public UIUploadBehaviorWithSameName() throws Exception {
44 }
45
46 public String[] getActions() { return new String[] {"ReplaceData", "Back", "Keepfile"}; }
47
48 static public class ReplaceDataActionListener extends EventListener<UIUploadBehaviorWithSameName> {
49 public void execute(Event<UIUploadBehaviorWithSameName> event) throws Exception {
50 UIUploadBehaviorWithSameName uiUploadBehavior = event.getSource();
51 UIPopupWindow uiPopup = uiUploadBehavior.getParent();
52 uiPopup.setShowMask(true);
53 UIUploadManager uiUploadManager = uiPopup.getParent();
54 UIUploadForm uiForm = uiUploadManager.getChild(UIUploadForm.class);
55 uiForm.doUpload(event, false);
56 if (uiUploadManager.getChildById(UIUploadManager.SAMENAME_POPUP) != null) {
57 uiUploadManager.removeChildById(UIUploadManager.SAMENAME_POPUP);
58 }
59 event.getRequestContext().addUIComponentToUpdateByAjax(uiUploadManager);
60 }
61 }
62
63 static public class BackActionListener extends EventListener<UIUploadBehaviorWithSameName> {
64 public void execute(Event<UIUploadBehaviorWithSameName> event) throws Exception {
65 UIUploadBehaviorWithSameName uiUploadBehavior = event.getSource();
66 UIPopupWindow uiPopup = uiUploadBehavior.getParent();
67 uiPopup.setRendered(false);
68 uiPopup.setShow(false);
69 event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup.getParent());
70 }
71 }
72
73 static public class KeepfileActionListener extends EventListener<UIUploadBehaviorWithSameName> {
74 public void execute(Event<UIUploadBehaviorWithSameName> event) throws Exception {
75 UIUploadBehaviorWithSameName uiUploadBehavior = event.getSource();
76 UIPopupWindow uiPopup = uiUploadBehavior.getParent();
77 uiPopup.setShowMask(true);
78 UIUploadManager uiUploadManager = uiPopup.getParent();
79 UIUploadForm uiForm = uiUploadManager.getChild(UIUploadForm.class);
80 uiForm.doUpload(event, true);
81 event.getRequestContext().addUIComponentToUpdateByAjax(uiUploadManager);
82 }
83 }
84 }
85