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.popup.actions.UIDocumentFormController;
20 import org.exoplatform.ecm.webui.component.explorer.popup.actions.UISelectDocumentForm;
21 import org.exoplatform.webui.config.annotation.ComponentConfig;
22 import org.exoplatform.webui.config.annotation.EventConfig;
23 import org.exoplatform.webui.core.UIComponent;
24 import org.exoplatform.webui.event.Event;
25 import org.exoplatform.webui.event.EventListener;
26
27
28
29
30
31
32 @ComponentConfig(template = "app:/groovy/webui/component/explorer/UISelectDocumentTemplateTitle.gtmpl", events = {
33 @EventConfig(listeners = UISelectDocumentTemplateTitle.ChangeViewActionListener.class),
34 @EventConfig(listeners = UISelectDocumentTemplateTitle.CancelActionListener.class) })
35 public class UISelectDocumentTemplateTitle extends UIComponent {
36
37 private final static String THUMBNAIL_VIEW_TEMPLATE =
38 "app:/groovy/webui/component/explorer/UISelectDocumentFormThumbnailView.gtmpl";
39
40 private final static String LIST_VIEW_TEMPLATE =
41 "app:/groovy/webui/component/explorer/UISelectDocumentFormListView.gtmpl";
42
43 static public class ChangeViewActionListener extends EventListener<UISelectDocumentTemplateTitle> {
44 private static final String THUMBNAIL_VIEW_TYPE = "ThumbnailView";
45
46 public void execute(Event<UISelectDocumentTemplateTitle> event) throws Exception {
47 String viewType = event.getRequestContext().getRequestParameter(OBJECTID);
48 UISelectDocumentTemplateTitle uiTemplateTitle = event.getSource();
49 UIWorkingArea uiWorkingArea = uiTemplateTitle.getAncestorOfType(UIWorkingArea.class);
50 UISelectDocumentForm uiSelectForm =
51 uiWorkingArea.getChild(UIDocumentWorkspace.class)
52 .getChild(UIDocumentFormController.class)
53 .getChild(UISelectDocumentForm.class);
54 UIJCRExplorer uiExplorer = uiSelectForm.getAncestorOfType(UIJCRExplorer.class);
55 if (viewType.equals(THUMBNAIL_VIEW_TYPE)) {
56 uiSelectForm.setTemplate(THUMBNAIL_VIEW_TEMPLATE);
57 } else {
58 uiSelectForm.setTemplate(LIST_VIEW_TEMPLATE);
59 }
60 uiExplorer.updateAjax(event);
61 }
62 }
63
64 static public class CancelActionListener extends EventListener<UISelectDocumentTemplateTitle> {
65 public void execute(Event<UISelectDocumentTemplateTitle> event) throws Exception {
66 UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class);
67 if (uiExplorer != null) {
68 UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class);
69 UIDocumentWorkspace uiDocumentWorkspace = uiWorkingArea.getChild(UIDocumentWorkspace.class);
70 if (uiDocumentWorkspace.getChild(UIDocumentFormController.class) != null) {
71 uiDocumentWorkspace.removeChild(UIDocumentFormController.class);
72 } else
73 uiExplorer.cancelAction();
74 uiExplorer.updateAjax(event);
75 }
76 }
77 }
78 }