Changeset 3864


Ignore:
Timestamp:
Sep 20, 2010, 11:31:11 AM (13 years ago)
Author:
Gregory Vincic
Message:

Refs #698. Removed method getFileProtocolForm from FormFactory. Decided to put this form creation within the action class that uses it.

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  
    1515import org.proteios.core.File;
    1616import org.proteios.core.ItemFactory;
     17import org.proteios.core.ItemResultList;
     18import org.proteios.core.ItemQuery;
    1719import org.proteios.core.ProtocolType;
     20import org.proteios.core.query.Orders;
     21import org.proteios.core.query.Hql;
    1822import org.proteios.gui.Title;
    1923import org.proteios.gui.Toolbar;
     
    2327import se.lu.thep.waf.ActionException;
    2428import se.lu.thep.waf.constraints.InvalidParameterValue;
     29import se.lu.thep.waf.constraints.VString;
    2530
    2631/**
     
    3136    implements ContextEnabled
    3237{
     38  public static final VString VTYPE = new VString("type", 1, 64, true);
     39
    3340  @Override
    3441  protected void runMe()
     
    6471    log.debug("fileId = " + fileId);
    6572    log.debug("file = " + file);
    66     Form form = getFormFactory().getFileProtocolForm(file, null);
     73    Form form = getFileProtocolForm(file, null);
    6774    /*
    6875     * Add the selected file ids to the forms first file set
     
    93100
    94101
     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
    95148  public List<Context> listContexts()
    96149  {
  • trunk/client/servlet/src/org/proteios/gui/form/FormFactory.java

    r3863 r3864  
    60406040
    60416041
    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 Name
    6049     TextField<String> nameF = new NameField();
    6050     fs.add(nameF);
    6051     // Protocol Description
    6052     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 Box
    6060     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 
    60876042  /**
    60886043   * Form for new Protocol item. The difference between calling
Note: See TracChangeset for help on using the changeset viewer.