private void handleAsString(String str) {
   if (isBlank(str)) {
     super.setValueInternal(null);
     return;
   }
   try {
     super.setValueInternal(new URL(str));
   } catch (MalformedURLException e) {
     throw illegalValue(str, URL.class, e);
   }
 }
 protected void setValueInternal(Object value) {
   if (null == value) {
     super.setValueInternal(null);
   } else if (value instanceof CharSequence) {
     handleAsString(String.valueOf(value));
   } else if (value instanceof File) {
     handleAsFile((File) value);
   } else if (value instanceof URL) {
     super.setValueInternal(value);
   } else {
     throw illegalValue(value, URL.class);
   }
 }
 protected void setValueInternal(Object value) {
   if (null == value) {
     super.setValueInternal(null);
   } else if (value instanceof CharSequence) {
     handleAsString(String.valueOf(value));
   } else if (value instanceof Date) {
     super.setValueInternal(value);
   } else if (value instanceof Calendar) {
     super.setValueInternal(((Calendar) value).getTime());
   } else if (value instanceof Number) {
     super.setValueInternal(new Date(((Number) value).longValue()));
   } else {
     throw illegalValue(value, Date.class);
   }
 }
 private void handleAsFile(File file) {
   try {
     super.setValueInternal(file.toURI().toURL());
   } catch (MalformedURLException e) {
     throw illegalValue(file, URL.class);
   }
 }
 protected void handleAsString(String str) {
   try {
     super.setValueInternal(isBlank(str) ? null : Long.parseLong(str));
   } catch (NumberFormatException e) {
     throw illegalValue(str, Long.class, e);
   }
 }
  protected void handleAsString(String str) {
    if (isBlank(str)) {
      super.setValueInternal(null);
      return;
    }

    try {
      super.setValueInternal(new Date(Long.parseLong(str)));
      return;
    } catch (NumberFormatException nfe) {
      // ignore, let's try parsing the date in a locale specific format
    }

    try {
      super.setValueInternal(new SimpleDateFormat().parse(str));
    } catch (ParseException e) {
      throw illegalValue(str, Date.class, e);
    }
  }
 protected void setValueInternal(Object value) {
   if (null == value) {
     super.setValueInternal(null);
   } else if (value instanceof CharSequence) {
     handleAsString(String.valueOf(value));
   } else if (value instanceof Number) {
     handleAsNumber((Number) value);
   } else {
     throw illegalValue(value, Long.class);
   }
 }
Exemple #8
0
  @Override
  protected void doBinding() {
    editor.setOrdered(input.isOrdered(propertyPath));
    editor.setUnique(input.isUnique(propertyPath));
    editor.setDirectCreation(input.getDirectCreation(propertyPath));
    ReferenceValueFactory factory = input.getValueFactory(propertyPath);
    if (factory != null) {
      editor.setFactory(input.getValueFactory(propertyPath));
    }

    IStaticContentProvider provider = input.getContentProvider(propertyPath);
    if (provider != null) {
      editor.setContentProvider(provider);
    }

    if (getInputObservableList() instanceof ICommitListener) {
      editor.addCommitListener((ICommitListener) getInputObservableList());
    }

    super.doBinding();
  }
Exemple #9
0
 /**
  * Constructor.
  *
  * @param parent The composite in which the widget will be displayed
  * @param style The style for the widget
  */
 public MultiString(Composite parent, int style) {
   editor = createMultipleStringEditor(parent, style);
   super.setEditor(editor);
 }
 protected void handleAsNumber(Number number) {
   super.setValueInternal(number.longValue());
 }
Exemple #11
0
 @Override
 public void setReadOnly(boolean readOnly) {
   super.setReadOnly(readOnly);
   updateControls();
 }