Пример #1
0
 public static String getDateFormat(
     final Shell shell, final MappingOperation<?, ?> mappingOp, final boolean isSource) {
   final DateFormatInputDialog dlg = new DateFormatInputDialog(shell, mappingOp);
   BaseDozerMapping dMapping = (BaseDozerMapping) mappingOp;
   if (dMapping.getSourceDateFormat() != null && isSource) {
     dlg.setFormatString(dMapping.getSourceDateFormat());
   } else if (dMapping.getTargetDateFormat() != null && !isSource) {
     dlg.setFormatString(dMapping.getTargetDateFormat());
   }
   if (dlg.open() != Window.OK) {
     return null;
   }
   return dlg.getFormatString();
 }
Пример #2
0
  public static void updateDateFormat(final Shell shell, final MappingOperation<?, ?> mappingOp) {
    if (mappingOp != null && mappingOp instanceof BaseDozerMapping) {

      // if both sides of the equation are Models, we're good to check this out
      if (!(mappingOp.getSource() instanceof Model && mappingOp.getTarget() instanceof Model)) {
        return;
      }
      Model srcModel = (Model) mappingOp.getSource();
      Model tgtModel = (Model) mappingOp.getTarget();
      BaseDozerMapping dMapping = (BaseDozerMapping) mappingOp;
      if (srcModel.getType().equalsIgnoreCase("java.lang.String")
          && tgtModel.getType().equalsIgnoreCase("java.util.Date")) {
        String dateFormatStr = Util.getDateFormat(shell, mappingOp, true);
        dMapping.setSourceDateFormat(dateFormatStr);
      } else if (tgtModel.getType().equalsIgnoreCase("java.lang.String")
          && srcModel.getType().equalsIgnoreCase("java.util.Date")) {
        String dateFormatStr = Util.getDateFormat(shell, mappingOp, false);
        dMapping.setTargetDateFormat(dateFormatStr);
      }
    }
  }