1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer;
18
19 import org.exoplatform.ecm.webui.component.explorer.rightclick.manager.DeleteManageComponent;
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.UIPopupComponent;
24 import org.exoplatform.webui.core.UIPopupWindow;
25 import org.exoplatform.webui.event.Event;
26 import org.exoplatform.webui.event.EventListener;
27
28
29
30
31
32
33
34 @ComponentConfig(
35 template = "classpath:groovy/ecm/webui/UIConfirmMessage.gtmpl",
36 events = {
37 @EventConfig(listeners = UIConfirmMessage.OKActionListener.class),
38 @EventConfig(listeners = UIConfirmMessage.CloseActionListener.class)
39
40 }
41 )
42 public class UIConfirmMessage extends UIComponent implements UIPopupComponent {
43
44 private String messageKey_;
45 private String[] args_ = {};
46 protected boolean isOK_ = false;
47 protected String nodePath_;
48 private boolean isNodeInTrash = false;
49
50 public UIConfirmMessage() throws Exception {
51 }
52
53 public void setMessageKey(String messageKey) { messageKey_ = messageKey; }
54
55 public String getMessageKey() { return messageKey_; }
56
57 public void setArguments(String[] args) { args_ = args; }
58
59 public String[] getArguments() { return args_; }
60
61 public boolean isOK() { return isOK_; }
62
63 public void setNodePath(String nodePath) { nodePath_ = nodePath; }
64
65 public String[] getActions() {
66 return new String[] {"OK", "Close"};
67 }
68
69 public boolean isNodeInTrash() {
70 return isNodeInTrash;
71 }
72
73 public void setNodeInTrash(boolean isNodeInTrash) {
74 this.isNodeInTrash = isNodeInTrash;
75 }
76
77 static public class OKActionListener extends EventListener<UIConfirmMessage> {
78 public void execute(Event<UIConfirmMessage> event) throws Exception {
79 UIConfirmMessage uiConfirm = event.getSource();
80 UIJCRExplorer uiExplorer = uiConfirm.getAncestorOfType(UIJCRExplorer.class);
81 UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class);
82
83 if (uiConfirm.isNodeInTrash()) {
84 uiWorkingArea.getChild(DeleteManageComponent.class).doDeleteWithoutTrash(uiConfirm.nodePath_, event);
85 } else {
86 uiWorkingArea.getChild(DeleteManageComponent.class).doDelete(uiConfirm.nodePath_, event);
87 }
88
89 uiConfirm.isOK_ = true;
90 UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ;
91 popupAction.setShow(false) ;
92 event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
93 }
94 }
95
96 static public class CloseActionListener extends EventListener<UIConfirmMessage> {
97 public void execute(Event<UIConfirmMessage> event) throws Exception {
98 UIConfirmMessage uiConfirm = event.getSource();
99 uiConfirm.isOK_ = false;
100 UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ;
101 popupAction.setShow(false) ;
102 event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
103 event.getRequestContext().getJavascriptManager().require("SHARED/uiFileView", "uiFileView").
104 addScripts("uiFileView.UIFileView.clearCheckboxes();");
105 }
106 }
107
108 public void activate() {
109
110 }
111
112 public void deActivate() {
113
114 }
115 }