1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.admininterface;
35
36 import info.magnolia.cms.core.Content;
37 import info.magnolia.cms.core.NodeData;
38 import info.magnolia.cms.core.Path;
39 import info.magnolia.cms.core.HierarchyManager;
40 import info.magnolia.cms.exchange.ExchangeException;
41 import info.magnolia.cms.exchange.Syndicator;
42 import info.magnolia.cms.gui.control.ControlImpl;
43 import info.magnolia.cms.gui.control.Tree;
44 import info.magnolia.cms.gui.misc.Sources;
45 import info.magnolia.cms.i18n.MessagesManager;
46 import info.magnolia.cms.i18n.MessagesUtil;
47 import info.magnolia.cms.i18n.Messages;
48 import info.magnolia.cms.security.AccessDeniedException;
49 import info.magnolia.cms.servlets.CommandBasedMVCServletHandler;
50 import info.magnolia.cms.util.AlertUtil;
51 import info.magnolia.cms.util.ContentUtil;
52 import info.magnolia.cms.util.ExclusiveWrite;
53 import info.magnolia.commands.CommandsManager;
54 import info.magnolia.context.Context;
55 import info.magnolia.context.MgnlContext;
56 import info.magnolia.context.WebContext;
57 import info.magnolia.module.admininterface.commands.BaseActivationCommand;
58 import info.magnolia.objectfactory.Classes;
59
60 import java.io.IOException;
61 import java.util.Iterator;
62
63 import javax.jcr.PathNotFoundException;
64 import javax.jcr.RepositoryException;
65 import javax.servlet.http.HttpServletRequest;
66 import javax.servlet.http.HttpServletResponse;
67
68 import org.apache.commons.chain.Command;
69 import org.apache.commons.lang.StringUtils;
70 import org.slf4j.Logger;
71 import org.slf4j.LoggerFactory;
72
73
74
75
76
77
78
79
80
81 public class AdminTreeMVCHandler extends CommandBasedMVCServletHandler {
82
83
84
85
86 protected static final String COMMAND_SHOW_TREE = "show";
87
88 protected static final String COMMAND_COPY_NODE = "copy";
89
90 protected static final String COMMAND_MOVE_NODE = "move";
91
92 protected static final String COMMAND_ACTIVATE = "activate";
93
94 protected static final String COMMAND_DEACTIVATE = "deactivate";
95
96 protected static final String COMMAND_CREATE_NODE = "createNode";
97
98 protected static final String COMMAND_DELETE_NODE = "delete";
99
100 protected static final String COMMAND_SAVE_VALUE = "saveValue";
101
102
103
104
105
106 protected static final String VIEW_TREE = "tree";
107
108 protected static final String VIEW_CREATE = "create";
109
110 protected static final String VIEW_VALUE = "value";
111
112 protected static final String VIEW_NOTHING = "nothing";
113
114 protected static final String VIEW_COPY_MOVE = "copymove";
115
116
117
118
119 private static Logger log = LoggerFactory.getLogger(AdminTreeMVCHandler.class);
120
121
122
123
124 protected Tree tree;
125
126
127
128
129 private String treeClass = Tree.class.getName();
130
131
132
133
134
135 private String configurationClass;
136
137
138
139
140 protected AdminTreeConfiguration configuration;
141
142 protected String newNodeName = "untitled";
143
144 protected String createItemType = Tree.ITEM_TYPE_NODEDATA;
145
146 protected String path;
147
148 protected String pathOpen;
149
150 protected String pathSelected;
151
152 protected String rootPath;
153
154
155
156
157 protected String displayValue;
158
159 protected String newPath;
160
161 private String repository;
162
163 private String i18nBasename;
164
165
166
167
168 protected boolean browseMode;
169
170 private boolean enableDeleteConfirmation = true;
171
172
173
174
175
176 public String getRepository() {
177 if (repository == null) {
178 repository = this.getName();
179 }
180 return repository;
181 }
182
183 public void setRepository(String repository) {
184 this.repository = repository;
185 }
186
187
188
189
190 public HierarchyManager getHierarchyManager() {
191 return MgnlContext.getHierarchyManager(this.getRepository());
192 }
193
194 public AdminTreeMVCHandler(String name, HttpServletRequest request, HttpServletResponse response) {
195 super(name, request, response);
196 }
197
198 @Override
199 public void init() {
200 super.init();
201
202 path = this.getRequest().getParameter("path");
203 if (StringUtils.isEmpty(path)) {
204 if(StringUtils.isNotEmpty(this.getRootPath())){
205 path = this.getRootPath();
206 }
207 else{
208 path = "/";
209 }
210 }
211
212 pathOpen = this.getRequest().getParameter("pathOpen");
213 pathSelected = this.getRequest().getParameter("pathSelected");
214
215 this.setBrowseMode(StringUtils.equals(this.getRequest().getParameter("browseMode"), "true"));
216 }
217
218
219
220
221
222 @Override
223 public String getCommand() {
224
225 if (StringUtils.isNotEmpty(super.getCommand())) {
226 return super.getCommand();
227 }
228
229 if (StringUtils.isNotEmpty(this.getRequest().getParameter("treeAction"))) {
230 int treeAction = Integer.parseInt(this.getRequest().getParameter("treeAction"));
231
232 if (treeAction == Tree.ACTION_COPY) {
233 return COMMAND_COPY_NODE;
234 }
235 if (treeAction == Tree.ACTION_MOVE) {
236 return COMMAND_MOVE_NODE;
237 }
238 if (treeAction == Tree.ACTION_ACTIVATE) {
239 return COMMAND_ACTIVATE;
240 }
241 if (treeAction == Tree.ACTION_DEACTIVATE) {
242 return COMMAND_DEACTIVATE;
243 }
244
245 return this.getRequest().getParameter("treeAction");
246 }
247
248
249 if (this.getRequest().getParameter("createItemType") != null) {
250 return COMMAND_CREATE_NODE;
251 }
252
253 if (this.getRequest().getParameter("deleteNode") != null) {
254 return COMMAND_DELETE_NODE;
255 }
256
257
258 if (this.getRequest().getParameter("saveName") != null
259 || this.getRequest().getParameter("saveValue") != null
260
261 || "true".equals(this.getRequest().getParameter("isNodeDataValue"))
262
263 || "true".equals(this.getRequest().getParameter("isNodeDataType"))) {
264 return COMMAND_SAVE_VALUE;
265 }
266
267 return COMMAND_SHOW_TREE;
268 }
269
270
271
272
273 @Override
274 protected Context getCommandContext(String commandName) {
275 Context context = MgnlContext.getInstance();
276
277
278 context.put(Context.ATTRIBUTE_REPOSITORY, this.getRepository());
279
280 if ("activate".equals(commandName) || "deactivate".equals(commandName)) {
281 context.put(BaseActivationCommand.ATTRIBUTE_SYNDICATOR, getActivationSyndicator(this.pathSelected));
282 if (this.pathSelected != null) {
283 try {
284 final String uuid = MgnlContext.getHierarchyManager(repository).getContent(this.pathSelected).getUUID();
285
286 context.put(Context.ATTRIBUTE_UUID, uuid);
287
288 final String realPath = MgnlContext.getSystemContext().getHierarchyManager(repository).getContentByUUID(uuid).getHandle();
289 context.put(Context.ATTRIBUTE_PATH, realPath);
290 } catch (RepositoryException e) {
291
292 log.error("Failed to retrieve content node [{}:{}].", this.repository, this.pathSelected);
293 }
294 }
295 } else if (this.pathSelected != null) {
296
297
298 context.put(Context.ATTRIBUTE_PATH, this.pathSelected);
299 }
300
301 return context;
302 }
303
304
305
306
307 @Override
308 protected Command findCommand(String commandName) {
309 Command cmd = super.findCommand(commandName);
310 if (cmd == null) {
311 cmd = CommandsManager.getInstance().getCommand(CommandsManager.DEFAULT_CATALOG, commandName);
312 }
313 return cmd;
314 }
315
316
317
318
319 @Override
320 protected String getViewNameAfterExecution(String commandName, Context ctx) {
321 return VIEW_TREE;
322 }
323
324
325
326
327 public String show() {
328 return VIEW_TREE;
329 }
330
331
332
333
334
335 public String createNode() {
336 getTree().setPath(path);
337 synchronized (ExclusiveWrite.getInstance()) {
338 String name = getTree().createNode(this.getNewNodeName(), createItemType);
339 setNewNodeName(name);
340 }
341 return VIEW_TREE;
342 }
343
344
345
346
347 public String copy() {
348 try {
349 synchronized (ExclusiveWrite.getInstance()) {
350 copyOrMove(Tree.ACTION_COPY);
351 }
352 }
353 catch (Exception e) {
354 log.error("can't copy", e);
355 AlertUtil.setMessage(MessagesManager.get("tree.error.copy") + " " + AlertUtil.getExceptionMessage(e));
356 }
357 return VIEW_COPY_MOVE;
358 }
359
360
361
362
363 public String move() {
364 try {
365 synchronized (ExclusiveWrite.getInstance()) {
366 copyOrMove(Tree.ACTION_MOVE);
367 }
368 }
369 catch (Exception e) {
370 log.error("can't move", e);
371 AlertUtil.setMessage(MessagesManager.get("tree.error.move") + " " + AlertUtil.getExceptionMessage(e));
372 }
373 return VIEW_COPY_MOVE;
374
375 }
376
377
378
379
380
381
382 private void copyOrMove(int action) throws ExchangeException, RepositoryException {
383 String pathClipboard = this.getRequest().getParameter("pathClipboard");
384 int pasteType = Integer.parseInt(this.getRequest().getParameter("pasteType"));
385 newPath = pasteNode(pathClipboard, pathSelected, pasteType, action);
386
387 if (pasteType == Tree.PASTETYPE_SUB) {
388 pathOpen = pathSelected;
389 }
390 else {
391
392 pathOpen = pathSelected.substring(0, pathSelected.lastIndexOf("/"));
393 }
394
395 pathSelected = null;
396 }
397
398 public void deleteNode(String parentPath, String label) throws ExchangeException, RepositoryException {
399 Content parentNode = getHierarchyManager().getContent(parentPath);
400 String path;
401 if (!parentPath.equals("/")) {
402 path = parentPath + "/" + label;
403 }
404 else {
405 path = "/" + label;
406 }
407 this.deactivateNode(path);
408 parentNode.delete(label);
409 parentNode.save();
410 }
411
412 public void deleteNode(String path) throws Exception {
413 String parentPath = StringUtils.substringBeforeLast(path, "/");
414 String label = StringUtils.substringAfterLast(path, "/");
415 deleteNode(parentPath, label);
416 }
417
418 public String delete() {
419 String deleteNode = this.getRequest().getParameter("deleteNode");
420 try {
421 synchronized (ExclusiveWrite.getInstance()) {
422 deleteNode(path, deleteNode);
423 }
424 }
425 catch (Exception e) {
426 log.error("can't delete", e);
427 AlertUtil.setMessage(MessagesManager.get("tree.error.delete") + " " + AlertUtil.getExceptionMessage(e));
428 }
429 return VIEW_TREE;
430 }
431
432
433
434
435
436
437
438 public Syndicator getActivationSyndicator(String path) {
439
440 return null;
441 }
442
443
444
445
446
447
448
449 public void deactivateNode(String path) throws ExchangeException, RepositoryException {
450 if (MgnlContext.getHierarchyManager(this.getRepository()).isNodeData(path)) {
451 return;
452 }
453 CommandsManager cm = CommandsManager.getInstance();
454
455 Command cmd = cm.getCommand(this.getName(), "deactivate");
456 if (cmd == null) {
457 cmd = cm.getCommand(CommandsManager.DEFAULT_CATALOG, "deactivate");
458 }
459
460 if (cmd == null) {
461 log.error("deactivate command not found, deactivation will not be performed");
462 return;
463 }
464
465 Context ctx = this.getCommandContext("deactivate");
466
467
468 ctx.setAttribute(Context.ATTRIBUTE_PATH, path, Context.LOCAL_SCOPE);
469 try {
470 cmd.execute(ctx);
471 }
472 catch (Exception e) {
473 throw new ExchangeException(e);
474 }
475
476 }
477
478 public Content copyMoveNode(String source, String destination, boolean move) throws ExchangeException,
479 RepositoryException {
480
481 final HierarchyManager hm = getHierarchyManager();
482 if (hm.isExist(destination)) {
483 String parentPath = StringUtils.substringBeforeLast(destination, "/");
484 String label = StringUtils.substringAfterLast(destination, "/");
485 label = Path.getUniqueLabel(getHierarchyManager(), parentPath, label);
486 destination = parentPath + "/" + label;
487 }
488 if (move) {
489 if (destination.indexOf(source + "/") == 0) {
490
491
492 return null;
493 }
494 try {
495 hm.moveTo(source, destination);
496 }
497 catch (Exception e) {
498
499 return null;
500 }
501 }
502 else {
503
504 hm.copyTo(source, destination);
505 }
506 Content newContent = hm.getContent(destination);
507 try {
508 newContent.updateMetaData();
509 if (!move) {
510
511 newContent.getMetaData().setUnActivated();
512 }
513 updateChildMetaData(move, newContent);
514 }
515 catch (Exception e) {
516 if (log.isDebugEnabled()) {
517 log.debug("Exception caught: " + e.getMessage(), e);
518 }
519 }
520 newContent.save();
521 return newContent;
522 }
523
524 private void updateChildMetaData(boolean move, Content newContent) throws RepositoryException, AccessDeniedException {
525
526 for (Iterator iter = newContent.getChildren().iterator(); iter.hasNext();) {
527 Content child = (Content) iter.next();
528 child.updateMetaData();
529 if (!move) {
530
531 child.getMetaData().setUnActivated();
532 }
533 updateChildMetaData(move, child);
534 }
535 }
536
537 public void moveNode(String source, String destination) throws ExchangeException, RepositoryException {
538 this.copyMoveNode(source, destination, true);
539 }
540
541 public void copyNode(String source, String destination) throws ExchangeException, RepositoryException {
542 this.copyMoveNode(source, destination, false);
543 }
544
545 public String renameNode(String newLabel) throws AccessDeniedException, ExchangeException, PathNotFoundException,
546 RepositoryException {
547 String returnValue;
548 String parentPath = StringUtils.substringBeforeLast(this.getPath(), "/");
549 newLabel = Path.getValidatedLabel(newLabel);
550
551
552 if (this.getPath().endsWith("/" + newLabel)) {
553 return newLabel;
554 }
555
556 String dest = parentPath + "/" + newLabel;
557 if (getHierarchyManager().isExist(dest)) {
558 newLabel = Path.getUniqueLabel(getHierarchyManager(), parentPath, newLabel);
559 dest = parentPath + "/" + newLabel;
560 }
561
562
563
564 log.info("Moving node from " + this.getPath() + " to " + dest);
565 if (getHierarchyManager().isNodeData(this.getPath())) {
566 Content parentPage = getHierarchyManager().getContent(parentPath);
567 NodeData newNodeData = parentPage.createNodeData(newLabel);
568 NodeData existingNodeData = getHierarchyManager().getNodeData(this.getPath());
569 newNodeData.setValue(existingNodeData.getString());
570 existingNodeData.delete();
571 dest = parentPath;
572 }
573 else {
574 Content current = getHierarchyManager().getContent(this.getPath());
575 ContentUtil.rename(current, newLabel);
576 current.getParent().save();
577 }
578
579 Content newPage = getHierarchyManager().getContent(dest);
580 returnValue = newLabel;
581 newPage.updateMetaData();
582 newPage.save();
583
584 return returnValue;
585 }
586
587
588
589
590
591 public String saveValue() {
592 String saveName = this.getRequest().getParameter("saveName");
593 Tree tree = getTree();
594
595
596 boolean isNodeDataValue = "true".equals(this.getRequest().getParameter("isNodeDataValue"));
597
598
599 boolean isNodeDataType = "true".equals(this.getRequest().getParameter("isNodeDataType"));
600
601 String value = StringUtils.defaultString(this.getRequest().getParameter("saveValue"));
602 displayValue = StringUtils.EMPTY;
603
604 boolean isMeta = "true".equals(this.getRequest().getParameter("isMeta"));
605
606 boolean isLabel = "true".equals(this.getRequest().getParameter("isLabel"));
607
608 if (isNodeDataValue || isNodeDataType) {
609 tree.setPath(StringUtils.substringBeforeLast(path, "/"));
610 saveName = StringUtils.substringAfterLast(path, "/");
611 }
612 else {
613
614 tree.setPath(path);
615 }
616
617 if (isLabel) {
618 displayValue = rename(value);
619 }
620 else if (isNodeDataType) {
621 int type = Integer.valueOf(value).intValue();
622 synchronized (ExclusiveWrite.getInstance()) {
623 displayValue = tree.saveNodeDataType(saveName, type);
624 }
625 }
626 else {
627 synchronized (ExclusiveWrite.getInstance()) {
628 displayValue = tree.saveNodeData(saveName, value, isMeta);
629 }
630 }
631
632
633 displayValue = StringUtils.defaultString(this.getRequest().getParameter("displayValue"), value);
634
635 return VIEW_VALUE;
636 }
637
638
639
640
641
642
643 protected String rename(String value) {
644 try {
645 synchronized (ExclusiveWrite.getInstance()) {
646 return renameNode(value);
647 }
648 }
649 catch (Exception e) {
650 log.error("can't rename", e);
651 AlertUtil.setMessage(MessagesManager.get("tree.error.rename") + " " + AlertUtil.getExceptionMessage(e));
652 }
653 return StringUtils.EMPTY;
654 }
655
656 public String pasteNode(String pathOrigin, String pathSelected, int pasteType, int action)
657 throws ExchangeException, RepositoryException {
658 boolean move = false;
659 if (action == Tree.ACTION_MOVE) {
660 move = true;
661 }
662 String label = StringUtils.substringAfterLast(pathOrigin, "/");
663 String slash = "/";
664 if (pathSelected.equals("/")) {
665 slash = StringUtils.EMPTY;
666 }
667 String destination = pathSelected + slash + label;
668 if (pasteType == Tree.PASTETYPE_SUB && action != Tree.ACTION_COPY && destination.equals(pathOrigin)) {
669
670 pasteType = Tree.PASTETYPE_LAST;
671 }
672 if (pasteType == Tree.PASTETYPE_SUB) {
673 destination = pathSelected + slash + label;
674 Content touchedContent = this.copyMoveNode(pathOrigin, destination, move);
675 if (touchedContent == null) {
676 return StringUtils.EMPTY;
677 }
678 return touchedContent.getHandle();
679
680 }
681 else if (pasteType == Tree.PASTETYPE_LAST) {
682
683 try {
684 Content touchedContent = getHierarchyManager().getContent(pathOrigin);
685 return touchedContent.getHandle();
686 }
687 catch (RepositoryException re) {
688 return StringUtils.EMPTY;
689 }
690 }
691 else {
692 try {
693
694 String nameSelected = StringUtils.substringAfterLast(pathSelected, "/");
695 String nameOrigin = StringUtils.substringAfterLast(pathOrigin, "/");
696 Content tomove = getHierarchyManager().getContent(pathOrigin);
697 Content selected = getHierarchyManager().getContent(pathSelected);
698
699
700 if (tomove.getParent().getHandle().equals(selected.getParent().getHandle())) {
701
702 if (move) {
703 tomove.getParent().orderBefore(nameOrigin, nameSelected);
704
705 tomove.updateMetaData();
706
707 tomove.getParent().save();
708 }
709 else {
710 Content newNode = this.copyMoveNode(pathOrigin, pathOrigin, move);
711 tomove.getParent().orderBefore(newNode.getName(), nameSelected);
712 tomove.getParent().save();
713 }
714
715 }
716 else {
717 String newOrigin = selected.getParent().getHandle() + "/" + nameOrigin;
718
719 if (newOrigin.startsWith("//")) {
720 newOrigin = StringUtils.removeStart(newOrigin, "/");
721 }
722 Content newNode;
723 if (move) {
724 getHierarchyManager().moveTo(pathOrigin, newOrigin);
725 newNode = getHierarchyManager().getContent(newOrigin);
726 }
727 else {
728 newNode = this.copyMoveNode(pathOrigin, newOrigin, move);
729 }
730
731 if (pasteType == Tree.PASTETYPE_ABOVE) {
732 newNode.getParent().orderBefore(newNode.getName(), nameSelected);
733 newNode.getParent().save();
734 }
735 }
736 return tomove.getHandle();
737 }
738 catch (RepositoryException re) {
739 re.printStackTrace();
740 log.error("Problem when pasting node", re);
741 return StringUtils.EMPTY;
742 }
743 }
744 }
745
746
747
748
749
750
751 public void renderHtml(String view) throws IOException {
752 StringBuffer html = new StringBuffer(500);
753
754
755 if (AlertUtil.isMessageSet()) {
756 html.append("<input type=\"hidden\" id=\"mgnlMessage\" value=\"");
757 html.append(ControlImpl.escapeHTML(AlertUtil.getMessage()));
758 html.append("\" />");
759 }
760
761 if (VIEW_TREE.equals(view) || VIEW_CREATE.equals(view) || VIEW_COPY_MOVE.equals(view)) {
762
763 if (!view.equals(VIEW_CREATE)) {
764 getTree().setPathOpen(pathOpen);
765 getTree().setPathSelected(pathSelected);
766 }
767
768
769 if (view.equals(VIEW_COPY_MOVE)) {
770
771
772 html.append("<input type=\"hidden\" id=\"mgnlSelectNode\" value=\"");
773 html.append(newPath);
774 html.append("\" />");
775 }
776
777 renderTree(html);
778 }
779
780
781 else if (view.equals(VIEW_VALUE)) {
782 html.append(displayValue);
783 }
784 this.getResponse().getWriter().print(html);
785 }
786
787
788
789
790
791 protected void renderTree(StringBuffer html) {
792 String mode = StringUtils.defaultString(this.getRequest().getParameter("treeMode"));
793 boolean snippetMode = mode.equals("snippet");
794 Tree tree = getTree();
795
796 tree.setJavascriptTree("mgnlTreeControl");
797 tree.setBrowseMode(this.isBrowseMode());
798
799 if (!snippetMode) {
800
801
802 html.append("<html>\n");
803 html.append("<head>\n");
804 html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
805 renderHeaderIncludes(html);
806 html.append("<title>Magnolia</title>\n");
807 html.append("</head>\n");
808 html.append("<body class=\"mgnlBgDark\">");
809 }
810
811 tree.setSnippetMode(snippetMode);
812 tree.setHeight(50);
813
814 tree.setPath(path);
815
816 this.getConfiguration().prepareTree(tree, this.isBrowseMode(), this.getRequest());
817 this.getConfiguration().prepareContextMenu(tree, this.isBrowseMode(), this.getRequest());
818 this.getConfiguration().prepareFunctionBar(tree, this.isBrowseMode(), this.getRequest());
819
820 if (!snippetMode) {
821 html.append("<div id=\"");
822 html.append(tree.getJavascriptTree());
823 html.append("_DivSuper\" style=\"display:block;\">");
824 }
825 html.append(tree.getHtml());
826 if (!snippetMode) {
827 html.append("</div>");
828 }
829
830 if (!snippetMode) {
831 html.append("</body></html>");
832 }
833 }
834
835
836
837
838 protected void renderHeaderIncludes(StringBuffer html) {
839 html.append(new Sources(this.getRequest().getContextPath()).getHtmlJs());
840 html.append(new Sources(this.getRequest().getContextPath()).getHtmlCss());
841 }
842
843 protected void setTree(Tree tree) {
844 this.tree = tree;
845 }
846
847 protected Tree getTree() {
848 if (tree == null) {
849 tree = Classes.quietNewInstance(getTreeClass(), getName(), getRepository());
850
851 if (tree == null) {
852
853 log.warn("The {} Tree class is probably using the deprecated (String name, String repository, HttpServletRequest request) constructor. Please use the (String name, String repository) constructor instead.", getTreeClass());
854 tree = Classes.quietNewInstance(this.getTreeClass(), getName(), getRepository(), getRequest());
855 }
856 tree.setRootPath(this.getRootPath());
857 }
858 return tree;
859 }
860
861
862 public String getNewNodeName() {
863 return this.newNodeName;
864 }
865
866
867 public void setNewNodeName(String newNodeName) {
868 this.newNodeName = newNodeName;
869 }
870
871 protected String getPath() {
872 return path;
873 }
874
875 protected String getPathSelected() {
876 return pathSelected;
877 }
878
879
880 public String getCreateItemType() {
881 return this.createItemType;
882 }
883
884
885 public void setCreateItemType(String createItemType) {
886 this.createItemType = createItemType;
887 }
888
889
890
891
892 public boolean isBrowseMode() {
893 return browseMode;
894 }
895
896
897
898
899 public void setBrowseMode(boolean browseMode) {
900 this.browseMode = browseMode;
901 }
902
903
904
905
906
907
908 public AdminTreeConfiguration getConfiguration() {
909 if (this.configuration == null) {
910 if (getConfigurationClass() == null) {
911 return null;
912 }
913 final AdminTreeConfiguration treeConfiguration = Classes.quietNewInstance(getConfigurationClass());
914 setConfiguration(treeConfiguration);
915 }
916 return this.configuration;
917 }
918
919
920
921
922 public void setConfiguration(AdminTreeConfiguration configuration) {
923 this.configuration = configuration;
924 final Messages messages = MessagesUtil.chainWithDefault(getI18nBasename());
925 configuration.setMessages(messages);
926 if (configuration instanceof AbstractTreeConfiguration) {
927 ((AbstractTreeConfiguration) configuration).setEnableDeleteConfirmation(isEnableDeleteConfirmation());
928 }
929 }
930
931 public String getConfigurationClass() {
932 return configurationClass;
933 }
934
935 public void setConfigurationClass(String configClass) {
936 this.configurationClass = configClass;
937 }
938
939 public String getTreeClass() {
940 return treeClass;
941 }
942
943 public void setTreeClass(String treeClass) {
944 this.treeClass = treeClass;
945 }
946
947 public String getI18nBasename() {
948 return i18nBasename;
949 }
950
951 public void setI18nBasename(String i18nBasename) {
952 this.i18nBasename = i18nBasename;
953 }
954
955 public String getRootPath() {
956 return rootPath;
957 }
958
959 public void setRootPath(String rootPath) {
960 this.rootPath = rootPath;
961 }
962
963 public boolean isEnableDeleteConfirmation() {
964 return enableDeleteConfirmation;
965 }
966
967 public void setEnableDeleteConfirmation(boolean enableConfirmation) {
968 this.enableDeleteConfirmation = enableConfirmation;
969 AdminTreeConfiguration conf = getConfiguration();
970 if (conf != null && conf instanceof AbstractTreeConfiguration) {
971 ((AbstractTreeConfiguration) conf).setEnableDeleteConfirmation(isEnableDeleteConfirmation());
972 }
973 }
974 }