BrightSide Workbench Full Report + Source Code
EditableColumn.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.grid;
19 
20 import java.util.Date;
21 import org.zkoss.zul.Column;
22 
27 public class EditableColumn extends Column {
28 
29  private boolean onlyDate = true, onlyTime= false, readOnly = false;
30  private String property, format;
31  private Class javaClass = String.class;
32  private int scale = 2;
33  private ChangeValueCallback onCheckDuplicate;
34 
35  public String getFormat() {
36  return format;
37  }
38 
39  public void setFormat(String format) {
40  this.format = format;
41  }
42 
43  public Class getJavaClass() {
44  return javaClass;
45  }
46 
47  public void setJavaClass(Class javaClass) {
48  this.javaClass = javaClass;
49  }
50 
51  public void setJavaClass(String javaClass) throws ClassNotFoundException {
52  if("int".equals(javaClass)) {
53  this.javaClass = int.class;
54  } else if("long".equals(javaClass)) {
55  this.javaClass = long.class;
56  } else if("double".equals(javaClass)) {
57  this.javaClass = double.class;
58  } else if("boolean".equals(javaClass)) {
59  this.javaClass = boolean.class;
60  } else {
61  this.javaClass = Class.forName(javaClass);
62  }
63  }
64 
65  public boolean isOnlyDate() {
66  return onlyDate;
67  }
68 
69  public void setOnlyDate(boolean onlyDate) {
70  this.onlyDate = onlyDate;
71  }
72 
73  public boolean isOnlyTime() {
74  return onlyTime;
75  }
76 
77  public void setOnlyTime(boolean onlyTime) {
78  this.onlyTime = onlyTime;
79  }
80 
81  public String getProperty() {
82  return property;
83  }
84 
85  public void setProperty(String property) {
86  this.property = property;
87  }
88 
89  public boolean isReadOnly() {
90  return readOnly;
91  }
92 
93  public void setReadOnly(boolean readOnly) {
94  this.readOnly = readOnly;
95  }
96 
97  public int getScale() {
98  return scale;
99  }
100 
101  public void setScale(int scale) {
102  this.scale = scale;
103  }
104 
106  return onCheckDuplicate;
107  }
108 
109  public void setOnCheckDuplicate(ChangeValueCallback onCheckDuplicate) {
110  this.onCheckDuplicate = onCheckDuplicate;
111  }
112 
113  public boolean isBoolean() {
114  return Boolean.class.isAssignableFrom(javaClass) ||
115  boolean.class.isAssignableFrom(javaClass);
116  }
117 
118  public boolean isNumber() {
119  return Number.class.isAssignableFrom(javaClass) ||
120  int.class.isAssignableFrom(javaClass) ||
121  long.class.isAssignableFrom(javaClass) ||
122  double.class.isAssignableFrom(javaClass);
123  }
124 
125  public boolean isDate() {
126  return Date.class.isAssignableFrom(javaClass);
127  }
128 }
void setReadOnly(boolean readOnly)
void setJavaClass(String javaClass)
void setOnlyTime(boolean onlyTime)
ChangeValueCallback getOnCheckDuplicate()
void setOnlyDate(boolean onlyDate)
void setOnCheckDuplicate(ChangeValueCallback onCheckDuplicate)