1 package org.exoplatform.ecm.webui.form;
2
3 import org.exoplatform.webui.config.annotation.ComponentConfig;
4 import org.exoplatform.webui.config.annotation.EventConfig;
5 import org.exoplatform.webui.core.UIComponent;
6 import org.exoplatform.webui.core.UIPopupComponent;
7 import org.exoplatform.webui.core.UIPopupWindow;
8 import org.exoplatform.webui.event.Event;
9 import org.exoplatform.webui.event.EventListener;
10
11
12
13
14
15
16
17
18 @ComponentConfig(
19 template = "classpath:groovy/ecm/webui/UIConfirmMessage.gtmpl",
20 events = {
21 @EventConfig(listeners = UIOpenDocumentForm.ReadOnlyActionListener.class),
22 @EventConfig(listeners = UIOpenDocumentForm.CancelActionListener.class)
23 }
24 )
25 public class UIOpenDocumentForm extends UIComponent implements UIPopupComponent {
26
27 public UIOpenDocumentForm() throws Exception {}
28
29 public String filePath;
30 public String mountPath;
31 public String absolutePath;
32 public String[] getActions() { return new String[] {"ReadOnly", "Cancel"}; }
33
34
35
36
37 public static class ReadOnlyActionListener extends EventListener<UIOpenDocumentForm> {
38 @Override
39 public void execute(Event<UIOpenDocumentForm> event) throws Exception {
40 UIOpenDocumentForm uiConfirm = event.getSource();
41
42 UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ;
43 popupAction.setShow(false) ;
44 event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
45
46 event.getRequestContext().getJavascriptManager().require("SHARED/openDocumentInOffice")
47 .addScripts("eXo.ecm.OpenDocumentInOffice.openDocument('" + uiConfirm.absolutePath + "', '" + uiConfirm.mountPath + "');");
48 }
49 }
50
51
52
53
54 public static class CancelActionListener extends EventListener<UIOpenDocumentForm> {
55 @Override
56 public void execute(Event<UIOpenDocumentForm> event) throws Exception {
57 UIOpenDocumentForm uiConfirm = event.getSource();
58 UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ;
59 popupAction.setShow(false) ;
60 event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
61 }
62 }
63
64 private String messageKey_;
65 private String[] args_ = {};
66
67 public void setMessageKey(String messageKey) { messageKey_ = messageKey; }
68
69 public String getMessageKey() { return messageKey_; }
70
71 public void setArguments(String[] args) { args_ = args; }
72
73 public String[] getArguments() { return args_; }
74
75 public void activate() {
76
77 }
78
79 public void deActivate() {
80
81 }
82
83 public void setFilePath(String filePath) {
84 this.filePath = filePath;
85 }
86
87 public void setMountPath(String mountPath) {
88 this.mountPath = mountPath;
89 }
90
91 public void setAbsolutePath(String absolutePath) {
92 this.absolutePath = absolutePath;
93 }
94 }