@Override
 protected Object doGetValue() {
   if (!dateTime.isDisposed()) {
     return dateTime.getSelection();
   }
   return null;
 }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public Map<IPreferenceGroup, Object> eventFired() {
    Map<IPreferenceGroup, Object> preferenceControlMap = new HashMap<IPreferenceGroup, Object>();
    Date toDate = toDateTime.getSelection();
    Date fromDate = fromDateTime.getSelection();

    if (null == oldToDate || oldToDate.getTime() != toDate.getTime()) {
      preferenceControlMap.put(PreferenceId.TimeLine.TO_DATE_ID, toDate);
      oldToDate = new Date(toDate.getTime());
    }
    if (null == oldFromDate || oldFromDate.getTime() != fromDate.getTime()) {
      preferenceControlMap.put(PreferenceId.TimeLine.FROM_DATE_ID, fromDate);
      oldFromDate = new Date(fromDate.getTime());
    }

    return preferenceControlMap;
  }
Ejemplo n.º 3
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#okPressed()
   */
  @Override
  protected void okPressed() {
    try {
      IAccount account =
          (IAccount) ((IStructuredSelection) accountCombo.getSelection()).getFirstElement();
      IOrderType orderType =
          (IOrderType) ((IStructuredSelection) typeCombo.getSelection()).getFirstElement();
      Double limitPrice =
          orderType == IOrderType.Market ? null : priceFormat.parse(price.getText()).doubleValue();

      Order order =
          new Order(
              account,
              orderType,
              (IOrderSide) ((IStructuredSelection) sideCombo.getSelection()).getFirstElement(),
              security,
              numberFormat.parse(quantity.getText()).longValue(),
              limitPrice);

      if (!routeCombo.getSelection().isEmpty()) {
        order.setRoute(
            (IOrderRoute) ((IStructuredSelection) routeCombo.getSelection()).getFirstElement());
      }

      if (!validityCombo.getSelection().isEmpty()) {
        IOrderValidity validity =
            (IOrderValidity)
                ((IStructuredSelection) validityCombo.getSelection()).getFirstElement();
        order.setValidity(validity);
        if (expireDate.getEnabled()) {
          order.setExpire(expireDate.getSelection());
        }
      }

      if (!orderReference.getText().equals("")) {
        order.setReference(orderReference.getText());
      }

      IBroker connector =
          (IBroker) ((IStructuredSelection) brokerCombo.getSelection()).getFirstElement();
      IOrderMonitor tracker = connector.prepareOrder(order);
      tracker.submit();

      super.okPressed();
    } catch (Exception e) {
      Status status =
          new Status(
              IStatus.ERROR, UIActivator.PLUGIN_ID, 0, Messages.OrderDialog_SubmitErrorMessage, e);
      UIActivator.log(status);
      ErrorDialog.openError(getShell(), getShell().getText(), null, status);
    }
  }
 @Override
 protected void doSetValue(Object value) {
   if (value instanceof Date && !dateTime.isDisposed()) {
     Date oldValue;
     Date newValue;
     try {
       updating = true;
       oldValue = dateTime.getSelection();
       newValue = (Date) value;
       dateTime.setSelection(newValue);
       currentSelection = newValue;
       fireValueChange(Diffs.createValueDiff(oldValue, newValue));
     } finally {
       updating = false;
     }
   }
 }
 /**
  * Observe the selection property of the provided CDateTime control.
  *
  * @param dateTime the control to observe
  */
 public CDateTimeObservableValue(CDateTime dateTime) {
   this.dateTime = dateTime;
   currentSelection = dateTime.getSelection();
   this.dateTime.addSelectionListener(selectionListener);
   this.dateTime.addFocusListener(focusListener);
 }