Changeset 3864
- Timestamp:
- Sep 20, 2010, 11:31:11 AM (13 years ago)
- Location:
- trunk/client/servlet/src/org/proteios
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/src/org/proteios/action/file/SelectProtocolType.java
r3851 r3864 15 15 import org.proteios.core.File; 16 16 import org.proteios.core.ItemFactory; 17 import org.proteios.core.ItemResultList; 18 import org.proteios.core.ItemQuery; 17 19 import org.proteios.core.ProtocolType; 20 import org.proteios.core.query.Orders; 21 import org.proteios.core.query.Hql; 18 22 import org.proteios.gui.Title; 19 23 import org.proteios.gui.Toolbar; … … 23 27 import se.lu.thep.waf.ActionException; 24 28 import se.lu.thep.waf.constraints.InvalidParameterValue; 29 import se.lu.thep.waf.constraints.VString; 25 30 26 31 /** … … 31 36 implements ContextEnabled 32 37 { 38 public static final VString VTYPE = new VString("type", 1, 64, true); 39 33 40 @Override 34 41 protected void runMe() … … 64 71 log.debug("fileId = " + fileId); 65 72 log.debug("file = " + file); 66 Form form = getF ormFactory().getFileProtocolForm(file, null);73 Form form = getFileProtocolForm(file, null); 67 74 /* 68 75 * Add the selected file ids to the forms first file set … … 93 100 94 101 102 103 public Form getFileProtocolForm(File file, ProtocolType protocolType) 104 { 105 Form form = new Form("FileProtocol"); 106 form.setTitle("Protocol"); 107 Fieldset fs = new Fieldset(); 108 fs.setTitle("Protocol"); 109 // Protocol Name 110 TextField<String> nameF = new NameField(); 111 fs.add(nameF); 112 // Protocol Description 113 TextArea descF = new DescriptionField(); 114 fs.add(descF); 115 if (file != null) 116 { 117 nameF.setValue(file.getName()); 118 descF.setValue(file.getDescription()); 119 } 120 // Protocol Type Select Box 121 Select<VString> typeS = new Select<VString>(VTYPE); 122 typeS.setLabel("ProtocolType"); 123 DbControl dc = file.getDbControl(); 124 ItemQuery<ProtocolType> query = ProtocolType.getQuery(); 125 query.order(Orders.asc(Hql.property("name"))); 126 ItemResultList<ProtocolType> types = query.list(dc); 127 // 128 for (ProtocolType type : types) 129 { 130 Option o = new Option(type.getSystemId()); 131 o.setContent(type.getName()); 132 typeS.addOption(o); 133 if (protocolType != null) 134 { 135 if (type.equals(protocolType)) 136 { 137 o.setSelected(true); 138 } 139 } 140 } 141 dc.close(); 142 fs.add(typeS); 143 form.addFieldset(fs); 144 return form; 145 } 146 147 95 148 public List<Context> listContexts() 96 149 { -
trunk/client/servlet/src/org/proteios/gui/form/FormFactory.java
r3863 r3864 6040 6040 6041 6041 6042 public Form getFileProtocolForm(File file, ProtocolType protocolType)6043 {6044 Form form = new Form("FileProtocol");6045 form.setTitle("Protocol");6046 Fieldset fs = new Fieldset();6047 fs.setTitle("Protocol");6048 // Protocol Name6049 TextField<String> nameF = new NameField();6050 fs.add(nameF);6051 // Protocol Description6052 TextArea descF = new DescriptionField();6053 fs.add(descF);6054 if (file != null)6055 {6056 nameF.setValue(file.getName());6057 descF.setValue(file.getDescription());6058 }6059 // Protocol Type Select Box6060 Select<VString> typeS = new Select<VString>(VTYPE);6061 typeS.setLabel("ProtocolType");6062 DbControl dc = sc.newDbControl();6063 ItemQuery<ProtocolType> query = ProtocolType.getQuery();6064 query.order(Orders.asc(Hql.property("name")));6065 ItemResultList<ProtocolType> types = query.list(dc);6066 //6067 for (ProtocolType type : types)6068 {6069 Option o = new Option(type.getSystemId());6070 o.setContent(type.getName());6071 typeS.addOption(o);6072 if (protocolType != null)6073 {6074 if (type.equals(protocolType))6075 {6076 o.setSelected(true);6077 }6078 }6079 }6080 dc.close();6081 fs.add(typeS);6082 form.addFieldset(fs);6083 return form;6084 }6085 6086 6087 6042 /** 6088 6043 * Form for new Protocol item. The difference between calling
Note: See TracChangeset
for help on using the changeset viewer.