示例#1
0
 /**
  * @param config
  * @return <code>true</code> if the object being dragged is a valid target object
  */
 public static boolean draggingFromValidTarget(final TransformationConfig config) {
   final Object object = draggedObject();
   if (!(object instanceof Model)) {
     return false;
   }
   final Model model = (Model) object;
   if (type(model)) {
     return false;
   }
   return config.root(model).equals(config.getTargetModel());
 }
示例#2
0
 public static boolean validSourceAndTarget(
     final Object source, final Object target, final TransformationConfig config) {
   final Model sourceModel = source instanceof Model ? (Model) source : null;
   final Model targetModel = target instanceof Model ? (Model) target : null;
   if (sourceModel != null && Util.type(sourceModel)) {
     return false;
   }
   if (targetModel != null && Util.type(targetModel)) {
     return false;
   }
   if (sourceModel != null && targetModel != null) {
     if (config.getMapping(sourceModel, targetModel) != null) {
       return false;
     }
     if (sourceModel.isCollection() && targetModel.isCollection()) {
       return false;
     }
   }
   return true;
 }
示例#3
0
  public static FieldMapping updateDateFormat(
      final Shell shell,
      final Model srcModel,
      final Model tgtModel,
      final TransformationConfig config) {

    if (srcModel != null && tgtModel != null && config != null) {
      FieldMapping mapping = config.mapField(srcModel, tgtModel);
      if (srcModel.getType().equalsIgnoreCase("java.lang.String")
          && tgtModel.getType().equalsIgnoreCase("java.util.Date")) {
        String dateFormatStr = Util.getDateFormat(shell, mapping, true);
        mapping.setSourceDateFormat(dateFormatStr);
      } else if (tgtModel.getType().equalsIgnoreCase("java.lang.String")
          && srcModel.getType().equalsIgnoreCase("java.util.Date")) {
        String dateFormatStr = Util.getDateFormat(shell, mapping, false);
        mapping.setTargetDateFormat(dateFormatStr);
      }
      return mapping;
    }
    return null;
  }