예제 #1
0
  /** {@inheritDoc} */
  @Override
  public void buildExportDialog(final ContactDetailsPresenter.ExportActionHandler handler) {

    final Window w = new Window();
    w.setPlain(true);
    w.setModal(true);
    w.setBlinkModal(true);
    w.setLayout(new FitLayout());
    w.setSize(400, 180);
    w.setHeadingHtml(I18N.CONSTANTS.exportData());

    final FormPanel panel = Forms.panel();

    final CheckBox synthesisBox = Forms.checkbox(I18N.CONSTANTS.caracteristics(), Boolean.TRUE);
    synthesisBox.setEnabled(false);
    final CheckBox allRelationsBox = Forms.checkbox(I18N.CONSTANTS.allRelations());
    final CheckBox frameworkRelationsBox = Forms.checkbox(I18N.CONSTANTS.frameworkRelations());
    final CheckBox relationsByElementBox = Forms.checkbox(I18N.CONSTANTS.relationsByElement());

    final CheckBoxGroup options =
        Forms.checkBoxGroup(
            I18N.CONSTANTS.exportOptions(),
            com.extjs.gxt.ui.client.Style.Orientation.VERTICAL,
            synthesisBox,
            allRelationsBox,
            frameworkRelationsBox,
            relationsByElementBox);

    panel.add(options);

    final Button export = Forms.button(I18N.CONSTANTS.export());
    panel.getButtonBar().add(export);
    export.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(final ButtonEvent ce) {
            if (handler != null) {
              handler.onExportContact(
                  synthesisBox.getValue(),
                  allRelationsBox.getValue(),
                  frameworkRelationsBox.getValue(),
                  relationsByElementBox.getValue());
            }
            w.hide();
          }
        });

    w.add(panel);
    w.show();
  }
예제 #2
0
  @Override
  public Widget asWidget() {

    // show window
    window.setSize(400, 310);
    window.setPlain(true);
    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.setHeading(AppController.Lang.AddNew(AppController.Lang.RunValue().toLowerCase()));
    window.setLayout(new FitLayout());

    // form
    final FormData formData = new FormData("-20");
    FormPanel simple = new FormPanel();
    simple.setHeaderVisible(false);
    simple.setFrame(true);
    simple.setAutoWidth(true);
    simple.setLabelWidth(100);
    // run
    cbName.setDisplayField("n");
    cbName.setFieldLabel(AppController.Lang.Run());
    cbName.setStore(storeName);
    cbName.setEnabled(false);
    cbName.setMinLength(Constants.LIMIT_NAME_MIN);
    cbName.setMaxLength(Constants.LIMIT_NAME_MAX);
    cbName.setAllowBlank(false);
    cbName.setTriggerAction(TriggerAction.ALL);
    simple.add(cbName, formData);
    // date
    final DateField tfDate = CommonUtils.getDateField(date);
    simple.add(tfDate, formData);
    // time
    final TimeSelectFieldView tfTime = new TimeSelectFieldView(0, null);
    tfTime.setFieldLabel(AppController.Lang.Time());
    simple.add(tfTime);

    // duration
    final MySpinnerField tfDuration = CommonUtils.getDurationSpinner();
    simple.add(tfDuration, formData);
    // pulse
    final SpinnerField tfPulse = CommonUtils.getPulseSpinner();
    simple.add(tfPulse, formData);
    // pulse max
    final SpinnerField tfPulseMax = CommonUtils.getPulseSpinner();
    tfPulseMax.setFieldLabel(AppController.Lang.MaxPulse());
    simple.add(tfPulseMax, formData);
    // calories
    final SpinnerField tfCalories = CommonUtils.getCaloriesSpinner();
    simple.add(tfCalories, formData);

    // info
    final TextArea tfInfo = new TextArea();
    tfInfo.setPreventScrollbars(true);
    tfInfo.setFieldLabel(AppController.Lang.Info());
    simple.add(tfInfo, formData);

    // buttons eventhandler
    Button btnAdd = new Button(AppController.Lang.Add());
    btnAdd.setScale(ButtonScale.MEDIUM);
    btnAdd.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @SuppressWarnings("deprecation")
          @Override
          public void componentSelected(ButtonEvent ce) {
            try {
              // return model
              if (handler != null) {

                final int pulse = (int) tfPulse.getValue().doubleValue();
                final int pulseMax = (int) tfPulseMax.getValue().doubleValue();
                final int calories = (int) tfCalories.getValue().doubleValue();
                // date and time
                Date date = tfDate.getValue();
                final double time = CommonUtils.getTimeToSeconds(tfTime.getValue());
                date.setHours((int) (time / 3600));
                date.setMinutes((int) ((time % 3600) / 60));
                date = CommonUtils.trimDateToDatabase(date, false);
                final String info = tfInfo.getValue();
                final long duration = tfDuration.getValue().intValue();

                RunValueModel value = new RunValueModel();
                value.setCalories(calories);
                value.setDate(date);
                value.setDuration(duration);
                value.setInfo(info);
                value.setPulse(pulse);
                value.setPulseMax(pulseMax);

                // get run
                RunModel run = null;
                // if no values
                if (cbName.getValue() == null) {
                  final String str = cbName.getRawValue();
                  run = new RunModel(0L, str);
                }
                // if user typed new value
                else if (!cbName.getRawValue().equals(cbName.getValue().getNameClient())) {
                  final String str = cbName.getRawValue();
                  run = new RunModel(0L, str);
                }
                // value selected from list
                else {
                  run = cbName.getValue();
                }

                handler.newValue(run, value);
              }

            } catch (Exception e) {
              Motiver.showException(e);
            }
          }
        });
    simple.addButton(btnAdd);
    Button btnCancel = new Button(AppController.Lang.Cancel());
    btnCancel.setScale(ButtonScale.MEDIUM);
    // hide window
    btnCancel.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            handler.cancel();
          }
        });
    simple.addButton(btnCancel);
    simple.setButtonAlign(HorizontalAlignment.CENTER);
    FormButtonBinding binding = new FormButtonBinding(simple);
    binding.addButton(btnAdd);
    window.add(simple);

    window.show();

    return this;
  }