1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer.rightclick.action;
18
19 import java.util.regex.Matcher;
20
21 import javax.jcr.AccessDeniedException;
22 import javax.jcr.Node;
23 import javax.jcr.PathNotFoundException;
24 import javax.jcr.Session;
25
26 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
27 import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea;
28 import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener;
29 import org.exoplatform.ecm.webui.component.explorer.rightclick.viewinfor.UIViewInfoManager;
30 import org.exoplatform.ecm.webui.utils.JCRExceptionManager;
31 import org.exoplatform.web.application.ApplicationMessage;
32 import org.exoplatform.webui.config.annotation.ComponentConfig;
33 import org.exoplatform.webui.config.annotation.EventConfig;
34 import org.exoplatform.webui.core.UIApplication;
35 import org.exoplatform.webui.core.UIPopupContainer;
36 import org.exoplatform.webui.event.Event;
37 import org.exoplatform.webui.ext.manager.UIAbstractManager;
38 import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
39
40
41
42
43
44
45
46 @ComponentConfig(events = { @EventConfig(listeners = ViewInfoActionComponent.ViewInfoActionListener.class) })
47 public class ViewInfoActionComponent extends UIAbstractManagerComponent{
48
49
50
51
52
53 public static class ViewInfoActionListener extends UIWorkingAreaActionListener<ViewInfoActionComponent> {
54
55 @Override
56 protected void processEvent(Event<ViewInfoActionComponent> event) throws Exception {
57 ViewInfoActionComponent uicomp = event.getSource();
58 UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class);
59 UIPopupContainer objUIPopupContainer = uiExplorer.getChild(UIPopupContainer.class);
60
61 String nodePath = event.getRequestContext().getRequestParameter(OBJECTID);
62 Node selectedNode = null;
63 if (nodePath != null && nodePath.length() != 0) {
64
65 Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath);
66 String wsName = null;
67 if (matcher.find()) {
68 wsName = matcher.group(1);
69 nodePath = matcher.group(2);
70 } else {
71 throw new IllegalArgumentException("The ObjectId is invalid '" + nodePath + "'");
72 }
73
74
75 Session session = uiExplorer.getSessionByWorkspace(wsName);
76
77
78 UIApplication uiApp = uicomp.getAncestorOfType(UIApplication.class);
79
80
81 try {
82
83 selectedNode = uiExplorer.getNodeByPath(nodePath, session);
84 } catch (PathNotFoundException path) {
85 uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,
86 ApplicationMessage.WARNING));
87
88 return;
89 } catch (AccessDeniedException ace) {
90 uiApp.addMessage(new ApplicationMessage("UIDocumentInfo.msg.null-exception", null,
91 ApplicationMessage.WARNING));
92
93 return;
94 } catch (Exception e) {
95 JCRExceptionManager.process(uiApp, e);
96 return;
97 }
98 }
99
100 if (selectedNode == null) selectedNode = uiExplorer.getCurrentNode();
101
102
103 UIViewInfoManager uiViewInfoManager = uiExplorer.createUIComponent(UIViewInfoManager.class, null, null);
104 uiViewInfoManager.setSelectedNode(selectedNode);
105 objUIPopupContainer.activate(uiViewInfoManager, 600, 0);
106 event.getRequestContext().addUIComponentToUpdateByAjax(objUIPopupContainer);
107 }
108 }
109
110 @Override
111 public Class<? extends UIAbstractManager> getUIAbstractManagerClass() {
112 return null;
113 }
114
115 }