private void initGUI() {
    mainContainer = new BorderLayoutContainer();
    refresButton = new TextButton("", ELearningController.ICONS.refresh());
    removeFromLectureButton =
        new TextButton("Remove form lecture", ELearningController.ICONS.delete());
    ListStore<Lecture> lectureListStore = new ListStore<Lecture>(lectureDataProperties.key());
    lectureComboBox =
        new ComboBox<Lecture>(
            lectureListStore,
            new LabelProvider<Lecture>() {
              public String getLabel(Lecture item) {
                return item.getLectureName();
              }
            });
    ListStore<Professor> professorListStore = new ListStore<Professor>(professorProperties.key());
    professorComboBox =
        new ComboBox<Professor>(
            professorListStore,
            new LabelProvider<Professor>() {
              public String getLabel(Professor item) {
                return item.getUsername();
              }
            });
    userGrid = createGrid();
    ToolBar toolBar = new ToolBar();

    lectureComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    lectureComboBox.setEditable(false);
    lectureComboBox.setAllowBlank(false);
    professorComboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL);
    professorComboBox.setEditable(false);
    professorComboBox.setAllowBlank(false);

    toolBar.setHorizontalSpacing(5);
    toolBar.add(refresButton);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(new Label("Professor: "));
    toolBar.add(professorComboBox);
    toolBar.add(new Label("Lecture: "));
    toolBar.add(lectureComboBox);
    toolBar.add(new SeparatorToolItem());
    toolBar.add(removeFromLectureButton);

    mainContainer.setNorthWidget(toolBar, new BorderLayoutContainer.BorderLayoutData(30));
    mainContainer.setCenterWidget(userGrid);
    setState(ManageEnrolledStudentsController.IManageEnrolledStudentsState.NONE);
  }
  /**
   * Creates combobox used to select molecular viewer.
   *
   * @return viewer selector
   */
  private ComboBox<String> createViewerTypeCombobox() {
    ListStore<String> store =
        new ListStore<String>(
            new ModelKeyProvider<String>() {
              @Override
              public String getKey(String item) {
                return item;
              }
            });

    store.add(AppPropertiesManager.CONSTANTS.viewer_local());
    store.add(AppPropertiesManager.CONSTANTS.viewer_jmol());
    store.add(AppPropertiesManager.CONSTANTS.viewer_pse());

    final ComboBox<String> viewerTypeComboBox =
        new ComboBox<String>(
            store,
            new LabelProvider<String>() {
              @Override
              public String getLabel(String item) {
                return item;
              }
            });

    viewerTypeComboBox.setId("viewercombo");
    viewerTypeComboBox.setTriggerAction(TriggerAction.ALL);
    viewerTypeComboBox.setEditable(false);
    viewerTypeComboBox.setWidth(100);

    viewerTypeComboBox.setToolTipConfig(createViewerTypeComboBoxToolTipConfig());

    String viewerCookie = Cookies.getCookie("crkviewer");
    if (viewerCookie != null) {
      viewerTypeComboBox.setValue(viewerCookie);
    } else {
      viewerTypeComboBox.setValue(AppPropertiesManager.CONSTANTS.viewer_jmol());
    }

    ApplicationContext.setSelectedViewer(viewerTypeComboBox.getValue());

    viewerTypeComboBox.addSelectionHandler(
        new SelectionHandler<String>() {
          @Override
          public void onSelection(SelectionEvent<String> event) {
            Cookies.setCookie("crkviewer", event.getSelectedItem());
            ApplicationContext.setSelectedViewer(event.getSelectedItem());
          }
        });

    return viewerTypeComboBox;
  }
Beispiel #3
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));
  }
  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());
          }
        });
  }