BrightSide Workbench Full Report + Source Code
FilesTree.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2014 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.configuration;
20 
21 import java.io.File;
22 import org.turro.elephant.context.ElephantContext;
23 import org.turro.i18n.I_;
24 import org.zkoss.zk.ui.ext.AfterCompose;
25 import org.zkoss.zul.Tree;
26 import org.zkoss.zul.Treechildren;
27 import org.zkoss.zul.Treeitem;
28 
33 public class FilesTree extends Tree implements AfterCompose {
34 
36  return (FilesItem) getSelectedItem();
37  }
38 
40  return (FilesItem) getSelectedItem().getParentItem();
41  }
42 
44  FilesItem folder = getSelectedFile();
45  if(folder != null && folder.getCurrentFile().isFile()) {
46  folder = getSelectedFileParent();
47  }
48  return folder;
49  }
50 
51  public void selectFile(File file, Treeitem parent) {
52  for(Treeitem ti : parent.getTreechildren().getItems()) {
53  if(file.equals(ti.getValue())) {
54  setSelectedItem(ti);
55  return;
56  }
57  }
58  }
59 
60  @Override
61  public void afterCompose() {
62  Treechildren children = new Treechildren();
63  appendChild(children);
64  FilesItem configuration = new FilesItem(null, I_.get("Configuration"), null);
65  configuration.addFile(new FilesItem(new File(
66  ElephantContext.getRealPath("/WEB-INF/elephant/conf/site.xml")),
67  null, null));
68  configuration.addFile(new FilesItem(new File(
69  ElephantContext.getRealPath("/WEB-INF/elephant/conf/shop.xml")),
70  null, null));
71  configuration.addFile(new FilesItem(new File(
72  ElephantContext.getRealPath("/WEB-INF/elephant/conf")),
73  I_.get("Properties"), ".*\\.properties"));
74  configuration.addFile(new FilesItem(new File(
75  ElephantContext.getRealPath("/WEB-INF/classes")),
76  I_.get("Resources"), "by-key-site_en\\.properties"));
77  configuration.addFile(new FilesItem(new File(
78  ElephantContext.getRealPath("/WEB-INF/elephant/conf")),
79  I_.get("Search"), "dao-search.*\\.xml"));
80  configuration.addFile(new FilesItem(new File(
81  ElephantContext.getRealPath("/WEB-INF/elephant/conf")),
82  "JSON", ".*\\.json"));
83  configuration.addFile(new FilesItem(new File(
84  ElephantContext.getRealPath("/WEB-INF/elephant/conf/mail")),
85  "Mail providers", ".*\\.json"));
86  File scripts = new File(ElephantContext.getRealPath("/WEB-INF/elephant/scripts"));
87  if(scripts.exists()) {
88  configuration.addFile(new FilesItem(scripts,
89  "Scripts", ".*\\.js"));
90  }
91  children.appendChild(configuration);
92  File support = new File(ElephantContext.getRealPath("/WEB-INF/elephant/support"));
93  if(support.exists()) {
94  children.appendChild(new FilesItem(support,
95  I_.get("Support"), null));
96  }
97  FilesItem css = new FilesItem(null, I_.get("Cascading Style Sheets"), null);
98  FilesItem cssTmpl = new FilesItem(null, I_.get("Templates"), null);
99  cssTmpl.addFile(new FilesItem(new File(
100  ElephantContext.getRealPath("/_internal/css/elephant-branding-semantic.css")),
101  null, null));
102  css.addFile(cssTmpl);
103  children.appendChild(css);
104  File tmplMail = new File(ElephantContext.getRealPath("/WEB-INF/elephant/templates-mail"));
105  if(tmplMail.exists()) {
106  children.appendChild(new FilesItem(tmplMail,
107  I_.get("Templates") + "-mail", null));
108  }
109  File tmplSemantic = new File(ElephantContext.getRealPath("/WEB-INF/elephant/templates-semantic"));
110  if(tmplSemantic.exists()) {
111  children.appendChild(new FilesItem(tmplSemantic,
112  I_.get("Templates") + "-semantic", null));
113  }
114  File tmplSemanticApp = new File(ElephantContext.getRealPath("/WEB-INF/elephant/templates-semantic-app"));
115  if(tmplSemanticApp.exists()) {
116  children.appendChild(new FilesItem(tmplSemanticApp,
117  I_.get("Templates") + "-semantic-app", null));
118  }
119  File reports = new File(ElephantContext.getRealPath("/WEB-INF/elephant/reports/financials"));
120  if(reports.exists()) {
121  children.appendChild(new FilesItem(reports,
122  I_.get("Reports"), null));
123  }
124  File tou = new File(ElephantContext.getRealPath("/_internal/terms"));
125  if(tou.exists()) {
126  children.appendChild(new FilesItem(tou,
127  I_.get("Terms of Use"), null));
128  }
129  FilesItem wiki = new FilesItem(null, "Wiki", null);
130  File wtmpl = new File(ElephantContext.getRealPath("/WEB-INF/elephant/wiki/templates"));
131  if(wtmpl.exists()) {
132  wiki.addFile(new FilesItem(wtmpl, "Templates", ".*\\.wiki"));
133  }
134  File wsnip = new File(ElephantContext.getRealPath("/WEB-INF/elephant/wiki/snippets"));
135  if(wsnip.exists()) {
136  wiki.addFile(new FilesItem(wsnip, "Snippets", ".*\\.wiki"));
137  }
138  children.appendChild(wiki);
139  }
140 
141 }
void selectFile(File file, Treeitem parent)
Definition: FilesTree.java:51
static String get(String msg)
Definition: I_.java:41