1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer.sidebar;
18
19 import java.util.Set;
20 import javax.servlet.http.Cookie;
21 import javax.servlet.http.HttpServletResponse;
22 import org.exoplatform.ecm.jcr.model.Preference;
23 import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace;
24 import org.exoplatform.ecm.webui.component.explorer.UIDrivesArea;
25 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
26 import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea;
27 import org.exoplatform.ecm.webui.component.explorer.control.UIAllItemsPreferenceForm;
28 import org.exoplatform.portal.webui.util.Util;
29 import org.exoplatform.services.wcm.core.NodetypeConstant;
30 import org.exoplatform.webui.config.annotation.ComponentConfig;
31 import org.exoplatform.webui.config.annotation.EventConfig;
32 import org.exoplatform.webui.core.UIComponent;
33 import org.exoplatform.webui.core.UIPopupContainer;
34 import org.exoplatform.webui.event.Event;
35 import org.exoplatform.webui.event.EventListener;
36
37
38
39
40
41
42
43
44 @ComponentConfig(
45 template = "app:/groovy/webui/component/explorer/sidebar/UIAllItems.gtmpl",
46 events = {
47 @EventConfig(listeners = UIAllItems.ClickFilterActionListener.class),
48 @EventConfig(listeners = UIAllItems.PreferencesActionListener.class)
49 }
50 )
51 public class UIAllItems extends UIComponent {
52
53 public UIAllItems() throws Exception {
54 }
55
56 public static String getFAVORITE() {
57 return NodetypeConstant.FAVORITE;
58 }
59
60 public static String getOWNED_BY_ME() {
61 return NodetypeConstant.OWNED_BY_ME;
62 }
63
64 public static String getHIDDEN() {
65 return NodetypeConstant.HIDDEN;
66 }
67
68 public static String getTRASH() {
69 return NodetypeConstant.TRASH;
70 }
71
72 public Preference getPreference() {
73 return getAncestorOfType(UIJCRExplorer.class).getPreference();
74 }
75
76 static public class ClickFilterActionListener extends EventListener<UIAllItems> {
77 public void execute(Event<UIAllItems> event) throws Exception {
78 UIAllItems UIAllItems = event.getSource();
79 UIJCRExplorer uiExplorer = UIAllItems.getAncestorOfType(UIJCRExplorer.class);
80 Set<String> allItemFilterMap = uiExplorer.getAllItemFilterMap();
81 HttpServletResponse response = Util.getPortalRequestContext().getResponse();
82 String userId = Util.getPortalRequestContext().getRemoteUser();
83 String cookieName = Preference.PREFERENCE_SHOW_HIDDEN_NODE + userId;
84 String filterType = event.getRequestContext().getRequestParameter(OBJECTID);
85 if (allItemFilterMap.contains(filterType)) {
86 allItemFilterMap.remove(filterType);
87 if (filterType.equals(NodetypeConstant.HIDDEN)) {
88 uiExplorer.getPreference().setShowHiddenNode(false);
89 response.addCookie(new Cookie(cookieName, "false"));
90 }
91 } else {
92 allItemFilterMap.add(filterType);
93 if (filterType.equals(NodetypeConstant.HIDDEN)) {
94 uiExplorer.getPreference().setShowHiddenNode(true);
95 response.addCookie(new Cookie(cookieName, "true"));
96 }
97 }
98
99
100
101 UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class);
102 UIDocumentWorkspace uiDocumentWorkspace = uiWorkingArea.getChild(UIDocumentWorkspace.class);
103 if(!uiDocumentWorkspace.isRendered()) {
104 uiWorkingArea.getChild(UIDrivesArea.class).setRendered(false);
105 uiWorkingArea.getChild(UIDocumentWorkspace.class).setRendered(true);
106 }
107 uiExplorer.updateAjax(event);
108 }
109 }
110
111 static public class PreferencesActionListener extends EventListener<UIAllItems> {
112 public void execute(Event<UIAllItems> event) throws Exception {
113 UIAllItems uiAllItems = event.getSource();
114 UIJCRExplorer uiJCRExplorer = uiAllItems.getAncestorOfType(UIJCRExplorer.class);
115 UIPopupContainer popupAction = uiJCRExplorer.getChild(UIPopupContainer.class);
116 UIAllItemsPreferenceForm uiPrefForm = popupAction.activate(UIAllItemsPreferenceForm.class,350) ;
117 uiPrefForm.update(uiJCRExplorer.getPreference()) ;
118 event.getRequestContext().addUIComponentToUpdateByAjax(popupAction) ;
119 }
120 }
121
122 }