BrightSide Workbench Full Report + Source Code
Labels.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 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.zkoss.label;
20 
21 import java.util.function.Consumer;
22 import org.turro.string.Strings;
23 import org.zkoss.zul.Label;
24 
29 public class Labels {
30 
31  public Labels width(String width) {
32  label.setWidth(width);
33  return this;
34  }
35 
36  public Labels height(String height) {
37  label.setHeight(height);
38  return this;
39  }
40 
41  public Labels hflex(String flex) {
42  label.setHflex(flex);
43  return this;
44  }
45 
46  public Labels vflex(String flex) {
47  label.setVflex(flex);
48  return this;
49  }
50 
51  public Labels style(String style) {
52  label.setStyle(style);
53  return this;
54  }
55 
56  public Labels maxlength(int maxlength) {
57  label.setMaxlength(maxlength);
58  return this;
59  }
60 
61  public Labels tooltiptext(String text) {
62  label.setTooltiptext(text);
63  return this;
64  }
65 
66  public Labels soft() {
67  return cssClass("softLabel");
68  }
69 
70  public Labels tiny() {
71  return cssClass("tinyLabel");
72  }
73 
74  public Labels caption() {
75  return cssClass("captionLabel");
76  }
77 
78  public Labels pre() {
79  label.setPre(true);
80  return cssClass("preLabel");
81  }
82 
83  public Labels cssClass(String cssClass) {
84  label.setSclass(cssClass);
85  return this;
86  }
87 
88  public Labels multiline() {
89  label.setMultiline(true);
90  return this;
91  }
92 
93  public Labels max(int maxChars) {
94  return tooltiptext(label.getValue())
95  .value(Strings.truncateAndWarn(label.getValue(), maxChars));
96  }
97 
98  public Labels value(String text) {
99  label.setValue(text);
100  return this;
101  }
102 
103  public Labels focus() {
104  label.setFocus(true);
105  return this;
106  }
107 
108  public Label get() {
109  return label;
110  }
111 
112  public Label get(Consumer<Label> onGet) {
113  onGet.accept(label);
114  return label;
115  }
116 
117  /* Factory */
118 
119  public static Labels text(String text) {
120  return new Labels(text);
121  }
122 
123  private final Label label;
124 
125  private Labels(String text) {
126  this.label = new Label(text);
127  }
128 
129 }
Labels maxlength(int maxlength)
Definition: Labels.java:56
static Labels text(String text)
Definition: Labels.java:119
Labels width(String width)
Definition: Labels.java:31
Labels max(int maxChars)
Definition: Labels.java:93
Labels height(String height)
Definition: Labels.java:36
Labels vflex(String flex)
Definition: Labels.java:46
Labels hflex(String flex)
Definition: Labels.java:41
Labels cssClass(String cssClass)
Definition: Labels.java:83
Labels style(String style)
Definition: Labels.java:51
Labels value(String text)
Definition: Labels.java:98
Labels tooltiptext(String text)
Definition: Labels.java:61