Example #1
0
  protected void createMiscellaneousGroup(Composite parent) {
    Group content = new Group(parent, SWT.NONE);
    content.setText(Messages.OrderDialog_MiscLabel);
    content.setLayout(new GridLayout(2, false));
    content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    Label label = new Label(content, SWT.NONE);
    label.setText(Messages.OrderDialog_TimeInForceLabel);
    validityCombo = new ComboViewer(content, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
    validityCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    validityCombo.setContentProvider(new ArrayContentProvider());
    validityCombo.setLabelProvider(new LabelProvider());

    label = new Label(content, SWT.NONE);
    label.setText(Messages.OrderDialog_ExpireLabel);
    expireDate =
        new CDateTime(content, CDT.BORDER | CDT.DATE_SHORT | CDT.DROP_DOWN | CDT.TAB_FIELDS);
    expireDate.setPattern(Util.getDateFormatPattern());
    expireDate.setSelection(new Date());
    expireDate.setEnabled(false);

    label = new Label(content, SWT.NONE);
    label.setText(Messages.OrderDialog_ReferenceLabel);
    orderReference = new Text(content, SWT.BORDER);
    orderReference.setLayoutData(new GridData(convertWidthInCharsToPixels(40), SWT.DEFAULT));
  }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * <p>If live is set on we disable this preference.
  */
 @Override
 public void eventFired(PreferenceEvent preferenceEvent) {
   if (PreferenceId.LIVEMODE.equals(preferenceEvent.getPreferenceId())) {
     Boolean liveOn =
         (Boolean) preferenceEvent.getPreferenceMap().get(PreferenceId.LiveMode.BUTTON_LIVE_ID);
     if (null != liveOn && liveOn.booleanValue()) {
       setEnabled(false);
     } else {
       setEnabled(true);
     }
   } else if (PreferenceId.TIMELINE.equals(preferenceEvent.getPreferenceId())) {
     if (preferenceEvent.getPreferenceMap().containsKey(PreferenceId.TimeLine.FROM_DATE_ID)) {
       fromDateTime.setSelection(
           (Date) preferenceEvent.getPreferenceMap().get(PreferenceId.TimeLine.FROM_DATE_ID));
     }
     if (preferenceEvent.getPreferenceMap().containsKey(PreferenceId.TimeLine.TO_DATE_ID)) {
       toDateTime.setSelection(
           (Date) preferenceEvent.getPreferenceMap().get(PreferenceId.TimeLine.TO_DATE_ID));
     }
   }
 }
 @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;
     }
   }
 }
Example #4
0
  /** {@inheritDoc} */
  @Override
  public Composite createControls(Composite parent, FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.TITLE_BAR);
    section.setText("Time Range");
    section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    mainComposite = toolkit.createComposite(section);
    mainComposite.setLayout(new GridLayout(1, false));
    section.setClient(mainComposite);

    Composite linksComposite = toolkit.createComposite(mainComposite);
    linksComposite.setLayout(new GridLayout(14, false));
    linksComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    toolkit.createLabel(linksComposite, "Last: ");
    createTimeHyperlink(linksComposite, toolkit, "15 minutes", 15 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "1 hour", 60 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "6 hours", 6 * 60 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "12 hours", 12 * 60 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "1 day", 24 * 60 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "7 days", 7 * 24 * 60 * 60 * 1000L);
    toolkit.createLabel(linksComposite, " | ");
    createTimeHyperlink(linksComposite, toolkit, "30 days", 30 * 24 * 60 * 60 * 1000L);

    Composite timeComposite = toolkit.createComposite(mainComposite);
    timeComposite.setLayout(new GridLayout(4, false));
    timeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    Date toDate = new Date();
    Date fromDate = new Date(toDate.getTime() - PreferenceId.TimeLine.TIMELINE_DEFAULT);

    toolkit.createLabel(timeComposite, "From: ");
    fromDateTime = new CDateTime(timeComposite, CDT.BORDER | CDT.DROP_DOWN);
    fromDateTime.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    fromDateTime.setFormat(CDT.DATE_SHORT | CDT.TIME_SHORT);
    fromDateTime.setSelection(fromDate);

    toolkit.createLabel(timeComposite, "To: ");
    toDateTime = new CDateTime(timeComposite, CDT.BORDER | CDT.DROP_DOWN);
    toDateTime.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    toDateTime.setFormat(CDT.DATE_SHORT | CDT.TIME_SHORT);
    toDateTime.setSelection(toDate);

    SelectionListener selectionListener =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            getPreferencePanel().update();
          }
        };
    fromDateTime.addSelectionListener(selectionListener);
    toDateTime.addSelectionListener(selectionListener);

    getPreferencePanel().registerCallback(this);

    return mainComposite;
  }