/**
   * 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;
  }
示例#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());
          }
        });
  }