Changeset 2942


Ignore:
Timestamp:
Nov 22, 2006, 1:34:33 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #317: Display and enter dates in different formats

Location:
trunk
Files:
3 added
2 deleted
114 edited
5 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r2875 r2942  
    2525
    2626import net.sf.basedb.core.Coloring;
     27import net.sf.basedb.core.DateUtil;
    2728import net.sf.basedb.core.File;
    2829import net.sf.basedb.core.Location;
     
    6162import net.sf.basedb.util.ColorGenerator;
    6263import net.sf.basedb.util.Values;
     64import net.sf.basedb.util.formatter.Formatter;
     65import net.sf.basedb.clients.web.formatter.FormatterFactory;
    6366import net.sf.basedb.clients.web.util.HTML;
    6467
    6568import java.awt.Color;
     69import java.util.Date;
    6670import java.util.Set;
    6771import java.util.Arrays;
     
    517521                op = Operator.EQ;
    518522                value = value.substring(1);
    519                 if ("".equals(value)) value = null;
    520523              }
    521524              else if (value.indexOf('%') >= 0)
    522525              {
    523526                op = Operator.LIKE;
     527              }
     528              if ("".equals(value)) value = null;
     529              if (valueType == Type.DATE && value != null)
     530              {
     531                // Dates are stored as long timevalues to avoid problems if user
     532                // changes the date format. The date is converted back when displayed
     533                Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     534                try
     535                {
     536                  Date d = dateFormatter != null ? dateFormatter.parseString(value) : DateUtil.parseString(value);
     537                  value = d == null ? null : Long.toString(d.getTime());
     538                }
     539                catch (Throwable t)
     540                {}
    524541              }
    525542              /*
     
    600617    @return A displayable string (null is never returned)
    601618  */
    602   public static String getPropertyFilterString(PropertyFilter filter)
     619  public static String getPropertyFilterString(PropertyFilter filter, Formatter<Date> dateFormatter)
    603620  {
    604621    String result = "";
     
    607624      Operator op = filter.getOperator();
    608625      String value = filter.getValue();
     626      if (filter.getValueType() == Type.DATE && value != null)
     627      {
     628        try
     629        {
     630          // Dates are stored as long time values; reformat according to date formatter
     631          // or as yyyy-MM-dd if no formatter is specified
     632          Date d = new Date(Long.parseLong(value));
     633          if (dateFormatter != null)
     634          {
     635            value = dateFormatter.format(d);
     636          }
     637          else
     638          {
     639            value = DateUtil.formatDate(d);
     640          }
     641        }
     642        catch (Throwable t)
     643        {}
     644      }
    609645      if (op == Operator.EQ && (value == null || (value != null && value.indexOf('%') >= 0)))
    610646      {
     
    926962          else
    927963          {
    928             newAn.setValues(Arrays.asList(valueType.parseStrings(values)));
     964            Object[] oValues = new Object[values.length];
     965            Formatter formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), valueType);
     966            for (int j = 0; j < values.length; ++j)
     967            {
     968              oValues[j] = formatter.parseString(values[j]);
     969            }
     970            newAn.setValues(Arrays.asList(oValues));
    929971          }
    930972        }
  • trunk/src/clients/web/net/sf/basedb/clients/web/DynamicUtil.java

    r2813 r2942  
    4141import net.sf.basedb.core.query.Hql;
    4242import net.sf.basedb.core.query.Orders;
    43 import net.sf.basedb.clients.web.formatter.Formatter;
    4443import net.sf.basedb.clients.web.formatter.FormatterFactory;
    4544import net.sf.basedb.clients.web.taglib.table.TableColumn;
     45import net.sf.basedb.util.formatter.Formatter;
    4646
    4747import java.util.ArrayList;
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r2892 r2942  
    3535
    3636import net.sf.basedb.util.Values;
     37import net.sf.basedb.clients.web.formatter.FormatterFactory;
    3738import net.sf.basedb.core.AnnotationType;
    3839import net.sf.basedb.core.BaseException;
     
    6566import net.sf.basedb.core.query.Selects;
    6667import net.sf.basedb.util.BioAssaySetUtil;
     68import net.sf.basedb.util.formatter.Formatter;
    6769
    6870/**
     
    430432    final ItemQuery<AnnotationType> query = AnnotationType.getQuery(null);
    431433    query.join(Hql.leftJoin("experiments", Item.EXPERIMENT.getAlias()));
    432     query.join(Hql.innerJoin("itemTypes", "itemType"));
     434
     435    // Restriction for experimental factors
    433436    Restriction ef = Restrictions.eq(
    434437      Hql.alias(Item.EXPERIMENT.getAlias()),
    435438      Hql.entity(getBioAssaySet(dc).getExperiment())
    436439    );
     440    // Restrictions for BioAssay annotation types
    437441    if (includeBioAssayAnnotations)
    438442    {
     443      query.join(Hql.innerJoin("itemTypes", "itemType"));
    439444      Restriction baa = Restrictions.eq(
    440445        Hql.alias("itemType"),
     
    446451    query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
    447452    query.order(Orders.asc(Hql.property("name")));
     453    query.setDistinct(true); // Needed because of the left join
    448454    return query.list(dc);
    449455  }
     
    830836    private final Set<AnnotationGroup> groups;
    831837   
     838    @SuppressWarnings("unchecked")
    832839    private AnnotationSummary(ExperimentExplorer explorer, DbControl dc, AnnotationType annotationType)
    833840    {
     
    836843      this.groups = new LinkedHashSet<AnnotationGroup>();
    837844     
     845      Formatter formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), annotationType.getValueType());
    838846      BioAssaySet bioAssaySet = explorer.getBioAssaySet(dc);
    839847      int channels = bioAssaySet.getRawDataType().getChannels();
    840       Map<Set<Object>, AnnotationGroup> temp = new HashMap<Set<Object>, AnnotationGroup>();
     848      Map<Set<?>, AnnotationGroup> temp = new HashMap<Set<?>, AnnotationGroup>();
    841849      int groupId = 0;
    842850      for (BioAssay ba : bioAssaySet.getBioAssays().list(dc))
    843851      {
    844         Set<Object> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, ba, annotationType);
     852        Set<?> annotationValues = BioAssaySetUtil.getAnnotationValues(dc, ba, annotationType);
    845853        AnnotationGroup group = temp.get(annotationValues);
    846854        if (group == null)
    847855        {
    848           group = new AnnotationGroup(++groupId, annotationValues, channels);
     856          group = new AnnotationGroup(++groupId, annotationValues, channels, formatter);
    849857          temp.put(annotationValues, group);
    850858          groups.add(group);
     
    888896  {
    889897    private final int id;
    890     private final Set<Object> annotationValues;
     898    private final Set<?> annotationValues;
    891899    private final String title;
    892900    private final float[] sum;
     
    894902    private final Map<String, Float> statistics;
    895903   
    896     private AnnotationGroup(int id, Set<Object> annotationValues, int channels)
     904    private <T> AnnotationGroup(int id, Set<T> annotationValues, int channels, Formatter<T> formatter)
    897905    {
    898906      this.id = id;
    899907      this.annotationValues = annotationValues;
    900       this.title = Values.getString(annotationValues, ", ", true);
     908      this.title = Values.getString(annotationValues, ", ", true, formatter);
    901909      this.sum = new float[channels+1]; // Channels are 1-based
    902910      this.count = new int[channels+1];
     
    929937      @return A set containing all annotation values
    930938    */
    931     public Set<Object> getAnnotationValues()
     939    public Set<?> getAnnotationValues()
    932940    {
    933941      return annotationValues;
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/ColorFormatter.java

    r2794 r2942  
    2727
    2828import net.sf.basedb.util.ColorGenerator;
     29import net.sf.basedb.util.formatter.Formatter;
    2930
    3031/**
     
    8081    return sb.toString();
    8182  }
     83
     84  public Number parseString(String value)
     85  {
     86    return numberFormatter.parseString(value);
     87  }
    8288  // -------------------------------------------
    8389
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/ExtendedPropertyFormatter.java

    r2733 r2942  
    2525
    2626import net.sf.basedb.core.ExtendedProperty;
     27import net.sf.basedb.util.formatter.Formatter;
    2728
    2829/**
     
    6869    return formattedValue;
    6970  }
     71  public T parseString(String value)
     72  {
     73    return valueFormatter.parseString(value);
     74  }
    7075  // -------------------------------------------
    7176
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterFactory.java

    r2733 r2942  
    3232import net.sf.basedb.core.Type;
    3333import net.sf.basedb.util.ColorGenerator;
     34import net.sf.basedb.util.formatter.BooleanFormatter;
     35import net.sf.basedb.util.formatter.DateFormatter;
     36import net.sf.basedb.util.formatter.Formatter;
     37import net.sf.basedb.util.formatter.IntegerFormatter;
     38import net.sf.basedb.util.formatter.NumberFormatter;
    3439
    3540/**
     
    174179  /**
    175180    Get a formatter suitable for displaying values of the given type.
    176     If type is <code>FLOAT</code> or <code>Double</code> a {@link #getNumberFormatter(SessionControl)}
     181    If type is <code>FLOAT</code> or <code>DOUBLE</code> a {@link #getNumberFormatter(SessionControl)}
    177182    is returned. If type is <code>LONG</code> or <code>INT</code>
    178183    a {@link #getIntFormatter(SessionControl)} is returned. If type is <code>STRING</code>
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterSettings.java

    r2795 r2942  
    2424package net.sf.basedb.clients.web.formatter;
    2525
     26import net.sf.basedb.core.InvalidDataException;
    2627import net.sf.basedb.core.SessionControl;
    2728import net.sf.basedb.util.Values;
     29import net.sf.basedb.util.formatter.DateFormatter;
    2830
    2931/**
     
    4749    The default date format for a date formatter = @value
    4850  */
    49   public static final String DEFAULT_DATE_FORMAT = "yyyy-mm-dd";
     51  public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
    5052
    5153  /**
    5254    The default datetime format for a datetime formatter = @value
    5355  */
    54   public static final String DEFAULT_DATETIME_FORMAT = "yyyy-mm-dd hh:nn:ss";
     56  public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    5557 
    5658  /**
     
    105107  public static void setDateFormat(SessionControl sc, String dateFormat)
    106108  {
     109    try
     110    {
     111      new DateFormatter(dateFormat);
     112    }
     113    catch (Throwable t)
     114    {
     115      throw new InvalidDataException("Invalid date format: " + dateFormat, t);
     116    }
    107117    sc.setUserClientSetting("formatter.date.formatstring", dateFormat);
    108118    sc.setSessionSetting("formatter.date", null);
     
    133143  public static void setDateTimeFormat(SessionControl sc, String dateTimeFormat)
    134144  {
     145    try
     146    {
     147      new DateFormatter(dateTimeFormat);
     148    }
     149    catch (Throwable t)
     150    {
     151      throw new InvalidDataException("Invalid date/time format: " + dateTimeFormat, t);
     152    }
    135153    sc.setUserClientSetting("formatter.datetime.formatstring", dateTimeFormat);
    136154    sc.setSessionSetting("formatter.datetime", null);
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/SpotImageFormatter.java

    r2733 r2942  
    2929import net.sf.basedb.core.RawDataUtil;
    3030import net.sf.basedb.core.data.RawData;
     31import net.sf.basedb.util.formatter.Formatter;
    3132
    3233/**
     
    5354  }
    5455 
     56  /*
     57    From the Formatter interface
     58    -------------------------------------------
     59  */
    5560  public String format(Integer value)
    5661  {
     
    7277    return sb.toString();
    7378  }
     79  /**
     80    Not supported.
     81    @since 2.2
     82  */
     83  public Integer parseString(String value)
     84  {
     85    throw new UnsupportedOperationException("parseString");
     86  }
     87  // -------------------------------------------
    7488
    7589}
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/StringFormatter.java

    r2733 r2942  
    2525
    2626import net.sf.basedb.clients.web.util.HTML;
     27import net.sf.basedb.util.formatter.Formatter;
    2728
    2829/**
     
    5354    return value == null ? "" : HTML.encodeTags(value);
    5455  }
     56  public String parseString(String value)
     57  {
     58    return value;
     59  }
    5560  // -------------------------------------------
    5661
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/ExportedProperty.java

    r2868 r2942  
    2727import net.sf.basedb.core.DbControl;
    2828import net.sf.basedb.util.Values;
     29import net.sf.basedb.util.formatter.Formatter;
    2930
    3031/**
     
    3940  public final String title;
    4041  public final AnnotationType annotationType;
     42  public final Formatter formatter;
    4143 
    42   public static ExportedProperty parse(DbControl dc, String column, boolean annotatable)
     44  public static ExportedProperty parse(DbControl dc, String column, boolean annotatable, Formatter formatter)
    4345  {
    4446    String[] p = column.split(":");
     
    5355      name = "annotationtype_"+annotationTypeId;
    5456    }
    55     return new ExportedProperty(name, title, at);
     57    return new ExportedProperty(name, title, at, formatter);
    5658  }
    5759 
    58   public ExportedProperty(String name, String title, AnnotationType annotationType)
     60  public ExportedProperty(String name, String title, AnnotationType annotationType, Formatter formatter)
    5961  {
    6062    this.name = name;
    6163    this.title = title;
    6264    this.annotationType = annotationType;
     65    this.formatter = formatter;
    6366  }
    6467 
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/PlainTextTemplate.java

    r2868 r2942  
    2626import java.io.IOException;
    2727import java.io.Writer;
    28 import java.util.Date;
    2928import java.util.List;
    3029import java.util.regex.Pattern;
     
    101100    Join the annotation values into a single string with a comma.
    102101  */
     102  @SuppressWarnings("unchecked")
    103103  public void writeAnnotations(ExportedProperty ep, List<?> values)
    104104    throws IOException
     
    106106    if (colNum > 0) exportStream.write("\t");
    107107    colNum++;
    108     exportStream.write(escape(Values.getString(values, ",", true)));
     108    exportStream.write(escape(Values.getString(values, ",", true, ep.formatter)));
    109109  }
    110110
     
    112112    Write the data object.
    113113  */
     114  @SuppressWarnings("unchecked")
    114115  public void writeProperty(ExportedProperty ep, Object data)
    115116    throws IOException
     
    117118    if (colNum > 0) exportStream.write("\t");
    118119    colNum++;
    119     exportStream.write(escape(data));
     120    exportStream.write(escape(ep.formatter.format(data)));
    120121  }
    121122
     
    139140  private static final Pattern UNSAFE = Pattern.compile("(\\r?\\n\\r?|\\t)");
    140141  /**
    141     Replace newlines and tabs with a space. Null values are converted to empty strings
    142     and dates are formatted with {@link Values#formatDate(Date)}.
     142    Replace newlines and tabs with a space. Null values are converted to empty strings.
    143143  */
    144   private String escape(Object data)
     144  private String escape(String data)
    145145  {
    146146    if (data == null)
     
    148148      return "";
    149149    }
    150     else if (data instanceof Date)
    151     {
    152       return Values.formatDate((Date)data);
    153     }
    154150    else
    155151    {
    156       String s = data.toString();
    157       s = UNSAFE.matcher(s).replaceAll(" ");
    158       return s;
     152      return UNSAFE.matcher(data).replaceAll(" ");
    159153    }
    160154  }
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java

    r2873 r2942  
    2424package net.sf.basedb.clients.web.plugins;
    2525
     26import net.sf.basedb.clients.web.formatter.FormatterFactory;
    2627import net.sf.basedb.core.Annotatable;
    2728import net.sf.basedb.core.AnnotationSet;
     
    6162import net.sf.basedb.util.Enumeration;
    6263import net.sf.basedb.util.Values;
     64import net.sf.basedb.util.formatter.MultiFormatter;
     65import net.sf.basedb.util.formatter.ToStringFormatter;
    6366
    6467import java.io.IOException;
     
    6770import java.util.ArrayList;
    6871import java.util.Arrays;
     72import java.util.Date;
    6973import java.util.List;
    7074import java.util.Set;
     
    226230    boolean annotatable = itemType.getItemClass() != null &&
    227231      Annotatable.class.isAssignableFrom(itemType.getItemClass());
     232    MultiFormatter formatter = new MultiFormatter(new ToStringFormatter(), true);
     233    formatter.registerFormatter(Date.class, FormatterFactory.getDateFormatter(sc));
    228234    for (String column : columns)
    229235    {
    230       ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable);
     236      ExportedProperty ep = ExportedProperty.parse(dc, column, annotatable, formatter);
    231237      hasAnnotations |= ep.annotationType != null;
    232238      exportedProperties.add(ep);
     
    332338          for (ExportedProperty ep : exportedProperties)
    333339          {
    334             if (ep.annotationType != null && as != null && as.hasAnnotation(ep.annotationType))
     340            if (ep.annotationType != null)
    335341            {
    336               List<?> values = as.getAnnotation(ep.annotationType).getValues();
     342              List<?> values = as != null && as.hasAnnotation(ep.annotationType) ?
     343                as.getAnnotation(ep.annotationType).getValues() : null;
    337344              template.writeAnnotations(ep, values);
    338345            }
     
    367374    {
    368375      exportStream.flush();
    369       exportStream.close();
    370376    }
    371377  }
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/XMLTemplate.java

    r2868 r2942  
    2626import java.io.IOException;
    2727import java.io.Writer;
    28 import java.util.Date;
    2928import java.util.List;
    3029import java.util.regex.Pattern;
    3130
    3231import net.sf.basedb.core.Item;
    33 import net.sf.basedb.util.Values;
    3432
    3533import org.jdom.DocType;
     
    121119    Add annotation values to the current item element.
    122120  */
     121  @SuppressWarnings("unchecked")
    123122  public void writeAnnotations(ExportedProperty ep, List<?> values)
    124123    throws IOException
     
    126125    Element property = new Element("annotation-values");
    127126    property.setAttribute("ref", ep.name);
    128     for (Object value : values)
     127    if (values != null)
    129128    {
    130       Element valueElement = new Element("value");
    131       valueElement.setText(escape(value));
    132       property.addContent(valueElement);
     129      for (Object value : values)
     130      {
     131        Element valueElement = new Element("value");
     132        valueElement.setText(escape(ep.formatter.format(value)));
     133        property.addContent(valueElement);
     134      }
    133135    }
    134136    itemElement.addContent(property);
     
    138140    Add the property value to the current item element.
    139141  */
     142  @SuppressWarnings("unchecked")
    140143  public void writeProperty(ExportedProperty ep, Object data)
    141144  {
    142145    Element property = new Element("property-value");
    143146    property.setAttribute("ref", ep.name);
    144     property.setText(escape(data));
     147    property.setText(escape(ep.formatter.format(data)));
    145148    itemElement.addContent(property);
    146149  }
     
    166169 
    167170  private static final Pattern NEWLINE = Pattern.compile("\\r?\\n\\r?");
    168   private String escape(Object data)
     171  private String escape(String data)
    169172  {
    170173    if (data == null)
     
    172175      return "";
    173176    }
    174     else if (data instanceof Date)
    175     {
    176       return Values.formatDate((Date)data);
    177     }
    178177    else
    179178    {
    180       String s = data.toString();
    181       s = NEWLINE.matcher(s).replaceAll("\n");
    182       return s;
     179      return NEWLINE.matcher(data).replaceAll("\n");
    183180    }
    184181  }
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/PlotServlet.java

    r2797 r2942  
    4545import net.sf.basedb.core.query.SqlResult;
    4646import net.sf.basedb.core.query.SqlResultIterator;
     47import net.sf.basedb.clients.web.formatter.FormatterFactory;
    4748import net.sf.basedb.clients.web.util.HTML;
    4849import net.sf.basedb.util.BioAssaySetUtil;
    4950import net.sf.basedb.util.Values;
     51import net.sf.basedb.util.formatter.Formatter;
    5052import net.sf.basedb.util.jep.ChannelFunction;
    5153import net.sf.basedb.util.jep.Jep;
     
    294296  }
    295297
     298  @SuppressWarnings("unchecked")
    296299  public void doGet(HttpServletRequest request, HttpServletResponse response)
    297300    throws IOException, ServletException
     
    414417            int annotationTypeId = Values.getInt(annotation);
    415418            AnnotationType at = AnnotationType.getById(dc, annotationTypeId);
    416             Map<Set<Object>, List<Integer>> groups = new HashMap<Set<Object>, List<Integer>>();
     419            Map<Set<?>, List<Integer>> groups = new HashMap<Set<?>, List<Integer>>();
     420            Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    417421            for (BioAssay bioAssay : bioAssays)
    418422            {
    419               Set<Object> values = BioAssaySetUtil.getAnnotationValues(dc, bioAssay, at);
     423              Set<?> values = BioAssaySetUtil.getAnnotationValues(dc, bioAssay, at);
    420424              if (!groups.containsKey(values))
    421425              {
     
    424428              groups.get(values).add((int)bioAssay.getDataCubeColumnNo());
    425429            }
    426             for (Map.Entry<Set<Object>, List<Integer>> entry : groups.entrySet())
    427             {
    428               String name = Values.getString(entry.getKey(), ", ", true);
     430            for (Map.Entry<Set<?>, List<Integer>> entry : groups.entrySet())
     431            {
     432              String name = Values.getString(entry.getKey(), ", ", true, formatter);
    429433              if (name == null || name.trim().equals("")) name = "null";
    430434              annotations.add(new PlotAnnotation(name, entry.getValue()));
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Cell.java

    r2733 r2942  
    2828import javax.servlet.jsp.tagext.BodyTagSupport;
    2929
    30 import net.sf.basedb.clients.web.formatter.Formatter;
     30import net.sf.basedb.util.formatter.Formatter;
    3131
    3232/**
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/CellValue.java

    r2733 r2942  
    2424package net.sf.basedb.clients.web.taglib.table;
    2525
     26import java.util.List;
     27
    2628import javax.servlet.jsp.JspException;
    2729import javax.servlet.jsp.JspTagException;
    2830import javax.servlet.jsp.tagext.TagSupport;
    2931
    30 import net.sf.basedb.clients.web.formatter.Formatter;
     32import net.sf.basedb.util.formatter.Formatter;
     33import net.sf.basedb.util.formatter.ToStringFormatter;
    3134
    3235/**
     
    3942   &lt;tbl:cellvalue
    4043      value=...
     44      list=...
     45      separator=...
    4146   &gt;
    4247</pre>
     
    5257    <td>value</td>
    5358    <td>-</td>
    54     <td>yes</td>
     59    <td>no</td>
    5560    <td>
    5661      A value to display in the cell. If a {@link Formatter} has been
    5762      defined for this column the value is formatted otherwise it is just
    5863      converted to a string with the toString() method.
     64    </td>
     65  </tr>
     66  <tr>
     67    <td>list</td>
     68    <td>-</td>
     69    <td>no</td>
     70    <td>
     71      A list of values to display in the cell. Each value is formatted
     72      the same way as for a single value. If a single value is also specified it is
     73      printed first.
     74    </td>
     75  </tr>
     76  <tr>
     77    <td>list</td>
     78    <td>; </td>
     79    <td>no</td>
     80    <td>
     81      A separator to use between each value in a list.
    5982    </td>
    6083  </tr>
     
    6891{
    6992
     93  private static final Formatter toStringFormatter = new ToStringFormatter();
     94 
    7095  /**
    7196    The value to display.
    7297  */
    7398  private Object value = null;
     99  private List<?> list = null;
     100  private String separator = "; ";
    74101
    75102  /*
     
    85112    return value;
    86113  }
     114 
     115  public void setList(List<?> list)
     116  {
     117    this.list = list;
     118  }
     119 
     120  public List<?> getList()
     121  {
     122    return list;
     123  }
     124 
     125  public void setSeparator(String separator)
     126  {
     127    this.separator = separator;
     128  }
     129 
     130  public String getSeparator()
     131  {
     132    return separator;
     133  }
    87134
    88135  /*
     
    95142    Cell cell =  (Cell)getParent();
    96143    Formatter formatter = cell.getFormatter();
    97     String output = formatter == null ?
    98       (value == null ? "" : value.toString()) :
    99       formatter.format(value);
     144    if (formatter == null) formatter = toStringFormatter;
     145   
     146    StringBuilder output = new StringBuilder();
     147    String theSeparator = "";
     148    if (value != null)
     149    {
     150      output.append(formatter.format(value));
     151      theSeparator = separator;
     152    }
     153    if (list != null && list.size() > 0)
     154    {
     155      for (Object o : list)
     156      {
     157        if (o != null)
     158        {
     159          output.append(theSeparator).append(formatter.format(o));
     160          theSeparator = separator;
     161        }
     162      }
     163    }
    100164    try
    101165    {
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/ColumnDef.java

    r2754 r2942  
    2323*/
    2424package net.sf.basedb.clients.web.taglib.table;
     25
     26import java.util.Date;
    2527
    2628import net.sf.basedb.util.Enumeration;
     
    3133import net.sf.basedb.clients.web.Base;
    3234import net.sf.basedb.util.Values;
    33 import net.sf.basedb.clients.web.formatter.Formatter;
     35import net.sf.basedb.util.formatter.Formatter;
     36import net.sf.basedb.clients.web.formatter.FormatterFactory;
    3437import net.sf.basedb.clients.web.util.HTML;
    3538
     
    590593      {
    591594        Type valueType = getValueType();
     595        Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(table.getSc());
    592596       
    593597        if (getEnumeration() != null)
    594598        {
    595           String filterValue = filter == null ? "" : filter.getValue();
     599          String filterValue = filter == null ? "" : Base.getPropertyFilterString(filter, dateFormatter);
    596600          sb.append("<select name=\"filter:").append(valueType.name()).append(":").append(getFilterproperty()).append("\"");
    597601          sb.append(" onchange=\"Forms.submit(event);\">\n");
     
    624628        else
    625629        {
    626           String filterValue = HTML.encodeTags(Base.getPropertyFilterString(filter));
     630          String filterValue = HTML.encodeTags(Base.getPropertyFilterString(filter, dateFormatter));
    627631          sb.append("<input class=\"text\" type=\"text\"");
    628632          sb.append(" name=\"filter:").append(valueType.name()).append(":").append(getFilterproperty()).append("\"");
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Table.java

    r2890 r2942  
    2727import net.sf.basedb.core.Item;
    2828import net.sf.basedb.core.ItemContext;
    29 import net.sf.basedb.clients.web.formatter.Formatter;
    3029import net.sf.basedb.clients.web.taglib.Page;
    3130import net.sf.basedb.clients.web.util.HTML;
     31import net.sf.basedb.util.formatter.Formatter;
    3232
    3333import java.util.HashSet;
     
    393393    boolean alwaysShow = "always".equals(cd.getShow());
    394394    boolean alwaysHide = "never".equals(cd.getShow());
    395     if ("never".equals(cd.getShow()))
     395    if (alwaysHide)
    396396    {
    397397      visibleColumns.remove(columnId);
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/TableColumn.java

    r2733 r2942  
    2424package net.sf.basedb.clients.web.taglib.table;
    2525
    26 import net.sf.basedb.clients.web.formatter.Formatter;
    2726import net.sf.basedb.core.Type;
     27import net.sf.basedb.util.formatter.Formatter;
    2828
    2929/**
  • trunk/src/core/net/sf/basedb/core/Annotation.java

    r2382 r2942  
    194194  }
    195195 
     196 
     197  /**
     198    Get the value type for this annotation type. It can't be change once
     199    the object has been created.
     200    @since 2.2
     201  */
     202  public Type getValueType()
     203  {
     204    return Type.fromValue(getData().getAnnotationType().getValueType());
     205  }
     206 
    196207  /**
    197208    Get the values this annotation contains. The values are of a
  • trunk/src/core/net/sf/basedb/core/Application.java

    r2932 r2942  
    7575    The build number.
    7676    @base.internal
    77     The <code>@BUILD@</code> string will be replaced with the
     77    The <code>${base.build}</code> string will be replaced with the
    7878    current subversion revision by the <code>ant dist</code> command.
    7979    See <code>svn.revision</code>, <code>dist.init</code> and
     
    8181
    8282  */
    83   private static final int BUILD = parseBuildNumber("@BUILD@");
     83  private static final int BUILD = parseBuildNumber("${base.build}");
    8484 
    8585  /**
  • trunk/src/core/net/sf/basedb/core/DateUtil.java

    r2610 r2942  
    7676 
    7777  /**
    78       Parses a string to create a <code>Date</code>. 
    79       @param value the <code>String</code> to be parsed.
     78      Parses a string to create a <code>Date</code>. This method supports
     79      date in yyyy-MM-dd format or as long timevalues.
     80       
     81      @param value the <code>String</code> to be parsed
    8082      @return a <code>Date</code> object
    8183      @throws InvalidDataException if <code>value</code> isn't a valid date.
     
    105107    return result;
    106108  }
     109 
     110  /**
     111    Formats a date in yyyy-MM-dd format.
     112    @since 2.2
     113  */
     114  public static String formatDate(Date d)
     115  {
     116    return DATE_FORMAT.format(d);
     117  }
     118 
    107119}
  • trunk/src/core/net/sf/basedb/core/InvalidDataException.java

    r2304 r2942  
    4545    Create a new <code>InvalidDataException</code> object.
    4646  */
    47   public InvalidDataException(Exception ex)
     47  public InvalidDataException(Throwable cause)
    4848  {
    49     super(ex);
     49    super(cause);
    5050  }
    5151
     
    6060    super(message);
    6161  }
     62 
     63  /**
     64    Create a new <code>InvalidDataException</code> object with the
     65    specified <code>message</code>.
     66 
     67    @param message The message to throw with the exception
     68  */
     69  public InvalidDataException(String message, Throwable cause)
     70  {
     71    super(message, cause);
     72  }
    6273
    6374}
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r2812 r2942  
    178178  private Map<String, Object> objects;
    179179  private Query query;
    180 
    181 
     180 
    182181  /**
    183182    Create a new context.
     
    555554      propertyFilters.remove(property);
    556555    }
     556  }
     557 
     558  public Object getPropertyObject(String property)
     559  {
     560    Object value = null;
     561    PropertyFilter filter = getPropertyFilter(property);
     562    if (filter != null)
     563    {
     564      value = filter.getValueAsObject();
     565    }
     566    return value;
    557567  }
    558568 
  • trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java

    r2892 r2942  
    7575    @return A set containing all values
    7676  */
    77   public static Set<Object> getAnnotationValues(DbControl dc, BioAssay bioAssay, AnnotationType annotationType)
     77  public static Set<?> getAnnotationValues(DbControl dc, BioAssay bioAssay, AnnotationType annotationType)
    7878  {
    7979    ItemQuery<RawBioAssay> rbaQuery = bioAssay.getRawBioAssays();
  • trunk/src/core/net/sf/basedb/util/Values.java

    r2752 r2942  
    3030import java.util.Collection;
    3131
     32import net.sf.basedb.util.formatter.Formatter;
     33
    3234/**
    3335  This class contains a set of static methods that may be useful
     
    389391  public static final String getString(Collection<?> values, String deliminator, boolean skipNull)
    390392  {
     393    return getString(values, deliminator, skipNull, null);
     394  }
     395 
     396  public static final <T> String getString(Collection<T> values, String deliminator, boolean skipNull, Formatter<T> formatter)
     397  {
    391398    StringBuilder sb = new StringBuilder();
    392399    boolean firstElement = true;
    393400    if (values != null)
    394401    {
    395       for (Object value : values)
     402      for (T value : values)
    396403      {
    397404        if (value == null)
     
    405412        else
    406413        {
     414          String s;
    407415          if (!firstElement) sb.append(deliminator);
    408           if (value instanceof Date) value = formatDate((Date)value);
    409           sb.append(value);
     416          if (formatter != null)
     417          {
     418            s = formatter.format(value);
     419          }
     420          /*
     421          else if (value instanceof Date)
     422          {
     423            s = formatDate((Date)value);
     424          }
     425          */
     426          else
     427          {
     428            s = value.toString();
     429          }
     430          sb.append(s);
    410431          firstElement = false;
    411432        }
    412433      }
    413434    }
    414     return sb.toString();
     435    return sb.toString();   
    415436  }
    416437 
     
    467488    @param value The value to convert
    468489    @return The parsed date or null if the value can't be converted
     490    @deprecated Use a {@link Formatter} for dates instead
    469491  */
    470492  public static final Date getDate(String value)
     
    478500    @param defaultValue The value to return if the string can't be converted
    479501    @return The parsed date or the default value
     502    @deprecated Use a {@link Formatter} for dates instead
    480503  */
    481504  public static final Date getDate(String value, Date defaultValue)
     
    493516    @param values The array of strings
    494517    @return The converted values
     518    @deprecated Use a {@link Formatter} for dates instead
    495519  */
    496520  public static final Date[] getDate(String[] values)
     
    526550  }
    527551
     552  public static final Date[] getDate(String[] values, Formatter<Date> dateFormatter)
     553  {
     554    Date[] result;
     555    if (values != null)
     556    {
     557      Date[] temp = new Date[values.length];
     558      int j = 0;
     559      for (String v : values)
     560      {
     561        Date i = dateFormatter.parseString(v);
     562        if (i != null)
     563        {
     564          temp[j++] = i;
     565        }
     566      }
     567      if (j < values.length)
     568      {
     569        result = new Date[j];
     570        System.arraycopy(temp, 0, result, 0, j);
     571      }
     572      else
     573      {
     574        result = temp;
     575      }
     576    }
     577    else
     578    {
     579      result = new Date[0];
     580    }
     581    return result;
     582  }
     583 
    528584  /**
    529585    Formats a decimal number with the specified number of decimals.
     
    667723    @param date The date to format
    668724    @return The formatted date
     725    @deprecated Use a {@link Formatter} for dates instead
    669726  */
    670727  public static final String formatDate(Date date)
     
    678735    @param time The time to format
    679736    @return The formatted time
     737    @deprecated Use a {@link Formatter} for dates instead
    680738  */
    681739  public static final String formatTime(Date time)
     
    691749    @param datetime The date and time to format
    692750    @return The formatted date with time
     751    @deprecated Use a {@link Formatter} for dates instead
    693752  */
    694753  public static final String formatDateTime(Date datetime)
  • trunk/src/core/net/sf/basedb/util/formatter/BooleanFormatter.java

    r2921 r2942  
    2222  Boston, MA  02111-1307, USA.
    2323*/
    24 package net.sf.basedb.clients.web.formatter;
     24package net.sf.basedb.util.formatter;
     25
     26import net.sf.basedb.util.Values;
    2527
    2628/**
     
    5456  {
    5557    return value == null ? "" : type.getString(value);
     58  }
     59  public Boolean parseString(String value)
     60  {
     61    return Values.getBoolean(value);
    5662  }
    5763  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/util/formatter/DateFormatter.java

    r2921 r2942  
    2222  Boston, MA  02111-1307, USA.
    2323*/
    24 package net.sf.basedb.clients.web.formatter;
     24package net.sf.basedb.util.formatter;
    2525
    2626import java.text.DateFormat;
     27import java.text.ParseException;
    2728import java.text.SimpleDateFormat;
    2829import java.util.Date;
    2930
     31import net.sf.basedb.core.InvalidDataException;
     32
     33
    3034/**
    31   Format a date for output on a web page.
     35  Format a date for output in a client application. This implementation
     36  uses the {@link SimpleDateFormat} standard formatting routines.
    3237 
    3338  @author nicklas
     
    4146
    4247  private DateFormat dateFormat;
     48  private String format;
    4349 
    4450  /**
     
    4955  {
    5056    this.dateFormat = dateFormat;
     57    this.format = null;
    5158  }
    5259 
     
    5966  {
    6067    this.dateFormat = new SimpleDateFormat(format);
     68    this.dateFormat.setLenient(true);
     69    this.format = format;
    6170  }
    6271 
     
    6978    return value == null ? "" : dateFormat.format(value);
    7079  }
     80  public Date parseString(String value)
     81  {
     82    if (value == null) return null;
     83    try
     84    {
     85      return dateFormat.parse(value);
     86    }
     87    catch (ParseException ex)
     88    {
     89      try
     90      {
     91        return new Date(new Long(value));
     92      }
     93      catch (Exception ex2)
     94      {
     95        throw new InvalidDataException(value + " is not a valid date for format: " +
     96          format, ex);
     97      }
     98    }
     99  }
    71100  // -------------------------------------------
    72101
  • trunk/src/core/net/sf/basedb/util/formatter/Formatter.java

    r2921 r2942  
    2222  Boston, MA  02111-1307, USA.
    2323*/
    24 package net.sf.basedb.clients.web.formatter;
     24package net.sf.basedb.util.formatter;
    2525
    2626/**
    2727  A <code>Formatter</code> formats an object to a string suitable for
    28   output on the web page.
     28  output in a client application. The formatter may optionally also do
     29  the reverse, ie. parse a string to an object.
    2930
    3031  @author nicklas
     
    4243  public String format(T value);
    4344
     45  /**
     46    Parse a string and return a value of the correct type.
     47    @param value The string to parse
     48    @return An object
     49    @since 2.2
     50  */
     51  public T parseString(String value);
     52 
    4453}
  • trunk/src/core/net/sf/basedb/util/formatter/IntegerFormatter.java

    r2921 r2942  
    2222  Boston, MA  02111-1307, USA.
    2323*/
    24 package net.sf.basedb.clients.web.formatter;
     24package net.sf.basedb.util.formatter;
     25
    2526
    2627/**
     
    3536{
    3637
    37  
    3838  /**
    3939    Create a new integer formatter.
     
    5050    return value == null ? "" : String.valueOf(value.longValue());
    5151  }
     52  public Number parseString(String value)
     53  {
     54    return Double.valueOf(value).longValue();
     55  }
    5256  // -------------------------------------------
    5357
  • trunk/src/core/net/sf/basedb/util/formatter/NumberFormatter.java

    r2921 r2942  
    2222  Boston, MA  02111-1307, USA.
    2323*/
    24 package net.sf.basedb.clients.web.formatter;
     24package net.sf.basedb.util.formatter;
    2525
    2626import net.sf.basedb.util.Values;
     
    5858    return value == null ? "" : Values.formatNumber(value.floatValue(), numDecimals);
    5959  }
     60  public Number parseString(String value)
     61  {
     62    return Double.valueOf(value);
     63  }
    6064  // -------------------------------------------
    6165
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r2839 r2942  
    11211121        out.print("\t");
    11221122        BioAssaySetUtil.getAnnotationValues(dc, ba, at);
    1123         Set<Object> v = BioAssaySetUtil.getAnnotationValues(dc, ba, at);
     1123        Set<?> v = BioAssaySetUtil.getAnnotationValues(dc, ba, at);
    11241124        if (!v.isEmpty())
    11251125        {
  • trunk/src/plugins/core/net/sf/basedb/plugins/HelpExporter.java

    r2876 r2942  
    2626
    2727import net.sf.basedb.core.BaseException;
    28 import net.sf.basedb.core.BooleanParameterType;
    2928import net.sf.basedb.core.Client;
    3029import net.sf.basedb.core.DbControl;
     
    3433import net.sf.basedb.core.ItemQuery;
    3534import net.sf.basedb.core.Path;
    36 import net.sf.basedb.core.PathParameterType;
    3735import net.sf.basedb.core.Permission;
    3836import net.sf.basedb.core.PluginDefinition;
     
    353351    xmlOut.output(helpRoot, helpExportStream);
    354352    helpExportStream.flush();
    355     helpExportStream.close();
    356353  }
    357354 
  • trunk/src/plugins/core/net/sf/basedb/plugins/PlateMappingExporter.java

    r2876 r2942  
    292292    }
    293293    textOut.flush();
    294     textOut.close();
    295294  }
    296295  protected void end(boolean success)
  • trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationExporter.java

    r2876 r2942  
    2626
    2727import net.sf.basedb.core.BaseException;
    28 import net.sf.basedb.core.BooleanParameterType;
    2928import net.sf.basedb.core.DbControl;
    3029import net.sf.basedb.core.Include;
     
    3534import net.sf.basedb.core.ItemResultIterator;
    3635import net.sf.basedb.core.ParameterInfo;
    37 import net.sf.basedb.core.PathParameterType;
    3836import net.sf.basedb.core.Permission;
    3937import net.sf.basedb.core.PluginConfiguration;
     
    4240import net.sf.basedb.core.ProgressReporter;
    4341import net.sf.basedb.core.RequestInformation;
    44 import net.sf.basedb.core.StringParameterType;
    4542import net.sf.basedb.core.Type;
    4643import net.sf.basedb.core.Job.ExecutionTime;
     
    336333      xmlOut.output(configurationRoot, configurationExportStream);
    337334      configurationExportStream.flush();
    338       configurationExportStream.close();
    339335    }
    340336  }
  • trunk/www/WEB-INF/table.tld

    r2733 r2942  
    624624    <attribute>
    625625      <name>value</name>
    626       <required>true</required>
     626      <required>false</required>
     627      <rtexprvalue>true</rtexprvalue>
     628    </attribute>
     629    <attribute>
     630      <name>list</name>
     631      <required>false</required>
     632      <rtexprvalue>true</rtexprvalue>
     633    </attribute>
     634    <attribute>
     635      <name>separator</name>
     636      <required>false</required>
    627637      <rtexprvalue>true</rtexprvalue>
    628638    </attribute>
  • trunk/www/admin/annotationtypes/edit_annotationtype.jsp

    r2933 r2942  
    4545  import="net.sf.basedb.clients.web.util.HTML"
    4646  import="net.sf.basedb.util.Values"
     47  import="net.sf.basedb.util.formatter.Formatter"
     48  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     49  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
     50  import="java.util.Date"
    4751  import="java.util.Set"
     52  import="java.util.List"
    4853%>
    4954<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    8388  final String clazz = "class=\"text\"";
    8489  final String requiredClazz = "class=\"text required\"";
     90  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     91  String dateFormat = FormatterSettings.getDateFormat(sc);
     92  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     93  String htmlDateFormat = HTML.encodeTags(dateFormat);
    8594  %>
    8695
     
    313322              <input <%=clazz%> type="text" name="defaultValue"
    314323                value="<%=HTML.encodeTags(defaultValue)%>"
    315                 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">&nbsp;
     324                size="20" maxlength="20 "title="Enter date in format: <%=htmlDateFormat%>">&nbsp;
    316325            </td>
    317326            <td>
    318327              <base:button
    319                 onclick="Dates.selectDate('Default value', 'annotationType', 'defaultValue')"
     328                onclick="<%="Dates.selectDate('Default value', 'annotationType', 'defaultValue', null, '"+jsDateFormat+"')"%>"
    320329                image="calendar.png"
    321330                title="Calendar&hellip;"
     
    548557          <td nowrap>
    549558            <%
    550             String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true);
     559            String values = annotationType == null ? "" :
     560              Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter);
    551561            %>
    552562            <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"
    553               onkeypress="return Dates.dateOnly(event)"><%=HTML.encodeTags(values)%></textarea>
     563              ><%=HTML.encodeTags(values)%></textarea>
    554564            <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" title="Edit in larger window"><base:icon image="zoom.gif" /></a><br>
    555             One date value (yyyy-mm-dd) per line
     565            One date value (<%=htmlDateFormat%>) per line
    556566          </td>
    557567        </tr>
  • trunk/www/admin/annotationtypes/index.jsp

    r2933 r2942  
    4747  import="net.sf.basedb.util.Values"
    4848  import="net.sf.basedb.clients.web.util.HTML"
     49  import="net.sf.basedb.util.formatter.Formatter"
     50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4951  import="java.util.Enumeration"
    5052  import="java.util.Set"
     
    221223      if (annotationType.isEnumeration())
    222224      {
    223         Date[] values = Values.getDate(request.getParameter("values").split("[\n\r]+"));
     225        Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     226        Date[] values = Values.getDate(request.getParameter("values").split("[\n\r]+"), dateFormatter);
    224227        annotationType.setValues(Arrays.asList(values));
    225228        annotationType.setDisplayAsList("list".equals(request.getParameter("interface")));
  • trunk/www/admin/annotationtypes/view_annotationtype.jsp

    r2933 r2942  
    3636  import="net.sf.basedb.core.AnnotationTypeCategory"
    3737  import="net.sf.basedb.core.User"
     38  import="net.sf.basedb.core.Type"
    3839  import="net.sf.basedb.core.ItemQuery"
    3940  import="net.sf.basedb.core.ItemResultList"
     
    4849  import="net.sf.basedb.clients.web.util.HTML"
    4950  import="net.sf.basedb.util.Values"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5053  import="java.util.Map"
     54  import="java.util.Date"
    5155%>
    5256<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7781  final boolean setOwnerPermission = annotationType.hasPermission(Permission.SET_OWNER);
    7882  final boolean isOwner = annotationType.isOwner();
     83  Formatter dateFormatter = FormatterFactory.getDateFormatter(sc);
    7984  %>
    8085  <base:page title="<%=title%>">
     
    219224        <td class="prompt">Enumeration</td>
    220225        <td><%=annotationType.isEnumeration() ?
    221           HTML.encodeTags(Values.getString(annotationType.getValues(), ", ", true)) : "no"%></td>
     226          HTML.encodeTags(Values.getString(annotationType.getValues(), ", ", true,
     227            annotationType.getValueType() == Type.DATE ? dateFormatter : null)) : "no"%></td>
    222228      </tr>
    223229      <tr>
  • trunk/www/admin/diskusage/list_users.jsp

    r2929 r2942  
    5656  import="net.sf.basedb.clients.web.PermissionUtil"
    5757  import="net.sf.basedb.clients.web.util.HTML"
     58  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5859  import="net.sf.basedb.util.Values"
    5960  import="java.util.List"
     
    240241        filterable="true"
    241242        exportable="true"
     243        formatter="<%=FormatterFactory.getDateFormatter(sc)%>"
    242244      />
    243245      <tbl:columndef
     
    560562                <tbl:cell column="systemId"><%=Values.getString(item.getSystemId())%></tbl:cell>
    561563                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
    562                 <tbl:cell column="expirationDate"><%=Values.formatDate(item.getExpirationDate())%></tbl:cell>
     564                <tbl:cell column="expirationDate" value="<%=item.getExpirationDate()%>" />
    563565                <tbl:cell column="disabled"><%=item.isDisabled() ? "yes" : "no" %></tbl:cell>
    564566                <tbl:cell column="multiuserAccount"><%=item.isMultiuserAccount() ? "yes" : "no" %></tbl:cell>
  • trunk/www/admin/jobagents/view_agent.jsp

    r2921 r2942  
    5050  import="net.sf.basedb.util.Values"
    5151  import="net.sf.basedb.clients.web.util.NameablePluginAdaptor"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.Map"
    5355  import="java.util.Set"
     56  import="java.util.Date"
    5457%>
    5558<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7174{
    7275  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     76  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
    7377
    7478  String title = null;
     
    442446                <tbl:cell column="job"><%=Base.getLinkedName(ID, job, !readJob, true) %></tbl:cell>
    443447                <tbl:cell column="plugin"><base:propertyvalue item="<%=job%>" property="pluginDefinition"/></tbl:cell>
    444                 <tbl:cell column="started"><%=job == null ? "" : Values.formatDateTime(job.getStarted())%></tbl:cell>
     448                <tbl:cell column="started"><%=job == null ? "" : dateFormatter.format(job.getStarted())%></tbl:cell>
    445449                <tbl:cell column="percentComplete">
    446450                  <%
  • trunk/www/admin/news/edit_news.jsp

    r2753 r2942  
    3636  import="net.sf.basedb.clients.web.Base"
    3737  import="net.sf.basedb.clients.web.util.HTML"
     38  import="net.sf.basedb.util.formatter.Formatter"
     39  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     40  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    3841  import="net.sf.basedb.util.Values"
    3942  import="java.util.Date"
     
    5356  String title = null;
    5457  News news = null;
     58  Date startDate = null;
     59  Date newsDate = null;
    5560
    5661  if (itemId == 0)
     
    5863    title = "Create news";
    5964    cc.removeObject("item");
     65    startDate = (Date)cc.getPropertyObject("startDate");
     66    newsDate = (Date)cc.getPropertyObject("newsDate");
    6067  }
    6168  else
     
    6471    cc.setObject("item", news);
    6572    title = "Edit news -- " + HTML.encodeTags(news.getName());
     73    startDate = news.getStartDate();
     74    newsDate = news.getNewsDate();
    6675  }
    6776  if (news != null && !news.hasPermission(Permission.WRITE))
     
    7281  final String clazz = "class=\"text\"";
    7382  final String requiredClazz = "class=\"text required\"";
     83  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     84  String dateFormat = FormatterSettings.getDateFormat(sc);
     85  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     86  String htmlDateFormat = HTML.encodeTags(dateFormat);
    7487  %>
    7588
     
    8093    function validateNews()
    8194    {
     95      var dateFormat = '<%=jsDateFormat%>';
    8296      var frm = document.forms['news'];
    8397      if (Main.trimString(frm.title.value) == '')
     
    87101        return false;
    88102      }
    89       else if (!Dates.isDate(frm.start_date.value))
     103      else if (!Dates.isDate(frm.start_date.value, dateFormat))
    90104      {
    91105        alert("'"+frm.start_date.value+"' is not a valid value for start date");
     
    93107        return false;
    94108      }
    95       else if (!Dates.isDate(frm.news_date.value))
     109      else if (!Dates.isDate(frm.news_date.value, dateFormat))
    96110      {
    97111        alert("'"+frm.news_date.value+"' is not a valid value for news date");
     
    99113        return false;
    100114      }
    101       else if (frm.end_date.value != '' && !Dates.isDate(frm.end_date.value))
     115      else if (frm.end_date.value != '' && !Dates.isDate(frm.end_date.value, dateFormat))
    102116      {
    103117        alert("'"+frm.end_date.value+"' is not a valid value for end date");
     
    153167        <td>
    154168          <input <%=requiredClazz%> type="text" name="start_date"
    155           value="<%=Values.formatDate(news == null ?
    156             Values.getDate(cc.getPropertyValue("startDate"), new Date()) : news.getStartDate())%>"
    157           size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    158           (yyyy-mm-dd)
     169          value="<%=HTML.encodeTags(dateFormatter.format(startDate == null ? new Date() : startDate))%>"
     170          size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
    159171        </td>
    160172        <td>
    161173          <base:button
    162             onclick="Dates.selectDate('Start date', 'news', 'start_date')"
     174            onclick="<%="Dates.selectDate('Start date', 'news', 'start_date', null, '"+jsDateFormat+"')"%>"
    163175            image="calendar.png"
    164176            title="Calendar&hellip;"
     
    171183        <td>
    172184          <input <%=requiredClazz%> type="text" name="news_date"
    173             value="<%=Values.formatDate(news == null ?
    174             Values.getDate(cc.getPropertyValue("newsDate"), new Date()) : news.getNewsDate())%>"
    175             size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    176           (yyyy-mm-dd)
     185            value="<%=HTML.encodeTags(dateFormatter.format(newsDate == null ? new Date() : newsDate))%>"
     186            size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
    177187        </td>
    178188        <td>
    179189          <base:button
    180             onclick="Dates.selectDate('News date', 'news', 'news_date')"
     190            onclick="<%="Dates.selectDate('News date', 'news', 'news_date', null, '"+jsDateFormat+"')"%>"
    181191            image="calendar.png"
    182192            title="Calendar&hellip;"
     
    189199        <td>
    190200          <input <%=clazz%> type="text" name="end_date"
    191           value="<%=Values.formatDate(news == null ?
    192             Values.getDate(cc.getPropertyValue("endDate")) : news.getEndDate())%>"
    193           size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    194           (yyyy-mm-dd)
     201          value="<%=dateFormatter.format(news == null ?
     202              (Date)cc.getPropertyObject("endDate") : news.getEndDate())%>"
     203          size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"><br>
    195204        </td>
    196205        <td>
    197206          <base:button
    198             onclick="Dates.selectDate('End date', 'news', 'end_date')"
     207            onclick="<%="Dates.selectDate('End date', 'news', 'end_date', null, '"+jsDateFormat+"')"%>"
    199208            image="calendar.png"
    200209            title="Calendar&hellip;"
  • trunk/www/admin/news/index.jsp

    r2811 r2942  
    4242  import="net.sf.basedb.util.Values"
    4343  import="net.sf.basedb.clients.web.util.HTML"
     44  import="net.sf.basedb.util.formatter.Formatter"
     45  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4446  import="java.util.Date"
    4547  import="java.util.Set"
     
    129131    dc = sc.newDbControl();
    130132    News news = (News)cc.getObject("item");
    131     Date startDate = Values.getDate(request.getParameter("start_date"));
    132     Date newsDate = Values.getDate(request.getParameter("news_date"));
     133    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     134    Date startDate = dateFormatter.parseString(request.getParameter("start_date"));
     135    Date newsDate = dateFormatter.parseString(request.getParameter("news_date"));
    133136    if (news == null)
    134137    {
     
    145148    }
    146149    news.setName(Values.getStringOrNull(request.getParameter("title")));
    147     news.setEndDate(Values.getDate(request.getParameter("end_date")));
     150    news.setEndDate(dateFormatter.parseString(request.getParameter("end_date")));
    148151    news.setDescription(Values.getStringOrNull(request.getParameter("description")));
    149152    dc.commit();
  • trunk/www/admin/news/list_news.jsp

    r2753 r2942  
    4646  import="net.sf.basedb.clients.web.ModeInfo"
    4747  import="net.sf.basedb.clients.web.util.HTML"
     48  import="net.sf.basedb.util.formatter.Formatter"
     49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4850  import="net.sf.basedb.util.Values"
    4951  import="java.util.List"
    5052  import="java.util.Map"
     53  import="java.util.Date"
    5154%>
    5255<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7174try
    7275{
    73   final ItemQuery<News> query = Base.getConfiguredQuery(cc, true, News.getQuery(), mode);
    7476
    7577  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7678  try
    7779  {
     80    final ItemQuery<News> query = Base.getConfiguredQuery(cc, true, News.getQuery(), mode);
    7881    news = query.iterate(dc);
    7982  }
     
    8386  }
    8487  int numListed = 0;
     88  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    8589  %>
    8690  <base:page title="<%=title==null ? "News" : title%>" type="<%=mode.getPageType()%>">
     
    197201        filterable="true"
    198202        exportable="true"
     203        formatter="<%=dateFormatter%>"
    199204      />
    200205      <tbl:columndef
     
    206211        filterable="true"
    207212        exportable="true"
     213        formatter="<%=dateFormatter%>"
    208214      />
    209215      <tbl:columndef
     
    215221        filterable="true"
    216222        exportable="true"
     223        formatter="<%=dateFormatter%>"
    217224      />
    218225      <tbl:columndef
     
    366373                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)"
    367374                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
    368                 <tbl:cell column="startDate"><%=Values.formatDate(item.getStartDate())%></tbl:cell>
    369                 <tbl:cell column="newsDate"><%=Values.formatDate(item.getNewsDate())%></tbl:cell>
    370                 <tbl:cell column="endDate"><%=Values.formatDate(item.getEndDate())%></tbl:cell>
     375                <tbl:cell column="startDate" value="<%=item.getStartDate()%>" />
     376                <tbl:cell column="newsDate" value="<%=item.getNewsDate()%>" />
     377                <tbl:cell column="endDate" value="<%=item.getEndDate()%>" />
    371378                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
    372379              </tbl:row>
  • trunk/www/admin/news/view_news.jsp

    r2753 r2942  
    4040  import="net.sf.basedb.clients.web.PermissionUtil"
    4141  import="net.sf.basedb.clients.web.util.HTML"
     42  import="net.sf.basedb.util.formatter.Formatter"
     43  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4244  import="net.sf.basedb.util.Values"
    4345  import="java.util.Map"
     46  import="java.util.Date"
    4447%>
    4548<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    6770  final boolean writePermission = news.hasPermission(Permission.WRITE);
    6871  final boolean deletePermission = news.hasPermission(Permission.DELETE);
     72  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    6973  %>
    7074
     
    173177      <tr>
    174178        <td class="prompt">Start date</td>
    175         <td><%=Values.formatDate(news.getStartDate())%></td>
     179        <td><%=dateFormatter.format(news.getStartDate())%></td>
    176180      </tr>
    177181      <tr>
    178182        <td class="prompt">News date</td>
    179         <td><%=Values.formatDate(news.getNewsDate())%></td>
     183        <td><%=dateFormatter.format(news.getNewsDate())%></td>
    180184      </tr>
    181185      <tr>
    182186        <td class="prompt">End date</td>
    183         <td><%=Values.formatDate(news.getEndDate())%></td>
     187        <td><%=dateFormatter.format(news.getEndDate())%></td>
    184188      </tr>
    185189      <tr valign="baseline">
  • trunk/www/admin/pluginconfigurations/view_configuration.jsp

    r2921 r2942  
    5050  import="net.sf.basedb.util.Values"
    5151  import="net.sf.basedb.clients.web.util.NameablePluginAdaptor"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.Map"
    5355  import="java.util.Set"
     
    7678{
    7779  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     80  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7881
    7982  String title = null;
     
    335338                  else if (value instanceof Date)
    336339                  {
    337                     sb.append(Values.formatDate((Date)value));
     340                    sb.append(dateFormatter.format((Date)value));
    338341                  }
    339342                  else
  • trunk/www/admin/users/edit_user.jsp

    r2753 r2942  
    5151  import="net.sf.basedb.clients.web.util.HTML"
    5252  import="net.sf.basedb.util.Values"
     53  import="net.sf.basedb.util.formatter.Formatter"
     54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     55  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
     56  import="java.util.Date"
    5357%>
    5458<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    164168  final String clazz = "class=\"text\"";
    165169  final String requiredClazz = "class=\"text required\"";
     170  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     171  String dateFormat = FormatterSettings.getDateFormat(sc);
     172  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     173  String htmlDateFormat = HTML.encodeTags(dateFormat);
    166174  %>
    167175
     
    440448        <td>
    441449          <input <%=clazz%> type="text" name="expiration_date"
    442             value="<%=user == null ? HTML.encodeTags(cc.getPropertyValue("expirationDate")) : Values.formatDate(user.getExpirationDate())%>"
    443             size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    444           (yyyy-mm-dd)
     450            value="<%=HTML.encodeTags(dateFormatter.format(
     451                user == null ? (Date)cc.getPropertyObject("expirationDate") : user.getExpirationDate())
     452              )%>"
     453            size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
    445454        </td>
    446455        <td>
    447456        <base:button
    448           onclick="Dates.selectDate('Expiration date', 'user', 'expiration_date')"
     457          onclick="<%="Dates.selectDate('Expiration date', 'user', 'expiration_date', null, '"+jsDateFormat + "')"%>"
    449458          image="calendar.png"
    450459          title="Calendar&hellip;"
  • trunk/www/admin/users/index.jsp

    r2900 r2942  
    4747  import="net.sf.basedb.util.Values"
    4848  import="net.sf.basedb.clients.web.util.HTML"
     49  import="net.sf.basedb.util.formatter.Formatter"
     50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     51  import="java.util.Date"
    4952  import="java.util.Enumeration"
    5053  import="java.util.Set"
     
    186189    }
    187190   
    188     user.setExpirationDate(Values.getDate(request.getParameter("expiration_date")));
     191    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     192    user.setExpirationDate(dateFormatter.parseString(request.getParameter("expiration_date")));
    189193    user.setMultiuserAccount(Values.getBoolean(request.getParameter("multiuser_account")));
    190194    user.setDisabled(Values.getBoolean(request.getParameter("disabled")));
  • trunk/www/admin/users/list_users.jsp

    r2818 r2942  
    5252  import="net.sf.basedb.clients.web.util.HTML"
    5353  import="net.sf.basedb.util.Values"
     54  import="net.sf.basedb.util.formatter.Formatter"
     55  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5456  import="java.util.List"
    5557  import="java.util.Map"
     58  import="java.util.Date"
    5659%>
    5760<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7780try
    7881{
     82  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     83
    7984  // Query for groups relatated to the current user
    8085  final ItemQuery<Group> groupQuery = Group.getQuery();
     
    259264        filterable="true"
    260265        exportable="true"
     266        formatter="<%=dateFormatter%>"
    261267      />
    262268      <tbl:columndef
     
    527533                <tbl:cell column="systemId"><%=Values.getString(item.getSystemId())%></tbl:cell>
    528534                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
    529                 <tbl:cell column="expirationDate"><%=Values.formatDate(item.getExpirationDate())%></tbl:cell>
     535                <tbl:cell column="expirationDate" value="<%=item.getExpirationDate()%>" />
    530536                <tbl:cell column="disabled"><%=item.isDisabled() ? "yes" : "no" %></tbl:cell>
    531537                <tbl:cell column="multiuserAccount"><%=item.isMultiuserAccount() ? "yes" : "no" %></tbl:cell>
  • trunk/www/admin/users/view_user.jsp

    r2753 r2942  
    5050  import="net.sf.basedb.clients.web.util.HTML"
    5151  import="net.sf.basedb.util.Values"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.Map"
     55  import="java.util.Date"
    5356%>
    5457<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    6972try
    7073{
     74  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7175  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7276
     
    225229          <td class="prompt">Expiration date</td>
    226230          <td><%=user.getExpirationDate() == null ? "<i>- never -</i>" :
    227             Values.formatDate(user.getExpirationDate())%></td>
     231            dateFormatter.format(user.getExpirationDate())%></td>
    228232        </tr>
    229233        <tr valign="baseline">
  • trunk/www/biomaterials/biosources/list_biosources.jsp

    r2916 r2942  
    5252  import="net.sf.basedb.clients.web.PermissionUtil"
    5353  import="net.sf.basedb.clients.web.util.HTML"
     54  import="net.sf.basedb.util.formatter.Formatter"
     55  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5456  import="net.sf.basedb.util.Values"
     57  import="java.util.Date"
    5558  import="java.util.List"
    5659  import="java.util.Map"
     
    7780{
    7881  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
    79   final ItemQuery<BioSource> query = Base.getConfiguredQuery(cc, true, BioSource.getQuery(), mode);
    8082  final ItemQuery<Sample> sampleQuery = Sample.getQuery();
    8183  sampleQuery.include(cc.getInclude());
     
    8890  try
    8991  {
     92    final ItemQuery<BioSource> query = Base.getConfiguredQuery(cc, true, BioSource.getQuery(), mode);
    9093    bioSources = query.iterate(dc);
    9194  }
     
    9598  }
    9699  int numListed = 0;
     100  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    97101  %>
    98102  <base:page title="<%=title==null ? "Biosources" : title%>" type="<%=mode.getPageType()%>">
     
    263267      {
    264268        Enumeration<String, String> annotationEnum = null;
     269        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    265270        if (at.isEnumeration())
    266271        {
     
    269274          for (Object value : values)
    270275          {
    271             String encoded = HTML.encodeTags(value.toString());
     276            String encoded = formatter.format(value);
    272277            annotationEnum.add(encoded, encoded);
    273278          }
     
    284289          filterable="true"
    285290          exportable="true"
     291          formatter="<%=formatter%>"
    286292        />
    287293        <%
     
    497503                <%
    498504                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    499                 for (AnnotationType at : annotationTypes)
     505                if (as != null)
    500506                {
    501                   %>
    502                   <tbl:cell column="<%="at"+at.getId()%>">
    503                     <%
    504                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    505                     %>
    506                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    507                   </tbl:cell>
    508                   <%
     507                  for (AnnotationType at : annotationTypes)
     508                  {
     509                    if (as.hasAnnotation(at))
     510                    {
     511                      %>
     512                      <tbl:cell column="<%="at"+at.getId()%>"
     513                        ><tbl:cellvalue
     514                        list="<%=as.getAnnotation(at).getValues()%>"
     515                      /></tbl:cell>
     516                      <%
     517                    }
     518                  }
    509519                }
    510520                %>
  • trunk/www/biomaterials/events/edit_event.jsp

    r2753 r2942  
    3939  import="net.sf.basedb.clients.web.util.HTML"
    4040  import="net.sf.basedb.util.Values"
     41  import="net.sf.basedb.util.formatter.Formatter"
     42  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     43  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    4144  import="java.util.Date"
    4245  import="java.util.List"
     
    5962  BioMaterialEvent event = null;
    6063  MeasuredBioMaterial bioMaterial = null;
     64  Date eventDate = null;
    6165 
    6266  boolean readCurrentProtocol = true;
     
    7074    title = "Create event";
    7175    cc.removeObject("item");
     76    eventDate = (Date)cc.getPropertyObject("eventDate");
    7277  }
    7378  else
    7479  {
    7580    event = BioMaterialEvent.getById(dc, itemId);
     81    eventDate = event.getEventDate();
    7682    title = "Edit event";
    7783    cc.setObject("item", event);
     
    9298  final String clazz = "class=\"text\"";
    9399  final String requiredClazz = "class=\"text required\"";
    94  
     100  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     101  String dateFormat = FormatterSettings.getDateFormat(sc);
     102  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     103  String htmlDateFormat = HTML.encodeTags(dateFormat);
    95104  %>
    96105
     
    173182          <td>
    174183            <input <%=clazz%> type="text" name="event_date"
    175               value="<%=Values.formatDate(event == null ? Values.getDate(cc.getPropertyValue("eventDate"), new Date()) : event.getEventDate())%>"
    176               size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    177             (yyyy-mm-dd)&nbsp;
     184              value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>"
     185              size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
     186            &nbsp;
    178187          </td>
    179188          <td>
    180189          <base:button
    181             onclick="Dates.selectDate('Date', 'event', 'event_date')"
     190            onclick="<%="Dates.selectDate('Event date', 'event', 'event_date', null, '"+jsDateFormat+"')"%>"
    182191            image="calendar.png"
    183192            title="Calendar&hellip;"
  • trunk/www/biomaterials/events/index.jsp

    r2811 r2942  
    4141  import="net.sf.basedb.clients.web.util.HTML"
    4242  import="net.sf.basedb.util.Values"
     43  import="net.sf.basedb.util.formatter.Formatter"
     44  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     45  import="java.util.Date"
    4346  import="java.util.List"
    4447  import="java.util.Collections"
     
    134137      message = "Event updated";
    135138    }
     139    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    136140    event.setComment(Values.getStringOrNull(request.getParameter("comment")));
    137     event.setEventDate(Values.getDate(request.getParameter("event_date")));
     141    event.setEventDate(dateFormatter.parseString(request.getParameter("event_date")));
    138142    event.setUsedQuantity(Values.getFloat(request.getParameter("used_quantity"), null));
    139143    int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
  • trunk/www/biomaterials/events/list_events.jsp

    r2875 r2942  
    4949  import="net.sf.basedb.clients.web.util.HTML"
    5050  import="net.sf.basedb.util.Values"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5153  import="java.util.List"
    5254  import="java.util.Map"
     55  import="java.util.Date"
    5356%>
    5457<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    9699  }
    97100 
    98   final ItemQuery<BioMaterialEvent> query = Base.getConfiguredQuery(cc, true, bioMaterial.getEvents(), mode);
    99   // Skip the creation event
    100   query.restrict(
    101     Restrictions.not(
    102       Restrictions.and(
    103         Restrictions.eq(
    104           Hql.property("eventType"),
    105           Expressions.integer(BioMaterialEvent.Type.CREATION.getValue())
    106         ),
    107         Restrictions.eq(
    108           Hql.property("bioMaterial"),
    109           Hql.entity(bioMaterial)
    110         )
    111       )
    112     )
    113   );
    114 
    115101  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    116102  try
    117103  {
     104    final ItemQuery<BioMaterialEvent> query = Base.getConfiguredQuery(cc, true, bioMaterial.getEvents(), mode);
     105    // Skip the creation event
     106    query.restrict(
     107      Restrictions.not(
     108        Restrictions.and(
     109          Restrictions.eq(
     110            Hql.property("eventType"),
     111            Expressions.integer(BioMaterialEvent.Type.CREATION.getValue())
     112          ),
     113          Restrictions.eq(
     114            Hql.property("bioMaterial"),
     115            Hql.entity(bioMaterial)
     116          )
     117        )
     118      )
     119    );
    118120    events = query.iterate(dc);
    119121  }
     
    123125  }
    124126  int numListed = 0;
     127  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    125128  %>
    126129  <base:page title="<%=title%>" type="<%=mode.getPageType()%>">
     
    274277        filterable="true"
    275278        exportable="true"
     279        formatter="<%=dateFormatter%>"
    276280      />
    277281      <tbl:columndef
     
    283287        filterable="true"
    284288        exportable="true"
     289        formatter="<%=dateFormatter%>"
    285290      />
    286291      <tbl:columndef
     
    486491                  %>
    487492                </tbl:cell>
    488                 <tbl:cell column="eventDate"><%=Values.formatDate(item.getEventDate())%></tbl:cell>
    489                 <tbl:cell column="entryDate"><%=Values.formatDate(item.getEntryDate())%></tbl:cell>
     493                <tbl:cell column="eventDate" value="<%=item.getEventDate()%>" />
     494                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
    490495                <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(bioMaterial), 2)%></tbl:cell>
    491496                <tbl:cell column="protocol"
  • trunk/www/biomaterials/events/view_event.jsp

    r2753 r2942  
    5050  import="net.sf.basedb.clients.web.util.HTML"
    5151  import="net.sf.basedb.util.Values"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.Date"
    5355  import="java.util.Map"
     
    7375try
    7476{
     77  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7578  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7679
     
    179182      <tr>
    180183        <td class="prompt">Event date</td>
    181         <td><%=Values.formatDate(event.getEventDate())%></td>
     184        <td><%=dateFormatter.format(event.getEventDate())%></td>
    182185      </tr>
    183186      <tr>
    184187        <td class="prompt">Registration date</td>
    185         <td><%=Values.formatDate(event.getEntryDate())%></td>
     188        <td><%=dateFormatter.format(event.getEntryDate())%></td>
    186189      </tr>
    187190      <tr>
  • trunk/www/biomaterials/extracts/edit_extract.jsp

    r2875 r2942  
    4848  import="net.sf.basedb.clients.web.util.HTML"
    4949  import="net.sf.basedb.util.Values"
     50  import="net.sf.basedb.util.formatter.Formatter"
     51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     52  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5053  import="java.util.List"
    5154  import="java.util.Set"
     
    6871  Extract extract = null;
    6972  BioMaterialEvent creationEvent = null;
     73  Date eventDate = null;
    7074  boolean isPooled = false;
    7175
     
    107111      name = Values.getString(cc.getPropertyValue("name"), "New extract");
    108112    }
     113    eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate");
    109114  }
    110115  else
     
    115120 
    116121    creationEvent = extract.getCreationEvent();
     122    eventDate = creationEvent.getEventDate();
    117123    isPooled = extract.isPooled();
    118124    name = extract.getName();
     
    149155  final String clazz = "class=\"text\"";
    150156  final String requiredClazz = "class=\"text required\"";
     157  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     158  String dateFormat = FormatterSettings.getDateFormat(sc);
     159  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     160  String htmlDateFormat = HTML.encodeTags(dateFormat);
    151161  %>
    152162
     
    456466      </tr>
    457467      <tr>
    458         <td class="prompt">Remaining quantity</td>
    459         <td><%=Values.formatNumber(extract == null ? null : extract.getRemainingQuantity(), 2, " µg")%></td>
    460       </tr>
    461       <tr>
    462468        <td class="prompt">Created</td>
    463469        <td>
     
    466472          <td>
    467473            <input <%=clazz%> type="text" name="event_date"
    468               value="<%=Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"
    469               size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    470             (yyyy-mm-dd)&nbsp;
     474              value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>"
     475              size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
     476            &nbsp;
    471477          </td>
    472478          <td>
    473479          <base:button
    474             onclick="Dates.selectDate('Date', 'extract', 'event_date')"
     480            onclick="<%="Dates.selectDate('Created', 'extract', 'event_date', null, '"+jsDateFormat+"')"%>"
    475481            image="calendar.png"
    476482            title="Calendar&hellip;"
     
    484490      <tr>
    485491        <td class="prompt">Registered</td>
    486         <td><%=Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
     492        <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
    487493      </tr>
    488494      <tr>
  • trunk/www/biomaterials/extracts/index.jsp

    r2917 r2942  
    4848  import="net.sf.basedb.util.Values"
    4949  import="net.sf.basedb.clients.web.util.HTML"
     50  import="net.sf.basedb.util.formatter.Formatter"
     51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5052  import="java.util.Enumeration"
    5153  import="java.util.Set"
     
    5456  import="java.util.ArrayList"
    5557  import="java.util.Collections"
     58  import="java.util.Date"
    5659%>
    5760<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    161164   
    162165    BioMaterialEvent creationEvent = extract.getCreationEvent();
    163     creationEvent.setEventDate(Values.getDate(request.getParameter("event_date")));
     166    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     167    creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date")));
    164168    int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
    165169    if (protocolId >= 0) // < 0 = denied or unchanged
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r2917 r2942  
    5454  import="net.sf.basedb.clients.web.PermissionUtil"
    5555  import="net.sf.basedb.clients.web.util.HTML"
     56  import="net.sf.basedb.util.formatter.Formatter"
     57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5658  import="net.sf.basedb.util.Values"
    5759  import="java.util.List"
    5860  import="java.util.Map"
     61  import="java.util.Date"
    5962%>
    6063<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    97100  }
    98101  int numListed = 0;
     102  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    99103  %>
    100104  <base:page title="<%=title==null ? "Extracts" : title%>" type="<%=mode.getPageType()%>">
     
    281285        filterable="true"
    282286        exportable="true"
     287        formatter="<%=dateFormatter%>"
    283288      />
    284289      <tbl:columndef
     
    290295        filterable="true"
    291296        exportable="true"
     297        formatter="<%=dateFormatter%>"
    292298      />
    293299      <tbl:columndef
     
    330336      {
    331337        Enumeration<String, String> annotationEnum = null;
     338        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    332339        if (at.isEnumeration())
    333340        {
     
    336343          for (Object value : values)
    337344          {
    338             String encoded = HTML.encodeTags(value.toString());
     345            String encoded = formatter.format(value);
    339346            annotationEnum.add(encoded, encoded);
    340347          }
     
    351358          filterable="true"
    352359          exportable="true"
     360          formatter="<%=formatter%>"
    353361        />
    354362        <%
     
    538546                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    539547                  /></tbl:cell>
    540                 <tbl:cell column="eventDate"><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>
    541                 <tbl:cell column="entryDate"><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>
     548                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
     549                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
    542550                <tbl:cell column="parents">
    543551                  <%
     
    620628                <%
    621629                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    622                 for (AnnotationType at : annotationTypes)
     630                if (as != null)
    623631                {
    624                   %>
    625                   <tbl:cell column="<%="at"+at.getId()%>">
    626                     <%
    627                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    628                     %>
    629                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    630                   </tbl:cell>
    631                   <%
     632                  for (AnnotationType at : annotationTypes)
     633                  {
     634                    if (as.hasAnnotation(at))
     635                    {
     636                      %>
     637                      <tbl:cell column="<%="at"+at.getId()%>"
     638                        ><tbl:cellvalue
     639                        list="<%=as.getAnnotation(at).getValues()%>"
     640                      /></tbl:cell>
     641                      <%
     642                    }
     643                  }
    632644                }
    633645                %>
  • trunk/www/biomaterials/extracts/view_extract.jsp

    r2917 r2942  
    5454  import="net.sf.basedb.clients.web.util.HTML"
    5555  import="net.sf.basedb.util.Values"
     56  import="net.sf.basedb.util.formatter.Formatter"
     57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5658  import="java.util.Date"
    5759  import="java.util.Map"
     
    7779try
    7880{
     81  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7982  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    8083
     
    253256      <tr>
    254257        <td class="prompt">Created</td>
    255         <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
     258        <td><%=dateFormatter.format(creationEvent.getEventDate())%></td>
    256259      </tr>
    257260      <tr>
    258261        <td class="prompt">Registered</td>
    259         <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
     262        <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td>
    260263      </tr>
    261264      <%
  • trunk/www/biomaterials/labeledextracts/edit_labeledextract.jsp

    r2875 r2942  
    4949  import="net.sf.basedb.clients.web.util.HTML"
    5050  import="net.sf.basedb.util.Values"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     53  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5154  import="java.util.List"
    5255  import="java.util.Set"
     
    6972  LabeledExtract extract = null;
    7073  BioMaterialEvent creationEvent = null;
     74  Date eventDate = null;
    7175  boolean isPooled = false;
    7276
     
    121125      name = Values.getString(cc.getPropertyValue("name"), "New labeled extract");
    122126    }
     127    eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate");
    123128  }
    124129  else
     
    129134 
    130135    creationEvent = extract.getCreationEvent();
     136    eventDate = creationEvent.getEventDate();
    131137    isPooled = extract.isPooled();
    132138    name = extract.getName();
     
    180186  final String clazz = "class=\"text\"";
    181187  final String requiredClazz = "class=\"text required\"";
     188  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     189  String dateFormat = FormatterSettings.getDateFormat(sc);
     190  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     191  String htmlDateFormat = HTML.encodeTags(dateFormat);
    182192  %>
    183193
     
    512522      </tr>
    513523      <tr>
    514         <td class="prompt">Remaining quantity</td>
    515         <td><%=Values.formatNumber(extract == null ? null : extract.getRemainingQuantity(), 2, " µg")%></td>
    516       </tr>
    517       <tr>
    518524        <td class="prompt">Created</td>
    519525        <td>
     
    522528          <td>
    523529            <input <%=clazz%> type="text" name="event_date"
    524               value="<%=Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"
    525               size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    526             (yyyy-mm-dd)&nbsp;
     530              value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>"
     531              size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
     532            &nbsp;
    527533          </td>
    528534          <td>
    529535          <base:button
    530             onclick="Dates.selectDate('Date', 'extract', 'event_date')"
     536            onclick="<%="Dates.selectDate('Created', 'labeledextract', 'event_date', null, '"+jsDateFormat+"')"%>"
    531537            image="calendar.png"
    532538            title="Calendar&hellip;"
     
    540546      <tr>
    541547        <td class="prompt">Registered</td>
    542         <td><%=Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
     548        <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
    543549      </tr>
    544550      <tr>
  • trunk/www/biomaterials/labeledextracts/index.jsp

    r2917 r2942  
    4949  import="net.sf.basedb.util.Values"
    5050  import="net.sf.basedb.clients.web.util.HTML"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5153  import="java.util.Enumeration"
    5254  import="java.util.Set"
     
    5557  import="java.util.ArrayList"
    5658  import="java.util.Collections"
     59  import="java.util.Date"
    5760%>
    5861<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    175178   
    176179    BioMaterialEvent creationEvent = extract.getCreationEvent();
    177     creationEvent.setEventDate(Values.getDate(request.getParameter("event_date")));
     180    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     181    creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date")));
    178182    int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
    179183    if (protocolId >= 0) // < 0 = denied or unchanged
  • trunk/www/biomaterials/labeledextracts/list_labeledextracts.jsp

    r2917 r2942  
    5454  import="net.sf.basedb.clients.web.PermissionUtil"
    5555  import="net.sf.basedb.clients.web.util.HTML"
     56  import="net.sf.basedb.util.formatter.Formatter"
     57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5658  import="net.sf.basedb.util.Values"
    5759  import="java.util.List"
    5860  import="java.util.Map"
     61  import="java.util.Date"
    5962%>
    6063<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    9396  }
    9497  int numListed = 0;
     98  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    9599  %>
    96100  <base:page title="<%=title==null ? "Labeled extract" : title%>" type="<%=mode.getPageType()%>">
     
    289293        filterable="true"
    290294        exportable="true"
     295        formatter="<%=dateFormatter%>"
    291296      />
    292297      <tbl:columndef
     
    298303        filterable="true"
    299304        exportable="true"
     305        formatter="<%=dateFormatter%>"
    300306      />
    301307      <tbl:columndef
     
    338344      {
    339345        Enumeration<String, String> annotationEnum = null;
     346        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    340347        if (at.isEnumeration())
    341348        {
     
    344351          for (Object value : values)
    345352          {
    346             String encoded = HTML.encodeTags(value.toString());
     353            String encoded = formatter.format(value);
    347354            annotationEnum.add(encoded, encoded);
    348355          }
     
    359366          filterable="true"
    360367          exportable="true"
     368          formatter="<%=formatter%>"
    361369        />
    362370        <%
     
    560568                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    561569                  /></tbl:cell>
    562                 <tbl:cell column="eventDate"><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>
    563                 <tbl:cell column="entryDate"><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>
     570                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
     571                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
    564572                <tbl:cell column="parents">
    565573                  <%
     
    632640                <%
    633641                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    634                 for (AnnotationType at : annotationTypes)
     642                if (as != null)
    635643                {
    636                   %>
    637                   <tbl:cell column="<%="at"+at.getId()%>">
    638                     <%
    639                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    640                     %>
    641                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    642                   </tbl:cell>
    643                   <%
     644                  for (AnnotationType at : annotationTypes)
     645                  {
     646                    if (as.hasAnnotation(at))
     647                    {
     648                      %>
     649                      <tbl:cell column="<%="at"+at.getId()%>"
     650                        ><tbl:cellvalue
     651                        list="<%=as.getAnnotation(at).getValues()%>"
     652                      /></tbl:cell>
     653                      <%
     654                    }
     655                  }
    644656                }
    645657                %>
  • trunk/www/biomaterials/labeledextracts/view_labeledextract.jsp

    r2917 r2942  
    5252  import="net.sf.basedb.clients.web.util.HTML"
    5353  import="net.sf.basedb.util.Values"
     54  import="net.sf.basedb.util.formatter.Formatter"
     55  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5456  import="java.util.Date"
    5557  import="java.util.Map"
     
    7678{
    7779  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     80  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7881
    7982  String title = null;
     
    255258      <tr>
    256259        <td class="prompt">Created</td>
    257         <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
     260        <td><%=dateFormatter.format(creationEvent.getEventDate())%></td>
    258261      </tr>
    259262      <tr>
    260263        <td class="prompt">Registered</td>
    261         <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
     264        <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td>
    262265      </tr>
    263266      <%
  • trunk/www/biomaterials/samples/edit_sample.jsp

    r2875 r2942  
    4848  import="net.sf.basedb.clients.web.util.HTML"
    4949  import="net.sf.basedb.util.Values"
     50  import="net.sf.basedb.util.formatter.Formatter"
     51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     52  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5053  import="java.util.List"
    5154  import="java.util.Set"
     
    6871  Sample sample = null;
    6972  BioMaterialEvent creationEvent = null;
     73  Date eventDate = null;
    7074  boolean isPooled = false;
    7175  String name = null;
     
    106110      name = Values.getString(cc.getPropertyValue("name"), "New sample");
    107111    }
     112    eventDate = (Date)cc.getPropertyObject("creationEvent.eventDate");
    108113  }
    109114  else
     
    114119 
    115120    creationEvent = sample.getCreationEvent();
     121    eventDate = creationEvent.getEventDate();
    116122    isPooled = sample.isPooled();
    117123    name = sample.getName();
     
    147153  final String clazz = "class=\"text\"";
    148154  final String requiredClazz = "class=\"text required\"";
     155  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     156  String dateFormat = FormatterSettings.getDateFormat(sc);
     157  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     158  String htmlDateFormat = HTML.encodeTags(dateFormat);
    149159  %>
    150160
     
    440450      </tr>
    441451      <tr>
    442         <td class="prompt">Remaining quantity</td>
    443         <td><%=Values.formatNumber(sample == null ? null : sample.getRemainingQuantity(), 2, " µg")%></td>
    444       </tr>
    445       <tr>
    446452        <td class="prompt">Created</td>
    447453        <td>
     
    450456          <td>
    451457            <input <%=clazz%> type="text" name="event_date"
    452               value="<%=Values.formatDate(creationEvent == null ? Values.getDate(cc.getPropertyValue("creationEvent.eventDate"), new Date()): creationEvent.getEventDate())%>"
    453               size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    454             (yyyy-mm-dd)&nbsp;
     458              value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>"
     459              size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
     460            &nbsp;
    455461          </td>
    456462          <td>
    457463          <base:button
    458             onclick="Dates.selectDate('Date', 'sample', 'event_date')"
     464            onclick="<%="Dates.selectDate('Created', 'sample', 'event_date', null, '"+jsDateFormat+"')"%>"
    459465            image="calendar.png"
    460466            title="Calendar&hellip;"
     
    468474      <tr>
    469475        <td class="prompt">Registered</td>
    470         <td><%=Values.formatDate(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
     476        <td><%=dateFormatter.format(creationEvent == null ? new Date() : creationEvent.getEntryDate())%></td>
    471477      </tr>
    472478      <tr>
  • trunk/www/biomaterials/samples/index.jsp

    r2917 r2942  
    4848  import="net.sf.basedb.util.Values"
    4949  import="net.sf.basedb.clients.web.util.HTML"
     50  import="net.sf.basedb.util.formatter.Formatter"
     51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5052  import="java.util.Enumeration"
    5153  import="java.util.Set"
     
    5456  import="java.util.ArrayList"
    5557  import="java.util.Collections"
     58  import="java.util.Date"
    5659%>
    5760<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    161164   
    162165    BioMaterialEvent creationEvent = sample.getCreationEvent();
    163     creationEvent.setEventDate(Values.getDate(request.getParameter("event_date")));
     166    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     167    creationEvent.setEventDate(dateFormatter.parseString(request.getParameter("event_date")));
    164168    int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
    165169    if (protocolId >= 0) // < 0 = denied or unchanged
  • trunk/www/biomaterials/samples/list_samples.jsp

    r2917 r2942  
    5656  import="net.sf.basedb.clients.web.util.HTML"
    5757  import="net.sf.basedb.util.Values"
     58  import="net.sf.basedb.util.formatter.Formatter"
     59  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5860  import="java.util.List"
    5961  import="java.util.Map"
     62  import="java.util.Date"
    6063%>
    6164<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    8083{
    8184  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
    82   final ItemQuery<Sample> query = Base.getConfiguredQuery(cc, true, Sample.getQuery(), mode);
    8385  final ItemQuery<Extract> extractQuery = Extract.getQuery();
    8486  extractQuery.include(cc.getInclude());
     
    9193  try
    9294  {
     95    final ItemQuery<Sample> query = Base.getConfiguredQuery(cc, true, Sample.getQuery(), mode);
    9396    samples = query.iterate(dc);
    9497  }
     
    98101  }
    99102  int numListed = 0;
     103  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    100104  %>
    101105  <base:page title="<%=title==null ? "Samples" : title%>" type="<%=mode.getPageType()%>">
     
    282286        filterable="true"
    283287        exportable="true"
     288        formatter="<%=dateFormatter%>"
    284289      />
    285290      <tbl:columndef
     
    291296        filterable="true"
    292297        exportable="true"
     298        formatter="<%=dateFormatter%>"
    293299      />
    294300      <tbl:columndef
     
    331337      {
    332338        Enumeration<String, String> annotationEnum = null;
     339        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    333340        if (at.isEnumeration())
    334341        {
     
    337344          for (Object value : values)
    338345          {
    339             String encoded = HTML.encodeTags(value.toString());
     346            String encoded = formatter.format(value);
    340347            annotationEnum.add(encoded, encoded);
    341348          }
     
    352359          filterable="true"
    353360          exportable="true"
     361          formatter="<%=formatter%>"
    354362        />
    355363        <%
     
    539547                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    540548                  /></tbl:cell>
    541                 <tbl:cell column="eventDate"><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>
    542                 <tbl:cell column="entryDate"><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>
     549                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
     550                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
    543551                <tbl:cell column="parents">
    544552                  <%
     
    616624                <%
    617625                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    618                 for (AnnotationType at : annotationTypes)
     626                if (as != null)
    619627                {
    620                   %>
    621                   <tbl:cell column="<%="at"+at.getId()%>">
    622                     <%
    623                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    624                     %>
    625                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    626                   </tbl:cell>
    627                   <%
     628                  for (AnnotationType at : annotationTypes)
     629                  {
     630                    if (as.hasAnnotation(at))
     631                    {
     632                      %>
     633                      <tbl:cell column="<%="at"+at.getId()%>"
     634                        ><tbl:cellvalue
     635                        list="<%=as.getAnnotation(at).getValues()%>"
     636                      /></tbl:cell>
     637                      <%
     638                    }
     639                  }
    628640                }
    629641                %>
  • trunk/www/biomaterials/samples/view_sample.jsp

    r2917 r2942  
    5151  import="net.sf.basedb.clients.web.util.HTML"
    5252  import="net.sf.basedb.util.Values"
     53  import="net.sf.basedb.util.formatter.Formatter"
     54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5355  import="java.util.Date"
    5456  import="java.util.Map"
     
    7476try
    7577{
     78  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7679  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7780
     
    250253      <tr>
    251254        <td class="prompt">Created</td>
    252         <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
     255        <td><%=dateFormatter.format(creationEvent.getEventDate())%></td>
    253256      </tr>
    254257      <tr>
    255258        <td class="prompt">Registered</td>
    256         <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
     259        <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td>
    257260      </tr>
    258261      <%
  • trunk/www/common/annotations/annotate.jsp

    r2885 r2942  
    5050  import="net.sf.basedb.clients.web.Base"
    5151  import="net.sf.basedb.clients.web.util.HTML"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     54  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5255  import="net.sf.basedb.util.Values"
    5356  import="java.util.ArrayList"
     
    7477try
    7578{
     79  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     80  String dateFormat = FormatterSettings.getDateFormat(sc);
     81  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     82  String htmlDateFormat = HTML.encodeTags(dateFormat);
     83
    7684  final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
    7785  Protocol protocol = null;
     
    128136    annotationTypes = new TreeSet<AnnotationType>(new NameableComparator(false));
    129137    annotationTypes.addAll(annotationTypeQuery.list(dc));
     138    if (annotationTypeId != 0)
     139    {
     140      annotationTypes.add(AnnotationType.getById(dc, annotationTypeId));
     141    }
    130142    if (parameterQuery != null)
    131143    {
     
    153165        for (Object value : values)
    154166        {
    155           if (value instanceof Date) value = Values.formatDate((Date)value);
     167          if (value instanceof Date) value = dateFormatter.format((Date)value);
    156168          %>
    157169          values[values.length] = '<%=HTML.javaScriptEncode(value.toString())%>';
     
    573585          {
    574586            List<?> values = at.getValues();
    575             %>
     587            Formatter f = FormatterFactory.getTypeFormatter(sc, at.getValueType());           %>
    576588            <b><%=HTML.encodeTags(at.getName())%></b> (<%=select%>)<br>
    577589            <%
     
    595607              for (Object value : values)
    596608              {
    597                 String encoded = HTML.encodeTags(value.toString());
     609                String encoded = f.format(value);
    598610                %>
    599611                <option value="<%=encoded%>"><%=encoded%>
     
    620632              for (Object value : values)
    621633              {
    622                 if (value instanceof Date) value = Values.formatDate((Date)value);
    623                 String encoded = HTML.encodeTags(value.toString());
     634                String encoded = f.format(value);
    624635                %>
    625636                <input name="<%=inputName%>" type="<%=checkType%>"
     
    725736              <b><%=HTML.encodeTags(at.getName())%></b> (Date)<br>
    726737              <input <%=clazz%> type="text" name="<%=inputName%>" value=""
    727                 size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)"
     738                size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"
    728739                onblur="valueOnBlur(this.value)">
    729740            </td>
     
    731742                <br>
    732743                <base:button
    733                   onclick="<%="Dates.selectDate('Value', 'annotations', '"+inputName+"', 'setDateCallback')"%>"
     744                  onclick="<%="Dates.selectDate('Value', 'annotations', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>"
    734745                  image="calendar.png"
    735746                  title="Calendar&hellip;"
  • trunk/www/common/annotations/inherit.jsp

    r2893 r2942  
    5151  import="net.sf.basedb.clients.web.util.HTML"
    5252  import="net.sf.basedb.util.Values"
     53  import="net.sf.basedb.util.formatter.Formatter"
     54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5355  import="java.util.List"
    5456  import="java.util.Set"
     
    110112
    111113    List<Annotation> annotations = as.getAnnotations().list(as.getDbControl());
     114    SessionControl sc = as.getSessionControl();
    112115    for (Annotation a : annotations)
    113116    {
     117      Formatter formatter = FormatterFactory.getTypeFormatter(sc, a.getValueType());
    114118      boolean inherited = inheritedAnnotations != null && inheritedAnnotations.contains(a);
    115119      AnnotationType at = null;
     
    124128      catch (PermissionDeniedException ex)
    125129      {}
    126       String values = HTML.encodeTags(Values.getString(a.getValues(), ", ", true));
     130      String values = Values.getString(a.getValues(), ", ", true, formatter);
    127131      name = HTML.javaScriptEncode(annotationName +
    128132        " [" + Values.trimString(values, 20)+"]");
  • trunk/www/common/annotations/list_annotations.jsp

    r2893 r2942  
    4343  import="net.sf.basedb.clients.web.Base"
    4444  import="net.sf.basedb.clients.web.util.HTML"
     45  import="net.sf.basedb.util.formatter.Formatter"
     46  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4547  import="net.sf.basedb.util.Values"
    4648  import="java.util.List"
     
    145147            for (AnnotationType at : annotationTypes)
    146148            {
    147               List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
     149              Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     150              List<?> values = as == null || !as.hasAnnotation(at) ?
     151                null : as.getAnnotation(at).getValues();
    148152              %>
    149153              <tbl:row>
    150154                <tbl:cell column="annotation"><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell>
    151                   <tbl:cell column="values"><%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%>
     155                  <tbl:cell column="values"><%=values == null || values.size() == 0 ? "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%>
    152156                  <%
    153157                    if (writePermission)
     
    214218              for (AnnotationType at : protocolParameters)
    215219              {
    216                 //String name = HTML.encodeTags(at.getName());
    217                 List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
     220                Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     221                List<?> values = as == null || !as.hasAnnotation(at) ?
     222                  null : as.getAnnotation(at).getValues();
    218223                %>
    219224                <tbl:row>
    220225                  <tbl:cell column="parameter"><%=Base.getLinkedName(ID, at, false, true)%></tbl:cell>
    221226                  <tbl:cell column="values">
    222                     <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%>
     227                    <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%>
    223228                    <%
    224229                    if (writePermission)
     
    292297              boolean writeInherited = false;
    293298              String icon = "joust/annotation.gif";
     299              Formatter formatter = FormatterFactory.getTypeFormatter(sc, a.getValueType());
    294300              try
    295301              {
     
    316322                <tbl:cell column="item"><%=Base.getLinkedName(ID, aItem, aItem == null, true)%><%=aItem != null ? " ["+aItem.getType()+"]" : ""%></tbl:cell>
    317323                <tbl:cell column="values">
    318                   <%=values == null || values.size() == 0 ? "<i>- no values -</i>" : HTML.encodeTags(Values.getString(values, ", ", true))%>
     324                  <%=values == null || values.size() == 0 ?
     325                    "<i>- no values -</i>" : Values.getString(values, ", ", true, formatter)%>
    319326                  <%
    320327                  if (writeInherited && aItem != null)
  • trunk/www/common/calendar.jsp

    r2753 r2942  
    3535<%@ page
    3636  import="net.sf.basedb.util.Values"
     37  import="net.sf.basedb.clients.web.util.HTML"
    3738  import="java.util.Date"
    3839%>
     
    4344  String input = request.getParameter("input");
    4445  String callback = request.getParameter("callback");
     46  String format = Values.getString(request.getParameter("format"), "yyyy-MM-dd");
    4547%>
    4648<base:page type="popup" title="<%=title%>">
     
    6062    var frm = window.opener.document.forms['<%=form%>'];
    6163    var dateString = frm['<%=input%>'].value;
    62     var date = Dates.parseString(dateString);
     64    var date = Dates.parseString(dateString, '<%=HTML.javaScriptEncode(format)%>');
    6365    if (date == null) date = new Date();
    6466    return date;
     
    6769  function setDate(theDate)
    6870  {
     71    var formattedDate = Dates.formatDate(theDate, '<%=HTML.javaScriptEncode(format)%>');
    6972    <%
    7073    if (callback == null)
     
    7275      %>
    7376      var frm = window.opener.document.forms['<%=form%>'];
    74       frm['<%=input%>'].value = theDate;
     77      frm['<%=input%>'].value = formattedDate;
    7578      <%
    7679    }
     
    7881    {
    7982      %>
    80       window.opener.<%=callback%>('<%=form%>', '<%=input%>', theDate);
     83      window.opener.<%=callback%>('<%=form%>', '<%=input%>', formattedDate);
    8184      <%
    8285    }
     
    8790  function setToday()
    8891  {
    89     setDate('<%=Values.formatDate(new Date())%>');
     92    setDate(new Date());
    9093  }
    9194 
     
    111114        {
    112115          cell.firstChild.nodeValue = dayOfMonth;
    113           cell.theDate = Dates.formatDate(Dates.newDate(year, month, dayOfMonth));
     116          cell.theDate = Dates.newDate(year, month, dayOfMonth);
    114117        }
    115118        if (year == today.getFullYear() && month == today.getMonth() && dayOfMonth == today.getDate())
  • trunk/www/common/plugin/configure.jsp

    r2762 r2942  
    5656  import="net.sf.basedb.clients.web.WebException"
    5757  import="net.sf.basedb.clients.web.util.HTML"
     58  import="net.sf.basedb.util.formatter.Formatter"
     59  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     60  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5861  import="net.sf.basedb.util.Values"
    5962  import="java.util.Date"
     
    7780try
    7881{
     82  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     83  String dateFormat = FormatterSettings.getDateFormat(sc);
     84  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     85  String htmlDateFormat = HTML.encodeTags(dateFormat);
     86
    7987  dc = sc.newDbControl();
    8088  PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request");
     
    193201                  else
    194202                  {
    195                     value = Values.formatDate((Date)value);
     203                    value = dateFormatter.format((Date)value);
    196204                  }
    197205                }
     
    763771                      {
    764772                        listValue = Long.toString(((Date)value).getTime());
    765                         if (enumeration == null) listText = Values.formatDate((Date)value);
     773                        if (enumeration == null) listText = dateFormatter.format((Date)value);
    766774                      }
    767775                      else if (value instanceof BasicItem)
     
    935943                      <input <%=pType.getNotNull() ? requiredClazz : clazz%>
    936944                        type="text" name="<%=inputName%>" value=""
    937                         size="20" maxlength="20" onkeypress="return Dates.dateOnly(event)"
     945                        size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"
    938946                        onblur="valueOnBlur(this.value)">
    939947                    </td>
     
    941949                      <br>
    942950                      <base:button
    943                         onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback')"%>"
     951                        onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>"
    944952                        image="calendar.png"
    945953                        title="Calendar&hellip;"
  • trunk/www/common/plugin/index.jsp

    r2868 r2942  
    6767  import="net.sf.basedb.clients.web.WebException"
    6868  import="net.sf.basedb.util.Values"
     69  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    6970  import="net.sf.basedb.clients.web.util.HTML"
    7071  import="net.sf.basedb.clients.web.util.ServletExportOutputStream"
     
    7778  import="java.util.Set"
    7879  import="java.util.HashSet"
     80  import="java.io.PrintWriter"
    7981%>
    8082<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    341343    PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request");
    342344    List<PluginParameter<?>> parameters =  pcRequest.getRequestInformation().getParameters();
     345    List<Throwable> parseErrors = new LinkedList<Throwable>();
    343346    ItemContext currentContext = (ItemContext)sc.getSessionSetting("plugin.configure.currentContext");
    344347    if (parameters != null && parameters.size() > 0)
     
    351354          String[] sValues = request.getParameterValues("parameter:"+param.getName());
    352355          Object[] oValues = null;
    353           if (sValues != null)
     356          try
    354357          {
    355             if (pType instanceof StringParameterType)
     358            if (sValues != null)
    356359            {
    357               oValues = sValues;
    358             }
    359             else if (pType instanceof IntegerParameterType)
    360             {
    361               oValues = Values.getInt(sValues);
    362             }
    363             else if (pType instanceof LongParameterType)
    364             {
    365               oValues = Values.getLong(sValues);
    366 //              oValues = Type.LONG.parseStrings(sValues);
    367             }
    368             else if (pType instanceof FloatParameterType)
    369             {
    370               oValues = Values.getFloat(sValues);
    371 //              oValues = Type.FLOAT.parseStrings(sValues);
    372             }
    373             else if (pType instanceof DoubleParameterType)
    374             {
    375               oValues = Values.getDouble(sValues);
    376 //              oValues = Type.DOUBLE.parseStrings(sValues);
    377             }
    378             else if (pType instanceof BooleanParameterType)
    379             {
    380               oValues = Type.BOOLEAN.parseStrings(sValues);
    381             }
    382             else if (pType instanceof DateParameterType)
    383             {
    384               oValues = Values.getDate(sValues);
    385 //              oValues = Type.DATE.parseStrings(sValues);
    386             }
    387             else if (pType instanceof ItemParameterType)
    388             {
    389               Integer[] itemId = Values.getInt(sValues);
    390               oValues = new Object[itemId.length];
    391               Item iType = Item.fromItemClass(pType.getParameterClass());
    392               dc = sc.newDbControl();
    393               for (int i = 0; i < itemId.length; ++i)
    394               {
    395                 Integer id = itemId[i];
    396                 if (id != null && id != 0)
     360              if (pType instanceof StringParameterType)
     361              {
     362                oValues = sValues;
     363              }
     364              else if (pType instanceof IntegerParameterType)
     365              {
     366                oValues = Values.getInt(sValues);
     367              }
     368              else if (pType instanceof LongParameterType)
     369              {
     370                oValues = Values.getLong(sValues);
     371              }
     372              else if (pType instanceof FloatParameterType)
     373              {
     374                oValues = Values.getFloat(sValues);
     375              }
     376              else if (pType instanceof DoubleParameterType)
     377              {
     378                oValues = Values.getDouble(sValues);
     379              }
     380              else if (pType instanceof BooleanParameterType)
     381              {
     382                oValues = Type.BOOLEAN.parseStrings(sValues);
     383              }
     384              else if (pType instanceof DateParameterType)
     385              {
     386                oValues = Values.getDate(sValues, FormatterFactory.getDateFormatter(sc));
     387              }
     388              else if (pType instanceof ItemParameterType)
     389              {
     390                Integer[] itemId = Values.getInt(sValues);
     391                oValues = new Object[itemId.length];
     392                Item iType = Item.fromItemClass(pType.getParameterClass());
     393                dc = sc.newDbControl();
     394                for (int i = 0; i < itemId.length; ++i)
    397395                {
    398                   BasicItem item = iType.getById(dc, id);
    399                   oValues[i] = item;
     396                  Integer id = itemId[i];
     397                  if (id != null && id != 0)
     398                  {
     399                    BasicItem item = iType.getById(dc, id);
     400                    oValues[i] = item;
     401                    if (currentContext != null)
     402                    {
     403                      currentContext.setRecent(item, maxRecent);
     404                    }
     405                  }
     406                }
     407                dc.close();
     408              }
     409              else if (pType instanceof FileParameterType)
     410              {
     411                oValues = new Object[sValues.length];
     412                dc = sc.newDbControl();
     413                for (int i = 0; i < sValues.length; ++i)
     414                {
     415                  File file = File.getByPath(dc, new Path(sValues[i], Path.Type.FILE), false);
     416                  oValues[i] = file;
    400417                  if (currentContext != null)
    401418                  {
    402                     currentContext.setRecent(item, maxRecent);
     419                    currentContext.setRecent(file, maxRecent);
    403420                  }
    404421                }
    405               }
    406               dc.close();
    407             }
    408             else if (pType instanceof FileParameterType)
    409             {
    410               oValues = new Object[sValues.length];
    411               dc = sc.newDbControl();
    412               for (int i = 0; i < sValues.length; ++i)
    413               {
    414                 File file = File.getByPath(dc, new Path(sValues[i], Path.Type.FILE), false);
    415                 oValues[i] = file;
    416                 if (currentContext != null)
    417                 {
    418                   currentContext.setRecent(file, maxRecent);
    419                 }
    420               }
    421               dc.close();
    422             }
    423             else if (pType instanceof PathParameterType)
    424             {
    425               oValues = sValues;
     422                dc.close();
     423              }
     424              else if (pType instanceof PathParameterType)
     425              {
     426                oValues = sValues;
     427              }
    426428            }
    427429          }
     430          catch (Throwable t)
     431          {
     432            parseErrors.add(t);
     433          }
    428434          pcRequest.setParameterValues(param.getName(), oValues == null ? null : Arrays.asList(oValues));
    429435        }
    430436      }
    431437    }
    432     PluginResponse pluginResponse = pcRequest.invoke();
    433     Response.Status status = pluginResponse.getStatus();
     438    PluginResponse pluginResponse = null;
     439    Response.Status status = null;
     440    if (parseErrors.size() == 0)
     441    {
     442      pluginResponse = pcRequest.invoke();
     443      status = pluginResponse.getStatus();
     444    }
     445    else
     446    {
     447      status = Response.Status.ERROR;
     448    }
    434449    if (status == Response.Status.DONE || status == Response.Status.EXECUTE_IMMEDIATELY)
    435450    {
     
    464479    {
    465480      PluginDefinition plugin = (PluginDefinition)sc.getSessionSetting("plugin.configure.plugin");
    466       sc.setSessionSetting("plugin.configure.errors.message", pluginResponse.getMessage());
    467       sc.setSessionSetting("plugin.configure.errors.list", pluginResponse.getErrorList());
     481      if (parseErrors.size() > 0)
     482      {
     483        sc.setSessionSetting("plugin.configure.errors.message",
     484          parseErrors.size() + " parameter value(s) are invalid");
     485        sc.setSessionSetting("plugin.configure.errors.list", parseErrors);
     486      }
     487      else
     488      {
     489        sc.setSessionSetting("plugin.configure.errors.message", pluginResponse.getMessage());
     490        sc.setSessionSetting("plugin.configure.errors.list", pluginResponse.getErrorList());
     491      }
    468492      forward = getJspPage(pcRequest, plugin, "configure.jsp");
    469493    }
     
    511535    PluginResponse pluginResponse = (PluginResponse)sc.getSessionSetting("plugin.configure.response");
    512536    ExportOutputStream exportStream = new ServletExportOutputStream(response);
    513     pluginResponse.downloadImmediately(exportStream, null);
     537    try
     538    {
     539      pluginResponse.downloadImmediately(exportStream, null);
     540    }
     541    catch (Throwable t)
     542    {
     543      PrintWriter pw = new PrintWriter(exportStream, true);
     544      t.printStackTrace(pw);
     545      pw.flush();
     546      pw.close();
     547      System.out.println("EXCEPTION:" + t.toString());
     548    }
    514549    exportStream.flush();
    515550    exportStream.close();
  • trunk/www/include/scripts/main.js

    r2939 r2942  
    523523var Dates = new DateClass();
    524524// Functions related to handling date values
     525// Implementation based on code provided by:
     526// ===================================================================
     527// Author: Matt Kruse <matt@mattkruse.com>
     528// WWW: http://www.mattkruse.com/
     529//
     530// NOTICE: You may use this code for any purpose, commercial or
     531// private, without any further permission from the author. You may
     532// remove this notice from your final code if you wish, however it is
     533// appreciated by the author if at least my web site address is kept.
     534//
     535// You may *NOT* re-distribute this code in any way except through its
     536// use. That means, you can include it in your product, or your web
     537// site, or any other form where the code is actually being used. You
     538// may not put the plain javascript up on your site for download or
     539// include it in your javascript libraries for download.
     540// If you wish to share this code with others, please just point them
     541// to the URL instead.
     542// Please DO NOT link directly to my .js files from your site. Copy
     543// the files to your server and use them there. Thank you.
     544// ===================================================================
     545// HISTORY
     546// ------------------------------------------------------------------
     547// May 17, 2003: Fixed bug in parseDate() for dates <1970
     548// March 11, 2003: Added parseDate() function
     549// March 11, 2003: Added "NNN" formatting option. Doesn't match up
     550//                 perfectly with SimpleDateFormat formats, but
     551//                 backwards-compatability was required.
     552
     553// ------------------------------------------------------------------
     554// These functions use the same 'format' strings as the
     555// java.text.SimpleDateFormat class, with minor exceptions.
     556// The format string consists of the following abbreviations:
     557//
     558// Field        | Full Form          | Short Form
     559// -------------+--------------------+-----------------------
     560// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
     561// Month        | MMMM(name or abbr.)| MM (2 digits), M (1 or 2 digits)
     562//              | NNN (abbr.)        |
     563// Day of Month | dd (2 digits)      | d (1 or 2 digits)
     564// Day of Week  | EE (name)          | E (abbr)
     565// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
     566// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
     567// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
     568// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
     569// Minute       | mm (2 digits)      | m (1 or 2 digits)
     570// Second       | ss (2 digits)      | s (1 or 2 digits)
     571// AM/PM        | a                  |
     572//
     573// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
     574// Examples:
     575//  "MMM d, y" matches: January 01, 2000
     576//                      Dec 1, 1900
     577//                      Nov 20, 00
     578//  "M/d/yy"   matches: 01/20/00
     579//                      9/2/00
     580//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
     581// ------------------------------------------------------------------
    525582function DateClass()
    526583{
    527 
    528   // formats a date as a string: yyyy-mm-dd
    529   this.formatDate = function(date)
    530   {
    531     var year = this.getFourDigitYear(date.getFullYear());
    532     var month = date.getMonth()+1;
    533     month = month < 10 ? '0'+month : month;
    534     var day = date.getDate();
    535     day = day < 10 ? '0'+day : day;
    536     return year+'-'+month+'-'+day;
     584  this.MONTH_NAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
     585  this.DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
     586
     587  // convert a date to a string:
     588  // default format is yyyy-MM-dd
     589  this.formatDate = function(date, format)
     590  {
     591    if (!format) format = "yyyy-MM-dd";
     592    var result="";
     593    var i_format=0;
     594    var c="";
     595    var token="";
     596    var y=date.getYear()+"";
     597    var M=date.getMonth()+1;
     598    var d=date.getDate();
     599    var E=date.getDay();
     600    var H=date.getHours();
     601    var m=date.getMinutes();
     602    var s=date.getSeconds();
     603    var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
     604   
     605    // Convert real date parts into formatted versions
     606    var value=new Object();
     607    if (y.length < 4)
     608    {
     609      y=""+(y-0+1900);
     610    }
     611    value["y"]=""+y;
     612    value["yyyy"]=y;
     613    value["yy"]=y.substring(2,4);
     614    value["M"]=M;
     615    value["MM"]=LZ(M);
     616    value["MMM"]=this.MONTH_NAMES[M+11];
     617    value["MMMM"]=this.MONTH_NAMES[M-1];
     618    value["NNN"]=this.MONTH_NAMES[M+11];
     619    value["d"]=d;
     620    value["dd"]=LZ(d);
     621    value["E"]=this.DAY_NAMES[E+7];
     622    value["EE"]=this.DAY_NAMES[E];
     623    value["H"]=H;
     624    value["HH"]=LZ(H);
     625    if (H==0)
     626    {
     627      value["h"]=12;
     628    }
     629    else if (H>12)
     630    {
     631      value["h"]=H-12;
     632    }
     633    else
     634    {
     635      value["h"]=H;
     636    }
     637    value["hh"]=LZ(value["h"]);
     638    if (H>11)
     639    {
     640      value["K"]=H-12;
     641    }
     642    else
     643    {
     644      value["K"]=H;
     645    }
     646    value["k"]=H+1;
     647    value["KK"]=LZ(value["K"]);
     648    value["kk"]=LZ(value["k"]);
     649    if (H > 11)
     650    {
     651      value["a"]="PM";
     652    }
     653    else
     654    {
     655      value["a"]="AM";
     656    }
     657    value["m"]=m;
     658    value["mm"]=LZ(m);
     659    value["s"]=s;
     660    value["ss"]=LZ(s);
     661    while (i_format < format.length)
     662    {
     663      c=format.charAt(i_format);
     664      token="";
     665      while ((format.charAt(i_format)==c) && (i_format < format.length))
     666      {
     667        token += format.charAt(i_format++);
     668      }
     669      if (value[token] != null)
     670      {
     671        result=result + value[token];
     672      }
     673      else
     674      {
     675        result=result + token;
     676      }
     677    }
     678    return result;
    537679  }
    538680
     
    593735  }
    594736 
    595   // checks if the supplied string is a date in the format: yyyy-mm-dd
    596   this.isDate = function(date)
    597   {
    598     if (date.search(/^\d{4}\-\d{2}\-\d{2}$/) == -1) return false;
    599     var parts = date.split('-');
    600     var year = Number(parts[0]);
    601     var month = Number(parts[1]);
    602     var day = Number(parts[2]);
    603     return (month >= 1 && month <= 12 && day >= 1 && day <= this.daysInMonth(year, month));
    604   }
    605  
    606   /*
    607     Parses a string expected to hold a date in the format: yyyy-mm-dd
    608     Returns null if the string is not a valid date.
    609   */
    610   this.parseString = function(date)
    611   {
    612     if (date.search(/^\d{4}\-\d{2}\-\d{2}$/) == -1) return null;
    613     var parts = date.split('-');
    614     var year = Number(parts[0]);
    615     var month = Number(parts[1]);
    616     var day = Number(parts[2]);
    617     var result = new Date();
    618     result.setFullYear(year, month-1, day);
    619     return result;
    620     return new Date(year, month-1, day);
    621   }
    622  
     737  // ------------------------------------------------------------------
     738  // isDate ( date_string, format_string )
     739  // Returns true if date string matches format of format string and
     740  // is a valid date. Else returns false.
     741  // It is recommended that you trim whitespace around the value before
     742  // passing it to this function, as whitespace is NOT ignored!
     743  // ------------------------------------------------------------------
     744  this.isDate = function(val, format)
     745  {
     746    return this.parseString(val, format) != null;
     747  }
     748 
     749  // ------------------------------------------------------------------
     750  // parseString( date_string , format_string )
     751  //
     752  // This function takes a date string and a format string. It matches
     753  // If the date string matches the format string, it returns the
     754  // the date object. If it does not match, it returns null.
     755  // ------------------------------------------------------------------
     756  this.parseString = function(val, format)
     757  {
     758    if (!format) format = 'yyyy-MM-dd';
     759    var i_val=0;
     760    var i_format=0;
     761    var c="";
     762    var token="";
     763    var token2="";
     764    var x,y;
     765    var now=new Date();
     766    var year=now.getYear();
     767    var month=now.getMonth()+1;
     768    var date=1;
     769    var hh=now.getHours();
     770    var mm=now.getMinutes();
     771    var ss=now.getSeconds();
     772    var ampm="";
     773   
     774    while (i_format < format.length)
     775    {
     776      // Get next token from format string
     777      c=format.charAt(i_format);
     778      token="";
     779      while ((format.charAt(i_format)==c) && (i_format < format.length))
     780      {
     781        token += format.charAt(i_format++);
     782      }
     783      // Extract contents of value based on format token
     784      if (token=="yyyy" || token=="yy" || token=="y")
     785      {
     786        if (token=="yyyy") { x=4;y=4; }
     787        if (token=="yy")   { x=2;y=2; }
     788        if (token=="y")    { x=2;y=4; }
     789        year=_getInt(val,i_val,x,y);
     790        if (year==null) { return null; }
     791        i_val += year.length;
     792        if (year.length==2)
     793        {
     794          if (year > 70)
     795          {
     796            year=1900+(year-0);
     797          }
     798          else
     799          {
     800            year=2000+(year-0);
     801          }
     802        }
     803      }
     804      else if (token=='MMMM' || token=="MMM" || token=="NNN")
     805      {
     806        month=0;
     807        for (var i=0; i<this.MONTH_NAMES.length; i++)
     808        {
     809          var month_name=this.MONTH_NAMES[i];
     810          if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase())
     811          {
     812            month=i+1;
     813            if (month>12) { month -= 12; }
     814            i_val += month_name.length;
     815            break;
     816          }
     817        }
     818        if ((month < 1)||(month>12)) { return null; }
     819      }
     820      else if (token=="EE"||token=="E")
     821      {
     822        for (var i=0; i<this.DAY_NAMES.length; i++)
     823        {
     824          var day_name=this.DAY_NAMES[i];
     825          if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase())
     826          {
     827            i_val += day_name.length;
     828            break;
     829          }
     830        }
     831      }
     832      else if (token=="MM"||token=="M")
     833      {
     834        month=_getInt(val,i_val,token.length,2);
     835        if(month==null||(month<1)||(month>12)){return null;}
     836        i_val+=month.length;
     837      }
     838      else if (token=="dd"||token=="d")
     839      {
     840        date=_getInt(val,i_val,token.length,2);
     841        if(date==null||(date<1)||(date>31)){return null;}
     842        i_val+=date.length;
     843      }
     844      else if (token=="hh"||token=="h")
     845      {
     846        hh=_getInt(val,i_val,token.length,2);
     847        if(hh==null||(hh<1)||(hh>12)){return null;}
     848        i_val+=hh.length;
     849      }
     850      else if (token=="HH"||token=="H")
     851      {
     852        hh=_getInt(val,i_val,token.length,2);
     853        if(hh==null||(hh<0)||(hh>23)){return null;}
     854        i_val+=hh.length;
     855      }
     856      else if (token=="KK"||token=="K")
     857      {
     858        hh=_getInt(val,i_val,token.length,2);
     859        if(hh==null||(hh<0)||(hh>11)){return null;}
     860        i_val+=hh.length;
     861      }
     862      else if (token=="kk"||token=="k")
     863      {
     864        hh=_getInt(val,i_val,token.length,2);
     865        if(hh==null||(hh<1)||(hh>24)){return null;}
     866        i_val+=hh.length;hh--;
     867      }
     868      else if (token=="mm"||token=="m")
     869      {
     870        mm=_getInt(val,i_val,token.length,2);
     871        if(mm==null||(mm<0)||(mm>59)){return null;}
     872        i_val+=mm.length;
     873      }
     874      else if (token=="ss"||token=="s")
     875      {
     876        ss=_getInt(val,i_val,token.length,2);
     877        if(ss==null||(ss<0)||(ss>59)){return null;}
     878        i_val+=ss.length;
     879      }
     880      else if (token=="a")
     881      {
     882        if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
     883        else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
     884        else {return null;}
     885        i_val+=2;
     886      }
     887      else
     888      {
     889        if (val.substring(i_val,i_val+token.length)!=token) {return null;}
     890        else {i_val+=token.length;}
     891      }
     892    }
     893   
     894    // If there are any trailing characters left in the value, it doesn't match
     895    if (i_val != val.length) { return null; }
     896   
     897    // Is date valid for month?
     898    if (month==2)
     899    {
     900      // Check for leap year
     901      if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) )
     902      { // leap year
     903        if (date > 29){ return null; }
     904      }
     905      else
     906      {
     907        if (date > 28) { return null; }
     908      }
     909    }
     910    if ((month==4)||(month==6)||(month==9)||(month==11))
     911    {
     912      if (date > 30) { return null; }
     913    }
     914   
     915    // Correct hours value
     916    if (hh<12 && ampm=="PM")
     917    {
     918      hh=hh-0+12;
     919    }
     920    else if (hh>11 && ampm=="AM")
     921    {
     922      hh-=12;
     923    }
     924    return new Date(year,month-1,date,hh,mm,ss);
     925  }
     926
     927  function _isInteger(val) {
     928    var digits="1234567890";
     929    for (var i=0; i < val.length; i++) {
     930      if (digits.indexOf(val.charAt(i))==-1) { return false; }
     931      }
     932    return true;
     933    }
     934  function _getInt(str,i,minlength,maxlength) {
     935    for (var x=maxlength; x>=minlength; x--) {
     936      var token=str.substring(i,i+x);
     937      if (token.length < minlength) { return null; }
     938      if (_isInteger(token)) { return token; }
     939      }
     940    return null;
     941    }
     942  function LZ(x) {return(x<0||x>9?"":"0")+x}
     943
    623944  /*
    624945    Calculate the number of days in the specified month
     
    677998      of by setting the form field
    678999  */
    679   this.selectDate = function(title, form, input, callback)
    680   {
    681     var url = getRoot()+'common/calendar.jsp?title='+escape(title)+'&form='+form+'&input='+input;
     1000  this.selectDate = function(title, form, input, callback, format)
     1001  {
     1002    var url = getRoot()+'common/calendar.jsp?title='+escape(title)+'&form='+form+'&input='+input+'&format='+escape(format);
    6821003    url += '&ID='+Main.getIdFromLocation();
    6831004    if (callback) url += '&callback='+callback;
  • trunk/www/info/news.jsp

    r2753 r2942  
    4040  import="net.sf.basedb.clients.web.util.HTML"
    4141  import="net.sf.basedb.util.Values"
     42  import="net.sf.basedb.util.formatter.Formatter"
     43  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     44  import="java.util.Date"
    4245%>
    4346<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    5053try
    5154{
     55  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    5256  %>
    5357  <base:page type="default" title="">
     
    7175        %>
    7276        <div class="item">
    73           <span class="date"><%=Values.formatDate(n.getNewsDate())%></span>
     77          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
    7478          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
    7579          <span class="text"><%=Values.getString(n.getDescription())%></span>
  • trunk/www/lims/arraybatches/list_batches.jsp

    r2919 r2942  
    5252  import="net.sf.basedb.clients.web.PermissionUtil"
    5353  import="net.sf.basedb.clients.web.util.HTML"
     54  import="net.sf.basedb.util.formatter.Formatter"
     55  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5456  import="net.sf.basedb.util.Values"
    5557  import="java.util.List"
     
    286288      for (AnnotationType at : annotationTypes)
    287289      {
     290        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    288291        Enumeration<String, String> annotationEnum = null;
    289292        if (at.isEnumeration())
     
    293296          for (Object value : values)
    294297          {
    295             String encoded = HTML.encodeTags(value.toString());
     298            String encoded = formatter.format(value);
    296299            annotationEnum.add(encoded, encoded);
    297300          }
     
    308311          filterable="true"
    309312          exportable="true"
     313          formatter="<%=formatter%>"
    310314        />
    311315        <%
     
    536540                <%
    537541                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    538                 for (AnnotationType at : annotationTypes)
     542                if (as != null)
    539543                {
    540                   %>
    541                   <tbl:cell column="<%="at"+at.getId()%>">
    542                     <%
    543                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    544                     %>
    545                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    546                   </tbl:cell>
    547                   <%
     544                  for (AnnotationType at : annotationTypes)
     545                  {
     546                    if (as.hasAnnotation(at))
     547                    {
     548                      %>
     549                      <tbl:cell column="<%="at"+at.getId()%>"
     550                        ><tbl:cellvalue
     551                        list="<%=as.getAnnotation(at).getValues()%>"
     552                      /></tbl:cell>
     553                      <%
     554                    }
     555                  }
    548556                }
    549557                %>
  • trunk/www/lims/arraydesigns/features/list_features.jsp

    r2753 r2942  
    5858  import="net.sf.basedb.clients.web.util.HTML"
    5959  import="net.sf.basedb.util.Values"
     60  import="net.sf.basedb.util.formatter.Formatter"
     61  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    6062  import="java.util.List"
    6163  import="java.util.Map"
     
    8587  final ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId);
    8688  final boolean isAffy = design.isAffyChip();
     89  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    8790 
    8891  final DataQuery<FeatureData> query = design.getFeatures();
     
    351354        filterable="true"
    352355        exportable="true"
     356        formatter="<%=dateFormatter%>"
    353357      />
    354358      <%
     
    387391            filterable="true"
    388392            exportable="true"
     393            formatter="<%=FormatterFactory.getExtendedPropertyFormatter(sc, ep)%>"
    389394          />
    390395          <%
     
    575580                  <tbl:cell column="reporter.symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell>
    576581                  <tbl:cell column="reporter.description"><%=HTML.encodeTags(reporter.getDescription())%></tbl:cell>
    577                   <tbl:cell column="reporter.lastUpdate"><%=Values.formatDate(reporter.getLastUpdate())%></tbl:cell>
     582                  <tbl:cell column="reporter.lastUpdate" value="<%=reporter.getLastUpdate()%>" />
    578583                  <tbl:cell column="reporter.reporterType"
    579584                    ><base:propertyvalue
     
    590595                    {
    591596                      String name = ep.getName();
    592                       Object value = reporter.getExtended(name);
    593                       String link = ep.getUrl(value);
    594                       if (value instanceof Date) value = Values.formatDate((Date)value);
    595                       value = HTML.encodeTags(value == null ? "" : value.toString());
    596                       if (link != null)
    597                       {
    598                         value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";
    599                       }
    600597                      %>
    601                       <tbl:cell column="<%="reporter."+name%>"><%=value%></tbl:cell>
     598                      <tbl:cell column="<%="reporter."+name%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell>
    602599                      <%
    603600                    }
  • trunk/www/lims/arraydesigns/features/view_feature.jsp

    r2753 r2942  
    5050  import="net.sf.basedb.clients.web.util.HTML"
    5151  import="net.sf.basedb.util.Values"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.Date"
    5355  import="java.util.Map"
     
    7274try
    7375{
     76  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7477  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7578
     
    244247          <tr>
    245248            <td class="prompt">Last update</td>
    246             <td><%=Values.formatDate(reporter.getLastUpdate())%></td>
     249            <td><%=dateFormatter.format(reporter.getLastUpdate())%></td>
    247250          </tr>
    248251          </table>
     
    259262            {
    260263              String name = ep.getName();
    261               Object value = reporter.getExtended(name);
    262               String link = ep.getUrl(value);
    263               if (value instanceof Date) value = Values.formatDate((Date)value);
    264               value = HTML.encodeTags(value == null ? "" : value.toString());
    265               if (link != null)
    266               {
    267                 value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";
    268               }
     264              Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
     265              String value = f.format(reporter.getExtended(name));
    269266              %>
    270267                <%=needsTr ? "<tr valign=\"top\">" : "" %>
  • trunk/www/lims/arraydesigns/list_designs.jsp

    r2919 r2942  
    5656  import="net.sf.basedb.clients.web.util.HTML"
    5757  import="net.sf.basedb.util.Values"
     58  import="net.sf.basedb.util.formatter.Formatter"
     59  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5860  import="java.util.List"
    5961  import="java.util.Map"
     
    282284      for (AnnotationType at : annotationTypes)
    283285      {
     286        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    284287        Enumeration<String, String> annotationEnum = null;
    285288        if (at.isEnumeration())
     
    289292          for (Object value : values)
    290293          {
    291             String encoded = HTML.encodeTags(value.toString());
     294            String encoded = formatter.format(value);
    292295            annotationEnum.add(encoded, encoded);
    293296          }
     
    304307          filterable="true"
    305308          exportable="true"
     309          formatter="<%=formatter%>"
    306310        />
    307311        <%
     
    538542                <%
    539543                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    540                 for (AnnotationType at : annotationTypes)
     544                if (as != null)
    541545                {
    542                   %>
    543                   <tbl:cell column="<%="at"+at.getId()%>">
    544                     <%
    545                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    546                     %>
    547                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    548                   </tbl:cell>
    549                   <%
     546                  for (AnnotationType at : annotationTypes)
     547                  {
     548                    if (as.hasAnnotation(at))
     549                    {
     550                      %>
     551                      <tbl:cell column="<%="at"+at.getId()%>"
     552                        ><tbl:cellvalue
     553                        list="<%=as.getAnnotation(at).getValues()%>"
     554                      /></tbl:cell>
     555                      <%
     556                    }
     557                  }
    550558                }
    551559                %>
  • trunk/www/lims/arrayslides/list_slides.jsp

    r2919 r2942  
    5151  import="net.sf.basedb.clients.web.util.HTML"
    5252  import="net.sf.basedb.util.Values"
     53  import="net.sf.basedb.util.formatter.Formatter"
     54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5355  import="java.util.List"
    5456  import="java.util.Map"
     
    296298      for (AnnotationType at : annotationTypes)
    297299      {
     300        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    298301        Enumeration<String, String> annotationEnum = null;
    299302        if (at.isEnumeration())
     
    303306          for (Object value : values)
    304307          {
    305             String encoded = HTML.encodeTags(value.toString());
     308            String encoded = formatter.format(value);
    306309            annotationEnum.add(encoded, encoded);
    307310          }
     
    318321          filterable="true"
    319322          exportable="true"
     323          formatter="<%=formatter%>"
    320324        />
    321325        <%
     
    526530                <%
    527531                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    528                 for (AnnotationType at : annotationTypes)
     532                if (as != null)
    529533                {
    530                   %>
    531                   <tbl:cell column="<%="at"+at.getId()%>">
    532                     <%
    533                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    534                     %>
    535                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    536                   </tbl:cell>
    537                   <%
     534                  for (AnnotationType at : annotationTypes)
     535                  {
     536                    if (as.hasAnnotation(at))
     537                    {
     538                      %>
     539                      <tbl:cell column="<%="at"+at.getId()%>"
     540                        ><tbl:cellvalue
     541                        list="<%=as.getAnnotation(at).getValues()%>"
     542                      /></tbl:cell>
     543                      <%
     544                    }
     545                  }
    538546                }
    539547                %>
  • trunk/www/lims/plates/events/edit_event.jsp

    r2753 r2942  
    5454  import="net.sf.basedb.clients.web.util.HTML"
    5555  import="net.sf.basedb.util.Values"
     56  import="net.sf.basedb.util.formatter.Formatter"
     57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     58  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    5659  import="java.util.List"
    5760  import="java.util.Set"
     
    7679  Plate plate = null;
    7780  PlateEventType eventType = null;
     81  Date eventDate = null;
    7882
    7983  Protocol currentProtocol = null;
     
    111115      currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name"));
    112116    }
     117   
     118    eventDate = (Date)cc.getPropertyObject("eventDate");
    113119  }
    114120  else
     
    116122    event = PlateEvent.getById(dc, itemId);
    117123    eventType = event.getPlateEventType();
     124    eventDate = event.getEventDate();
    118125    cc.setObject("item", event);
    119126    title = "Edit event  -- " + HTML.encodeTags(eventType.getName());
     
    150157  final String clazz = "class=\"text\"";
    151158  final String requiredClazz = "class=\"text required\"";
     159  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     160  String dateFormat = FormatterSettings.getDateFormat(sc);
     161  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
     162  String htmlDateFormat = HTML.encodeTags(dateFormat);
    152163  %>
    153164
     
    309320          <td>
    310321            <input <%=clazz%> type="text" name="event_date"
    311               value="<%=Values.formatDate(event == null ? Values.getDate(cc.getPropertyValue("eventDate"), new Date()) : event.getEventDate())%>"
    312               size="12" maxlength="10" onkeypress="return Dates.dateOnly(event)">
    313             (yyyy-mm-dd)&nbsp;
     322              value="<%=dateFormatter.format(eventDate == null ? new Date() : eventDate)%>"
     323              size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
     324            &nbsp;
    314325          </td>
    315326          <td>
    316327          <base:button
    317             onclick="Dates.selectDate('Date', 'event', 'event_date')"
     328            onclick="<%="Dates.selectDate('Date', 'event', 'event_date', null, '"+jsDateFormat+"')"%>"
    318329            image="calendar.png"
    319330            title="Calendar&hellip;"
     
    327338      <tr>
    328339        <td class="prompt">Entry date</td>
    329         <td><%=Values.formatDate(event == null ? new Date() : event.getEntryDate())%></td>
     340        <td><%=dateFormatter.format(event == null ? new Date() : event.getEntryDate())%></td>
    330341      </tr>
    331342      <tr>
  • trunk/www/lims/plates/events/index.jsp

    r2811 r2942  
    4242  import="net.sf.basedb.clients.web.WebException"
    4343  import="net.sf.basedb.clients.web.util.HTML"
     44  import="net.sf.basedb.util.formatter.Formatter"
     45  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4446  import="net.sf.basedb.util.Values"
    4547  import="java.util.List"
    4648  import="java.util.Collections"
     49  import="java.util.Date"
    4750%>
    4851<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    140143      message = "Event updated";
    141144    }
     145    Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    142146    event.setComment(Values.getStringOrNull(request.getParameter("comment")));
    143     event.setEventDate(Values.getDate(request.getParameter("event_date")));
     147    event.setEventDate(dateFormatter.parseString(request.getParameter("event_date")));
    144148    int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
    145149    if (protocolId >= 0) // < 0 = denied or unchanged
  • trunk/www/lims/plates/events/list_events.jsp

    r2753 r2942  
    4949  import="net.sf.basedb.clients.web.util.HTML"
    5050  import="net.sf.basedb.util.Values"
     51  import="net.sf.basedb.util.formatter.Formatter"
     52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5153  import="java.util.List"
    5254  import="java.util.Map"
     55  import="java.util.Date"
    5356%>
    5457<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    7780  final boolean deletePermission = createPermission;
    7881
    79   final ItemQuery<PlateEvent> query = Base.getConfiguredQuery(cc, true, plate.getEvents(), mode);
     82  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    8083
    8184  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    8285  try
    8386  {
     87    final ItemQuery<PlateEvent> query = Base.getConfiguredQuery(cc, true, plate.getEvents(), mode);
    8488    events = query.iterate(dc);
    8589  }
     
    98102    {
    99103      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true, '&plate_id=<%=plateId%>');
    100 //      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&plate_id=<%=plateId%>', 'NewEvent', 600, 380);
    101104    }
    102105    function editItem(itemId)
    103106    {
    104107      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
    105 //      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=EditItem&plate_id=<%=plateId%>&item_id='+itemId, 'EditEvent', 600, 380);
    106108    }
    107109    function viewItem(itemId)
    108110    {
    109111      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
    110 //      location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&plate_id=<%=plateId%>&item_id='+itemId;
    111112    }
    112113    function itemOnClick(evt, itemId)
     
    244245        filterable="true"
    245246        exportable="true"
     247        formatter="<%=dateFormatter%>"
    246248      />
    247249      <tbl:columndef
     
    253255        filterable="true"
    254256        exportable="true"
     257        formatter="<%=dateFormatter%>"
    255258      />
    256259      <tbl:columndef
     
    437440                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    438441                  /></tbl:cell>
    439                 <tbl:cell column="entryDate"><%=Values.formatDate(item.getEntryDate())%></tbl:cell>
    440                 <tbl:cell column="eventDate"><%=Values.formatDate(item.getEventDate())%></tbl:cell>
     442                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
     443                <tbl:cell column="eventDate" value="<%=item.getEventDate()%>" />
    441444                <tbl:cell column="comment"><%=HTML.encodeTags(item.getComment())%></tbl:cell>
    442445                <tbl:cell column="user"
  • trunk/www/lims/plates/events/view_event.jsp

    r2753 r2942  
    4444  import="net.sf.basedb.clients.web.util.HTML"
    4545  import="net.sf.basedb.util.Values"
     46  import="net.sf.basedb.util.formatter.Formatter"
     47  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4648  import="java.util.Date"
    4749  import="java.util.Map"
     
    6668{
    6769  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     70  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    6871
    6972  String title = null;
     
    174177      <tr>
    175178        <td class="prompt">Event date</td>
    176         <td><%=Values.formatDate(event.getEventDate())%></td>
     179        <td><%=dateFormatter.format(event.getEventDate())%></td>
    177180      </tr>
    178181      <tr>
    179182        <td class="prompt">Registration date</td>
    180         <td><%=Values.formatDate(event.getEntryDate())%></td>
     183        <td><%=dateFormatter.format(event.getEntryDate())%></td>
    181184      </tr>
    182185      <tr>
  • trunk/www/lims/plates/list_plates.jsp

    r2919 r2942  
    5353  import="net.sf.basedb.clients.web.PermissionUtil"
    5454  import="net.sf.basedb.clients.web.util.HTML"
     55  import="net.sf.basedb.util.formatter.Formatter"
     56  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5557  import="net.sf.basedb.util.Values"
    5658  import="java.util.List"
     
    327329      for (AnnotationType at : annotationTypes)
    328330      {
     331        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    329332        Enumeration<String, String> annotationEnum = null;
    330333        if (at.isEnumeration())
     
    334337          for (Object value : values)
    335338          {
    336             String encoded = HTML.encodeTags(value.toString());
     339            String encoded = formatter.format(value);
    337340            annotationEnum.add(encoded, encoded);
    338341          }
     
    349352          filterable="true"
    350353          exportable="true"
     354          formatter="<%=formatter%>"
    351355        />
    352356        <%
     
    605609                <%
    606610                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    607                 for (AnnotationType at : annotationTypes)
     611                if (as != null)
    608612                {
    609                   %>
    610                   <tbl:cell column="<%="at"+at.getId()%>">
    611                     <%
    612                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    613                     %>
    614                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    615                   </tbl:cell>
    616                   <%
     613                  for (AnnotationType at : annotationTypes)
     614                  {
     615                    if (as.hasAnnotation(at))
     616                    {
     617                      %>
     618                      <tbl:cell column="<%="at"+at.getId()%>"
     619                        ><tbl:cellvalue
     620                        list="<%=as.getAnnotation(at).getValues()%>"
     621                      /></tbl:cell>
     622                      <%
     623                    }
     624                  }
    617625                }
    618626                %>
  • trunk/www/lims/plates/wells/list_wells.jsp

    r2893 r2942  
    5757  import="net.sf.basedb.clients.web.util.HTML"
    5858  import="net.sf.basedb.util.Values"
     59  import="net.sf.basedb.util.formatter.Formatter"
     60  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5961  import="java.util.List"
    6062  import="java.util.Map"
     
    8991  final boolean deletePermission = createPermission;
    9092
    91   final ItemQuery<Well> query = Base.getConfiguredQuery(cc, true, plate.getWells(), mode);
    92   if (!"row".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("row")));
    93   if (!"column".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("column")));
    94 
    9593  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    9694  final ItemQuery<ReporterType> typeQuery = ReporterType.getQuery();
     
    9896  typeQuery.setCacheResult(true);
    9997  List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
     98  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    10099 
    101100  try
    102101  {
     102    final ItemQuery<Well> query = Base.getConfiguredQuery(cc, true, plate.getWells(), mode);
     103    if (!"row".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("row")));
     104    if (!"column".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("column")));
    103105    wells = query.iterate(dc);
    104106  }
     
    276278        filterable="true"
    277279        exportable="true"
     280        formatter="<%=dateFormatter%>"
    278281      />
    279282      <%
     
    312315            filterable="true"
    313316            exportable="true"
     317            formatter="<%=FormatterFactory.getExtendedPropertyFormatter(sc, ep)%>"
    314318          />
    315319          <%
     
    321325      {
    322326        Enumeration<String, String> annotationEnum = null;
     327        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    323328        if (at.isEnumeration())
    324329        {
     
    327332          for (Object value : values)
    328333          {
    329             String encoded = HTML.encodeTags(value.toString());
     334            String encoded = formatter.format(value);
    330335            annotationEnum.add(encoded, encoded);
    331336          }
     
    342347          filterable="true"
    343348          exportable="true"
     349          formatter="<%=formatter%>"
    344350        />
    345351        <%
     
    502508                  <tbl:cell column="reporter.name"><i>- none -</i></tbl:cell>
    503509                  <tbl:cell column="reporter.externalId"><i>- none -</i></tbl:cell>
    504                   <tbl:cell column="reporter.symbol"><i>- none -</i></tbl:cell>
    505                   <tbl:cell column="reporter.description"><i>- none -</i></tbl:cell>
    506                   <tbl:cell column="reporter.lastUpdate"><i>- none -</i></tbl:cell>
    507                   <tbl:cell column="reporter.reporterType"><i>- none -</i></tbl:cell>
    508510                  <%
    509                   if (reporterProperties != null)
    510                   {
    511                     for (ExtendedProperty ep : reporterProperties)
    512                     {
    513                       String name = ep.getName();
    514                       %>
    515                       <tbl:cell column="<%="reporter."+name%>"><i>- none -</i></tbl:cell>
    516                       <%
    517                     }
    518                   }
    519511                }
    520512                else
     
    525517                  <tbl:cell column="reporter.symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell>
    526518                  <tbl:cell column="reporter.description"><%=HTML.encodeTags(reporter.getDescription())%></tbl:cell>
    527                   <tbl:cell column="reporter.lastUpdate"><%=Values.formatDate(reporter.getLastUpdate())%></tbl:cell>
     519                  <tbl:cell column="reporter.lastUpdate" value="<%=reporter.getLastUpdate()%>" />
    528520                  <tbl:cell column="reporter.reporterType"
    529521                    ><base:propertyvalue
     
    540532                    {
    541533                      String name = ep.getName();
    542                       Object value = reporter.getExtended(name);
    543                       String link = ep.getUrl(value);
    544                       if (value instanceof Date) value = Values.formatDate((Date)value);
    545                       value = HTML.encodeTags(value == null ? "" : value.toString());
    546                       if (link != null)
    547                       {
    548                         value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";
    549                       }
    550534                      %>
    551                       <tbl:cell column="<%="reporter."+name%>"><%=value%></tbl:cell>
     535                      <tbl:cell column="<%="reporter."+name%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell>
    552536                      <%
    553537                    }
    554538                  }
    555539                }
    556                 %>
    557                 <%
    558540                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    559                 for (AnnotationType at : annotationTypes)
     541                if (as != null)
    560542                {
    561                   %>
    562                   <tbl:cell column="<%="at"+at.getId()%>">
    563                     <%
    564                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    565                     %>
    566                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Values.getString(values, ", ", true))%>
    567                   </tbl:cell>
    568                   <%
     543                  for (AnnotationType at : annotationTypes)
     544                  {
     545                    if (as.hasAnnotation(at))
     546                    {
     547                      %>
     548                      <tbl:cell column="<%="at"+at.getId()%>"
     549                        ><tbl:cellvalue
     550                        list="<%=as.getAnnotation(at).getValues()%>"
     551                      /></tbl:cell>
     552                      <%
     553                    }
     554                  }
    569555                }
    570556                %>
  • trunk/www/lims/plates/wells/view_well.jsp

    r2753 r2942  
    4646  import="net.sf.basedb.clients.web.util.HTML"
    4747  import="net.sf.basedb.util.Values"
     48  import="net.sf.basedb.util.formatter.Formatter"
     49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4850  import="java.util.Date"
    4951  import="java.util.Map"
     
    6870try
    6971{
     72  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    7073  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    7174
     
    254257          <tr>
    255258            <td class="prompt">Last update</td>
    256             <td><%=Values.formatDate(reporter.getLastUpdate())%></td>
     259            <td><%=dateFormatter.format(reporter.getLastUpdate())%></td>
    257260          </tr>
    258261          </table>
     
    269272              {
    270273                String name = ep.getName();
    271                 Object value = reporter.getExtended(name);
    272                 String link = ep.getUrl(value);
    273                 if (value instanceof Date) value = Values.formatDate((Date)value);
    274                 value = HTML.encodeTags(value == null ? "" : value.toString());
    275                 if (link != null)
    276                 {
    277                   value = "<a href=\"" + link + "\" target=\"_blank\">" + value + "</a>";
    278                 }
     274                Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
     275                String value = f.format(reporter.getExtended(name));
    279276                %>
    280277                  <%=needsTr ? "<tr valign=\"top\">" : "" %>
  • trunk/www/main.jsp

    r2753 r2942  
    4141  import="net.sf.basedb.clients.web.Base"
    4242  import="net.sf.basedb.clients.web.util.HTML"
     43  import="net.sf.basedb.util.formatter.Formatter"
     44  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4345  import="net.sf.basedb.util.Values"
     46  import="java.util.Date"
    4447%>
    4548<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    5154final SessionControl sc = Base.getSessionControl(pageContext, true);
    5255final String ID = sc.getId();
     56final Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
    5357final DbControl dc = sc.newDbControl();
    5458ItemResultList<News> news = null;
     
    214218        %>
    215219        <div class="item">
    216           <span class="date"><%=Values.formatDate(n.getNewsDate())%></span>
     220          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
    217221          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
    218222          <span class="text"><%=Values.getString(n.getDescription())%></span>
  • trunk/www/my_base/index.jsp

    r2753 r2942  
    5252  import="net.sf.basedb.clients.web.Base"
    5353  import="net.sf.basedb.clients.web.util.HTML"
     54  import="net.sf.basedb.util.formatter.Formatter"
     55  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5456  import="net.sf.basedb.util.Values"
    5557  import="java.util.Date"
     
    98100  Quota groupQuota = quotaGroup == null ? null : quotaGroup.getQuota();
    99101 
     102  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
     103  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     104
    100105  ItemQuery<Message> messageQuery = Message.getQuery(user);
    101106  messageQuery.order(Orders.desc(Hql.property("timeSent")));
     
    175180          <a href="javascript:viewMessage(<%=m.getId()%>)"
    176181            title="<%=HTML.encodeTags(fullName)%>">
    177           <span class="date"><%=Values.formatDateTime(m.getTimeSent())%></span>
     182          <span class="date"><%=dateTimeFormatter.format(m.getTimeSent())%></span>
    178183          <span class="headline"><%=HTML.encodeTags(shortName)%></span></a><br>
    179184          <span class="text"><%=HTML.encodeTags(text)%></span>
     
    350355        %>
    351356        <div class="item">
    352           <span class="date"><%=Values.formatDate(n.getNewsDate())%></span>
     357          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
    353358          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
    354359          <span class="text"><%=Values.getString(n.getDescription())%></span>
  • trunk/www/my_base/messages/list_messages.jsp

    r2753 r2942  
    5050  import="net.sf.basedb.clients.web.util.HTML"
    5151  import="net.sf.basedb.util.Values"
     52  import="net.sf.basedb.util.formatter.Formatter"
     53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5254  import="java.util.List"
    5355  import="java.util.Map"
     56  import="java.util.Date"
    5457%>
    5558<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    8588  }
    8689  int numListed = 0;
     90  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    8791  %>
    8892  <base:page title="<%=title==null ? "Messages" : title%>" type="<%=mode.getPageType()%>">
     
    212216        filterable="true"
    213217        exportable="true"
     218        formatter="<%=dateTimeFormatter%>"
    214219      />
    215220      <tbl:columndef
     
    380385                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
    381386                <tbl:cell column="from"><%=HTML.encodeTags(item.getFrom())%></tbl:cell>
    382                 <tbl:cell column="timeSent"><%=Values.formatDateTime(item.getTimeSent())%></tbl:cell>
     387                <tbl:cell column="timeSent" value="<%=item.getTimeSent()%>" />
    383388                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
    384389                <tbl:cell column="job"><base:propertyvalue item="<%=item%>" property="job" enableEditLink="<%=editLink%>" enablePropertyLink="<%=mode.hasPropertyLink()%>"/></tbl:cell>
  • trunk/www/my_base/messages/view_message.jsp

    r2753 r2942  
    4747  import="net.sf.basedb.clients.web.util.HTML"
    4848  import="net.sf.basedb.util.Values"
     49  import="net.sf.basedb.util.formatter.Formatter"
     50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    4951  import="java.util.Date"
    5052  import="java.util.Map"
     
    98100 
    99101  String title = "Message -- " + HTML.encodeTags(message.getName());;
     102  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
     103  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    100104 
    101105  final boolean writePermission = message.hasPermission(Permission.WRITE);
     
    134138      <tr valign="top">
    135139        <td class="prompt">Time sent</td>
    136         <td><%=Values.formatDateTime(message.getTimeSent())%></td>
     140        <td><%=dateTimeFormatter.format(message.getTimeSent())%></td>
    137141      </tr>
    138142      <tr valign="top">
     
    205209        <td class="prompt">Created</td>
    206210        <td>
    207           <%=Values.formatDateTime(job.getCreated())%>
     211          <%=dateTimeFormatter.format(job.getCreated())%>
    208212        </td>
    209213      </tr>
     
    211215        <td class="prompt">Started</td>
    212216        <td>
    213           <%=Values.formatDateTime(job.getStarted())%>
     217          <%=dateTimeFormatter.format(job.getStarted())%>
    214218        </td>
    215219      </tr>
     
    217221        <td class="prompt">Ended</td>
    218222        <td>
    219           <%=Values.formatDateTime(job.getEnded())%>
     223          <%=dateTimeFormatter.format(job.getEnded())%>
    220224        </td>
    221225      </tr>
     
    297301                else if (value instanceof Date)
    298302                {
    299                   sb.append(Values.formatDate((Date)value));
     303                  sb.append(dateFormatter.format((Date)value));
    300304                }
    301305                else
     
    384388                  else if (value instanceof Date)
    385389                  {
    386                     sb.append(Values.formatDate((Date)value));
     390                    sb.append(dateFormatter.format((Date)value));
    387391                  }
    388392                  else
  • trunk/www/my_base/user/preferences.jsp

    r2907 r2942  
    4545  import="net.sf.basedb.clients.web.Base"
    4646  import="net.sf.basedb.clients.web.util.HTML"
     47  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    4748  import="net.sf.basedb.util.Values"
    4849  import="java.util.List"
     
    314315      </td>
    315316    </tr>
     317    <tr>
     318      <td class="prompt">Date format</td>
     319      <td>
     320        <input class="text" type="text" name="date_format"
     321        value="<%=HTML.encodeTags(FormatterSettings.getDateFormat(sc))%>"
     322        size="40">
     323      </td>
     324    </tr>
     325   
     326    <tr>
     327      <td class="prompt">Date-time format</td>
     328      <td>
     329        <input class="text" type="text" name="datetime_format"
     330        value="<%=HTML.encodeTags(FormatterSettings.getDateTimeFormat(sc))%>"
     331        size="40">
     332      </td>
     333    </tr>
     334   
    316335    </table>
    317336    <div align="right">&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
  • trunk/www/my_base/user/submit_user.jsp

    r2907 r2942  
    4040  import="net.sf.basedb.clients.web.WebException"
    4141  import="net.sf.basedb.clients.web.util.HTML"
     42  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
    4243  import="net.sf.basedb.util.Values"
    4344  import="java.util.Arrays"
     
    118119    sc.setUserClientSetting("ratiocolor.max", maxColor);
    119120    cc.setRecent("colors", minColor + "," + midColor + "," + maxColor, maxRecent);
     121    FormatterSettings.setDateFormat(sc, request.getParameter("date_format"));
     122    FormatterSettings.setDateTimeFormat(sc, request.getParameter("datetime_format"));
    120123    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
    121124   
  • trunk/www/plugins/net/sf/basedb/clients/web/plugins/simple_export.jsp

    r2868 r2942  
    413413          </tr>
    414414          </table>
    415           <input type="checkbox" name="parameter:overwrite" value="1">
     415          <input type="checkbox" name="parameter:overwrite" value="true">
    416416            <a href="javascript:Forms.toggleCheckbox(document.forms['export']['parameter:overwrite'])">Overwrite existing file</a><br>
    417417        </td>
  • trunk/www/views/experiments/bioassays/list_bioassays.jsp

    r2892 r2942  
    5858  import="net.sf.basedb.clients.web.util.HTML"
    5959  import="net.sf.basedb.util.Values"
     60  import="net.sf.basedb.util.formatter.Formatter"
     61  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    6062  import="java.util.List"
    6163  import="java.util.LinkedList"
     
    273275      {
    274276        Enumeration<String, String> annotationEnum = null;
     277        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
    275278        if (at.isEnumeration())
    276279        {
     
    279282          for (Object value : values)
    280283          {
    281             String encoded = HTML.encodeTags(value.toString());
     284            String encoded = formatter.format(value);
    282285            annotationEnum.add(encoded, encoded);
    283286          }
     
    294297          filterable="true"
    295298          exportable="true"
     299          formatter="<%=formatter%>"
    296300        />
    297301        <%
     
    464468                <%
    465469                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
    466                 for (AnnotationType at : annotationTypes)
     470                if (as != null)
    467471                {
    468                   %>
    469                   <tbl:cell column="<%="at"+at.getId()%>">
    470                     <%
    471                     List<?> values = as == null || !as.hasAnnotation(at) ? null : as.getAnnotation(at).getValues();
    472                     %>
    473                     <%=values == null || values.size() == 0 ? "" : HTML.encodeTags(Val