Exemple #1
0
  private void submitSearch() {
    List<ModelData> query = new ArrayList<ModelData>();

    for (Field<?> field : formFields) {
      ModelData md = new BaseModelData();
      MetaField mf = findField(field.getName());

      if (mf == null
          || !enabledFields.containsKey(mf.getName())
          || field.getValue() == null
          || field.getValue().toString().length() == 0
          || !field.isValid()) {
        GWT.log("Will not submit field " + field.getName() + ".", null);
        continue;
      }

      md.set("field", mf);
      md.set("value", field.getValue());

      query.add(md);
    }

    GWT.log("Submitting search with " + query.size() + " query elements.", null);

    AppEvent evt = new AppEvent(ApplicationEvents.SUBMIT_ADVANCED_SEARCH, query);
    evt.setData("asset", combo.getValue().getBean());
    Dispatcher.forwardEvent(evt);
  }
Exemple #2
0
 private MetaField findField(String name) {
   for (MetaField f : currentFields) {
     if (f.getName().equals(name)) {
       return f;
     }
   }
   return null;
 }
Exemple #3
0
 private static void logFieldNotSupported(MetaField field) {
   GWT.log(
       "Skipping field \""
           + field.getName()
           + "\". Fields of type \""
           + field.getType().toString()
           + "\" are not supported in search.",
       null);
 }
Exemple #4
0
  private FieldSet wrapField(
      final Field field, final MetaField metaField, final LayoutContainer container) {
    FieldSet fs = new FieldSet();
    fs.setLayout(new FitLayout());
    fs.setHeading(metaField.getLabel());
    fs.setCheckboxToggle(true);
    fs.addListener(
        Events.Expand,
        new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            enabledFields.put(metaField.getName(), field);
          }
        });
    fs.addListener(
        Events.Collapse,
        new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            enabledFields.remove(metaField.getName());
          }
        });
    fs.add(field);
    fs.setExpanded(false);

    return fs;
  }