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 java.util.ArrayList;
20 import java.util.List;
21
22 import javax.jcr.Item;
23 import javax.jcr.Node;
24
25 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
26 import org.exoplatform.services.log.ExoLogger;
27 import org.exoplatform.services.log.Log;
28 import org.exoplatform.services.wcm.core.NodeLocation;
29 import org.exoplatform.webui.config.annotation.ComponentConfig;
30 import org.exoplatform.webui.config.annotation.EventConfig;
31 import org.exoplatform.webui.core.UIContainer;
32 import org.exoplatform.webui.event.Event;
33 import org.exoplatform.webui.event.EventListener;
34
35
36
37
38
39
40
41 @ComponentConfig(
42 template = "app:/groovy/webui/component/explorer/UITabPaneWithAction.gtmpl",
43 events = {
44 @EventConfig(listeners = UIUploadContainer.CloseActionListener.class),
45 @EventConfig(listeners = UIUploadContainer.AddMetadataActionListener.class)
46 }
47 )
48 public class UIUploadContainer extends UIContainer {
49
50 private static final Log LOG = ExoLogger.getLogger(UIUploadContainer.class.getName());
51
52 private NodeLocation uploadedNode_;
53 private List<NodeLocation> listUploadedNode_ = new ArrayList<NodeLocation>();
54 private String[] arrayActions = new String[] {"Close"};
55
56 public UIUploadContainer() throws Exception {
57 addChild(UIUploadContent.class, null, null) ;
58 }
59
60 public void setActions(String[] arrValueActions) {
61 arrayActions = arrValueActions ;
62 }
63
64 public String[] getActions() {
65 return arrayActions;
66 }
67
68 public Node getEditNode(String nodeType) throws Exception {
69 Node uploadNode = getUploadedNode();
70 try {
71 Item primaryItem = uploadNode.getPrimaryItem() ;
72 if (primaryItem == null || !primaryItem.isNode()) return uploadNode;
73 if (primaryItem != null && primaryItem.isNode()) {
74 Node primaryNode = (Node) primaryItem ;
75 if (primaryNode.isNodeType(nodeType)) return primaryNode ;
76 }
77 } catch(Exception e) {
78 if (LOG.isWarnEnabled()) {
79 LOG.warn(e.getMessage());
80 }
81 }
82 return uploadNode;
83 }
84
85 public void setUploadedNode(Node node) throws Exception {
86 uploadedNode_ = NodeLocation.getNodeLocationByNode(node);
87 }
88
89 public Node getUploadedNode() {
90 return NodeLocation.getNodeByLocation(uploadedNode_);
91 }
92
93 public void setListUploadedNode(List<Node> listNode) throws Exception {
94 listUploadedNode_ = NodeLocation.getLocationsByNodeList(listNode);
95 }
96
97 public List<Node> getListUploadedNode() {
98 return NodeLocation.getNodeListByLocationList(listUploadedNode_);
99 }
100
101 static public class CloseActionListener extends EventListener<UIUploadContainer> {
102 public void execute(Event<UIUploadContainer> event) throws Exception {
103 UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class) ;
104 uiExplorer.cancelAction() ;
105 }
106 }
107
108 static public class AddMetadataActionListener extends EventListener<UIUploadContainer> {
109 public void execute(Event<UIUploadContainer> event) throws Exception {
110 UIUploadManager uiUploadManager = event.getSource().getParent() ;
111 uiUploadManager.initMetadataPopup() ;
112 event.getRequestContext().addUIComponentToUpdateByAjax(uiUploadManager) ;
113 }
114 }
115 }