1 19 20 package com.sslexplorer.properties.attributes.forms; 21 22 import java.util.Collection ; 23 24 import javax.servlet.http.HttpSession ; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 import org.apache.struts.util.MessageResources; 29 30 import com.sslexplorer.core.CoreUtil; 31 import com.sslexplorer.properties.attributes.AttributeDefinition; 32 import com.sslexplorer.properties.attributes.AttributeDefinitionItem; 33 import com.sslexplorer.table.AbstractTableItemTableModel; 34 import com.sslexplorer.table.forms.AbstractPagerForm; 35 36 42 public class AttributeDefinitionsForm extends AbstractPagerForm { 43 44 static Log log = LogFactory.getLog(AttributeDefinitionsForm.class); 45 46 private String propertyClassName; 47 48 51 public AttributeDefinitionsForm() { 52 super(new AttributeDefinitionsModel()); 53 } 54 55 62 public void initialize(HttpSession session, Collection <AttributeDefinition> definitions) throws Exception { 63 super.initialize(session, "name"); 64 for (AttributeDefinition def : definitions) { 65 if(def.isHidden()) 66 continue; 67 MessageResources mr = null; 68 if(def.getMessageResourcesKey() != null) { 69 mr = CoreUtil.getMessageResources(session, def.getMessageResourcesKey()); 70 } 71 AttributeDefinitionItem item = new AttributeDefinitionItem(def, mr); 72 getModel().addItem(item); 73 } 74 getPager().rebuild(getFilterText()); 75 } 76 77 82 public String getPropertyClassName() { 83 return propertyClassName; 84 } 85 86 91 public void setPropertyClassName(String propertyClassName) { 92 this.propertyClassName = propertyClassName; 93 } 94 95 98 99 104 static class AttributeDefinitionsModel extends AbstractTableItemTableModel { 105 106 111 public int getColumnWidth(int col) { 112 return 0; 113 } 114 115 120 public String getId() { 121 return "attributeDefinitions"; 122 } 123 124 129 public int getColumnCount() { 130 return 2; 131 } 132 133 138 public String getColumnName(int col) { 139 switch (col) { 140 case 0: 141 return "name"; 142 default: 143 return "label"; 144 } 145 } 146 147 152 public Class getColumnClass(int col) { 153 return String .class; 154 } 155 156 } 157 } 158 | Popular Tags |