1 13 package info.magnolia.cms.gui.controlx.search; 14 15 import org.apache.commons.lang.StringUtils; 16 17 18 22 public class SearchControlDefinition { 23 24 27 private String name; 28 29 32 private String column; 33 34 37 private String label; 38 39 42 private String type; 43 44 47 public SearchControlDefinition() { 48 setType("edit"); 49 } 50 51 public SearchControlDefinition(String name, String label) { 52 this(name, label, "edit"); 53 } 54 55 public SearchControlDefinition(String name, String label, String type) { 56 setName(name); 57 setLabel(label); 58 setType(type); 59 } 60 61 public String getJsField() { 62 return this.getName() 63 + ": {name:'" 64 + this.getName() 65 + "', label:'" 66 + this.getLabel() 67 + "', type:'" 68 + this.getType() 69 + "'}"; 70 } 71 72 public SearchControl getSearchControlInstance(String value, String constraint) { 73 if (this.type.equals("date")) { 74 return new DateSearchControl(this, value, constraint); 75 } 76 77 return new SearchControl(this, value, constraint); 78 } 79 80 83 public String getType() { 84 return this.type; 85 } 86 87 90 public void setType(String type) { 91 this.type = type; 92 } 93 94 97 public String getLabel() { 98 return this.label; 99 } 100 101 104 public void setLabel(String label) { 105 this.label = label; 106 } 107 108 111 public String getName() { 112 return this.name; 113 } 114 115 118 public void setName(String name) { 119 if (StringUtils.isEmpty(this.getColumn())) { 120 this.setColumn(name); 121 } 122 this.name = StringUtils.replace(name, ":", "_"); 124 } 125 126 129 public String getColumn() { 130 return this.column; 131 } 132 133 136 public void setColumn(String column) { 137 this.column = column; 138 } 139 140 } 141 | Popular Tags |