Beispiel #1
0
  private void prepareForm(MetaAsset ma) {
    GWT.log("Preparing form for " + ma.getName(), null);

    form.removeAll();

    currentFields = ma.getSearchableFields();
    formFields = new ArrayList<Field<?>>();
    enabledFields.clear();

    for (MetaField metaField : currentFields) {
      Field newField = EditorFactory.createSearchField(metaField);
      if (newField == null) {
        logFieldNotSupported(metaField);
        continue;
      }
      newField.addKeyListener(
          new KeyListener() {
            @Override
            public void componentKeyPress(ComponentEvent event) {
              if (event.getKeyCode() == 13) {
                submitSearch();
              }
            }
          });

      formFields.add(newField);

      FieldSet fs = wrapField(newField, metaField, form);
      form.add(fs, new FormData("90%"));
    }

    layout();
  }
Beispiel #2
0
  public SearchFormPanel() {

    ListStore<BeanModel> comboStore = new ListStore<BeanModel>();
    combo = new ComboBox<BeanModel>();
    combo.setStore(comboStore);
    combo.setFieldLabel("Asset type");
    combo.setDisplayField("name");
    combo.setTypeAhead(true);
    combo.setForceSelection(true);
    combo.setTriggerAction(ComboBox.TriggerAction.ALL);
    // combo.setWidth(150);
    combo.addSelectionChangedListener(
        new SelectionChangedListener<BeanModel>() {
          public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
            prepareForm((MetaAsset) combo.getValue().getBean());
          }
        });

    Button btnSearch = new Button("Search");
    btnSearch.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent be) {
            submitSearch();
          }
        });

    form = new FormPanel();
    form.setHeaderVisible(false);
    form.setBodyBorder(false);
    form.setScrollMode(Style.Scroll.AUTOY);
    // form.setWidth(300);

    HBoxLayout layout = new HBoxLayout();
    layout.setHBoxLayoutAlign(HBoxLayout.HBoxLayoutAlign.MIDDLE);
    ContentPanel topPanel = new ContentPanel(layout);
    topPanel.setHeaderVisible(false);
    topPanel.setFrame(true);
    topPanel.setHeight(40);
    topPanel.add(new Text("Asset type: "));
    HBoxLayoutData layoutData = new HBoxLayoutData(0, 2, 0, 2);
    topPanel.add(combo, layoutData);
    topPanel.add(btnSearch);

    setHeading("Advanced search");
    setLayout(new FitLayout());
    setFrame(true);
    setTopComponent(topPanel);
    add(form);

    /*
    addListener(Events.Expand, new Listener<BaseEvent>() {
    	public void handleEvent(BaseEvent be) {
    		initComponents(false);
    	}
    });*/
    initComponents(false);
  }