Ejemplo n.º 1
0
  /** @param supportedValidatorTypes use these to construct content of the combo box */
  AddValidatorDialog(
      Set<ArgumentValidatorType> supportedValidatorTypes, ArgumentValidatorMessages avMessages) {
    this.avMessages = avMessages;

    setHeadingText(avMessages.validatorDialogHeading());
    setAutoHide(false);
    setSize("400", "250");
    // Initialize the ComboBox list store with the given Set<..>
    ListStore<ArgumentValidatorType> validatorTypes = new ListStore<>(new AVTLabelKeyProvider());
    validatorTypes.addAll(supportedValidatorTypes);

    // Initialize the ComboBox
    validatorTypeCB = new ComboBox<>(validatorTypes, new AVTLabelKeyProvider());
    validatorTypeCB.setForceSelection(true);
    validatorTypeCB.setAllowBlank(false);
    validatorTypeCB.setTriggerAction(TriggerAction.ALL);

    // Construct all "provided" fields.
    constructDoubleSpinnerFields();
    constructIntegerSpinnerFields();
    charLimitField = new NumberField<>(new NumberPropertyEditor.IntegerPropertyEditor());
    charLimitField.setAllowBlank(false);
    charLimitField.addValidHandler(this);
    charLimitField.addInvalidHandler(this);

    add(BINDER.createAndBindUi(this));

    // Initialize validatorTypeToCardMap
    validatorTypeToCardMap = Maps.newHashMap();
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleAbove, dblAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleBelow, dblBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleRange, dblRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.IntAbove, intAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntBelow, intBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntRange, intRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.Regex, regexValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.CharacterLimit, characterLimitValidatorCon);

    // Set default values.
    ArgumentValidatorType next = supportedValidatorTypes.iterator().next();
    validatorTypeCB.setValue(next, true);
    cardLC.setActiveWidget(validatorTypeToCardMap.get(next));
  }
Ejemplo n.º 2
0
  private void initializeLayerCombo(String width) {
    VectorLayerProperties properties = GWT.create(VectorLayerProperties.class);

    layerStore = new ListStore<VectorLayerInfo>(properties.key());

    layerCombo = new ComboBox<VectorLayerInfo>(layerStore, properties.name());
    layerCombo.setEmptyText((UIMessages.INSTANCE.sbLayerComboEmptyText()));
    layerCombo.setTypeAhead(true);
    layerCombo.setTriggerAction(TriggerAction.ALL);
    layerCombo.setForceSelection(true);
    layerCombo.setEditable(false);
    layerCombo.enableEvents();
    layerCombo.setWidth(width);

    layerCombo.addSelectionHandler(
        new SelectionHandler<VectorLayerInfo>() {
          @Override
          public void onSelection(SelectionEvent<VectorLayerInfo> event) {
            layerCombo.setValue(event.getSelectedItem(), true);
          }
        });

    layerCombo.addValueChangeHandler(
        new ValueChangeHandler<VectorLayerInfo>() {
          @Override
          public void onValueChange(ValueChangeEvent<VectorLayerInfo> event) {
            VectorLayer layer =
                (VectorLayer) layerManagerWidget.getSelectedLayer(LayerManagerWidget.VECTOR_TAB);
            if (layer == null) {
              layer = (VectorLayer) event.getValue().getLayer();
            }
            new SelectFeature(layer).unselectAll(null);
            layerManagerWidget.setSelectedLayer(
                LayerManagerWidget.VECTOR_TAB, layerCombo.getValue().getLayer());
          }
        });
  }