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