BrightSide Workbench Full Report + Source Code
LabelValueGrid.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.zkoss.label;
19 
20 import org.zkoss.zk.ui.HtmlBasedComponent;
21 import org.zkoss.zul.Cell;
22 import org.zkoss.zul.Grid;
23 import org.zkoss.zul.Rows;
24 import org.zkoss.zul.Separator;
25 
30 public class LabelValueGrid extends Grid {
31 
32  private Rows rows;
33  private String labelStyle = "color:gray;padding-right:10px;", valueStyle = "";
34 
35  public LabelValueGrid() {
36  setSclass("none");
37  setZclass("none");
38  setOddRowSclass("none");
39  }
40 
41  public String getLabelStyle() {
42  return labelStyle;
43  }
44 
45  public void setLabelStyle(String labelStyle) {
46  this.labelStyle = labelStyle;
47  }
48 
49  public String getValueStyle() {
50  return valueStyle;
51  }
52 
53  public void setValueStyle(String valueStyle) {
54  this.valueStyle = valueStyle;
55  }
56 
57  public LabelValueRow addLabelValue(HtmlBasedComponent label, HtmlBasedComponent value) {
58  if(rows == null) {
59  rows = new Rows();
60  appendChild(rows);
61  }
62  if(labelStyle != null) label.setStyle(labelStyle);
63  if(valueStyle != null) value.setStyle(valueStyle);
64  LabelValueRow row = new LabelValueRow();
65  row.appendChild(label);
66  row.appendChild(value);
67  rows.appendChild(row);
68  return row;
69  }
70 
71  public LabelValueRow addCaptionValue(HtmlBasedComponent caption, HtmlBasedComponent value) {
72  if(rows == null) {
73  rows = new Rows();
74  appendChild(rows);
75  }
76  if(labelStyle != null) caption.setStyle(labelStyle);
77  if(valueStyle != null) value.setStyle(valueStyle);
78  LabelValueRow row = new LabelValueRow();
79  Cell cell = new Cell();
80  cell.setColspan(2);
81  cell.appendChild(caption);
82  row.appendChild(cell);
83  rows.appendChild(row);
84  row = new LabelValueRow();
85  cell = new Cell();
86  cell.setColspan(2);
87  cell.appendChild(value);
88  row.appendChild(cell);
89  rows.appendChild(row);
90  return row;
91  }
92 
93  public LabelValueRow addButton(HtmlBasedComponent button) {
94  if(rows == null) {
95  rows = new Rows();
96  appendChild(rows);
97  }
98  LabelValueRow row = new LabelValueRow();
99  Cell cell = new Cell();
100  cell.setColspan(2);
101  cell.appendChild(button);
102  row.appendChild(cell);
103  rows.appendChild(row);
104  return row;
105  }
106 
107  public void addSpace(String spacing) {
108  if(rows == null) {
109  rows = new Rows();
110  appendChild(rows);
111  }
112  LabelValueRow row = new LabelValueRow();
113  Separator separator = new Separator("vertical");
114  separator.setSpacing(spacing);
115  Cell cell = new Cell();
116  cell.setColspan(2);
117  cell.appendChild(separator);
118  row.appendChild(cell);
119  rows.appendChild(row);
120  }
121 
122 }
void setValueStyle(String valueStyle)
void setLabelStyle(String labelStyle)
LabelValueRow addCaptionValue(HtmlBasedComponent caption, HtmlBasedComponent value)
LabelValueRow addLabelValue(HtmlBasedComponent label, HtmlBasedComponent value)
LabelValueRow addButton(HtmlBasedComponent button)