BrightSide Workbench Full Report + Source Code
ClassesListbox.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2014 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.zul.fieldit;
20 
21 import java.util.Date;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.elephant.context.ElephantContext;
25 import org.turro.fieldit.AutoFillList;
26 import org.turro.fieldit.StringList;
27 import org.turro.i18n.I_;
28 import org.zkoss.zul.Listbox;
29 import org.zkoss.zul.Listitem;
30 
35 public class ClassesListbox extends Listbox {
36 
37  public ClassesListbox() {
38  appendItem(I_.get("String"), String.class.getName()).setSelected(true);
39  appendItem(I_.get("Long integer"), Long.class.getName());
40  appendItem(I_.get("Double"), Double.class.getName());
41  appendItem(I_.get("Date"), Date.class.getName());
42  appendItem(I_.get("Boolean"), Boolean.class.getName());
43  appendItem(I_.get("String list"), StringList.class.getName());
44  appendItem(I_.get("Auto fill list"), AutoFillList.class.getName());
45  }
46 
47  public void setObjectValue(Class javaClass) {
48  if(javaClass != null) {
49  for(Listitem li : getItems()) {
50  if(((String) li.getValue()).equals(javaClass.getName())) {
51  li.setSelected(true);
52  }
53  }
54  }
55  }
56 
57  public Class getObjectValue() {
58  if(getSelectedItem() != null) {
59  try {
60  return Class.forName((String) getSelectedItem().getValue());
61  } catch (ClassNotFoundException ex) {
62  Logger.getLogger(ClassesListbox.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
63  }
64  }
65  return null;
66  }
67 
68 }
static String get(String msg)
Definition: I_.java:41