BrightSide Workbench Full Report + Source Code
RepositoryGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 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.file.zul.repository;
20 
21 import java.io.File;
22 import org.turro.file.zul.navigator.FileRow;
23 import org.turro.i18n.I_;
24 import org.turro.zkoss.grid.PagingGrid;
25 import org.zkoss.zk.ui.ext.AfterCompose;
26 import org.zkoss.zul.Column;
27 import org.zkoss.zul.Columns;
28 
33 public class RepositoryGrid extends PagingGrid implements AfterCompose {
34 
35  private RepositoryItem currentFolder;
36  private boolean readOnly;
37 
38  public RepositoryGrid() {
39  addColumns();
40  }
41 
42  public boolean isReadOnly() {
43  return readOnly;
44  }
45 
46  public void setReadOnly(boolean readOnly) {
47  this.readOnly = readOnly;
48  }
49 
51  return currentFolder;
52  }
53 
54  public void setCurrentFolder(RepositoryItem currentFolder) {
55  this.currentFolder = currentFolder;
56  populateList();
57  }
58 
59  private void populateList() {
60  getRows(true).getChildren().clear();
61  if(currentFolder != null) {
62  for(RepositoryItem f : currentFolder.getFileFolders()) {
63  getRows(true).appendChild(new FolderRow(f));
64  }
65  for(File a : currentFolder.getFiles()) {
66  getRows(true).appendChild(new FileRow(a, readOnly));
67  }
68  }
69  setRowCount(getRows(true).getChildren().size());
70  }
71 
72  @Override
73  public void afterCompose() {
74  }
75 
76  private void addColumns() {
77  Columns cols = getColumns(true);
78 
80 
81  Column col = new Column();
82  col.setLabel(I_.get("Name"));
83  col.setHflex("1");
84  cols.appendChild(col);
85 
86  col = new Column();
87  col.setLabel(I_.get("Size"));
88  col.setAlign("right");
89  col.setWidth("120px");
90  cols.appendChild(col);
91 
92  col = new Column();
93  col.setLabel(I_.get("Date"));
94  col.setWidth("180px");
95  cols.appendChild(col);
96  }
97 
98 }
99 
void setCurrentFolder(RepositoryItem currentFolder)
static String get(String msg)
Definition: I_.java:41
Columns getColumns(boolean create)
Rows getRows(boolean create)