// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
// 
//     private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
//         @Override
//         public String quote(String id) {
//             return "\"" + id + "\"";
//         }
//     };
// 
//   public void setIdentifierEscaper(IdentifierEscaper p) {
//       identifierEscaper = p;
//   }
// 
//   /**
//    * Add double quotes around an identifier if required.
//    *
//    * @param s the identifier
//    * @return the quoted identifier
//    */
//   public static String quoteIdentifier(String s) {
//       return identifierEscaper.quote(s);
//   }
// 
//     // XXX need commandBuilder and select?
//     private CommandBuilder commandBuilder;
// 
//     private Select select;
// 
//     private Configuration config;
// 
//     private final ValueRegistry valueRegistry = new ValueRegistry();
// 
//     private final Database database;
// 
//     private final HandlerManager msgbus;
// 
// 
//   // XXX 00 remove one of these constructors
//   public Session(Configuration config2) {
//       this(config2.getDatabase());
//       this.config = config2;
//   }
// 
//   @Deprecated
//   public Session(Database database2) {
//       database = database2;
//       msgbus = new HandlerManager(this);
//   }
// 
//     public Configuration getConfig() {
//         return config;
//     }
// 
//     public CommandBuilder getCommandBuilder() {
//         return commandBuilder;
//     }
// 
//     public void setCommandBuilder(CommandBuilder p) {
//         commandBuilder = p;
//     }
// 
//     public Database getDatabase() {
//         return database;
//     }
// 
// 
//   public HandlerManager getMsgBus() {
//       return msgbus;
//   }
// 
// 
// 
//   public void setSelect(Select p) {
//       select = p;
//   }
// 
//   public Column resolveColumn(String alias, String columnName) {
//       return select.resolveColumn(alias, columnName);
//   }
// 
//   public ObjectArray<TableFilter> getFilters() {
//       return select.getFilters();
//   }
// 
//   public TableFilter getTableFilter(Table t) {
//       for (TableFilter tf : select.getFilters()) {
//           if (tf.getTable().equals(t)) {
//               return tf;
//           }
//       }
//       return null;
//   }
// 
//   public TableFilter createTableFilter(Table t) {
//       TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
//       select.addTableFilter(tf, true); // XXX really is true?
//       return tf;
//   }
// 
//   public TableFilter getOrCreateTableFilter(Table t) {
//       TableFilter tf = getTableFilter(t);
//       if (tf == null) {
//           tf = createTableFilter(t);
//       }
//       return tf;
//   }
// 
//   //public Table getTable(String alias) {
//   //    return select.getTable(alias);
//   //}
// 
//   public Table getRootTable() {
//       // XXX maybe if no table then grab default?
//       // or should select always have one table?
//       // or ui shouldn't offer condition button till table?
//       return select.getFilters().get(0).getTable();
//   }
// 
//     public ValueRegistry getValueRegistry() {
//         return valueRegistry;
//     }
// }


import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.redspr.redquerybuilder.core.client.engine.Session;
import com.redspr.redquerybuilder.core.shared.meta.Column;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest;

                @Override
                public void onSuccess(Response result) {
                    callback.onSuggestionsReady(request, result);
                }
            });
        }

        @Override
        public void requestSuggestions(final Request request,
                final Callback callback) {
            SuggestRequest sr = create(request);

            session.getConfig().fireSuggest(sr, new AsyncCallback<Response>() {
                @Override
                public void onFailure(Throwable caught) {
                    // XXX
                }

                @Override
                public void onSuccess(Response result) {
                    callback.onSuggestionsReady(request, result);
                }
            });
        }
    }

    private final String tableName;
    private final String columnName;
    private final String columnType;
// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
// 
//     private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
//         @Override
//         public String quote(String id) {
//             return "\"" + id + "\"";
//         }
//     };
// 
//   public void setIdentifierEscaper(IdentifierEscaper p) {
//       identifierEscaper = p;
//   }
// 
//   /**
//    * Add double quotes around an identifier if required.
//    *
//    * @param s the identifier
//    * @return the quoted identifier
//    */
//   public static String quoteIdentifier(String s) {
//       return identifierEscaper.quote(s);
//   }
// 
//     // XXX need commandBuilder and select?
//     private CommandBuilder commandBuilder;
// 
//     private Select select;
// 
//     private Configuration config;
// 
//     private final ValueRegistry valueRegistry = new ValueRegistry();
// 
//     private final Database database;
// 
//     private final HandlerManager msgbus;
// 
// 
//   // XXX 00 remove one of these constructors
//   public Session(Configuration config2) {
//       this(config2.getDatabase());
//       this.config = config2;
//   }
// 
//   @Deprecated
//   public Session(Database database2) {
//       database = database2;
//       msgbus = new HandlerManager(this);
//   }
// 
//     public Configuration getConfig() {
//         return config;
//     }
// 
//     public CommandBuilder getCommandBuilder() {
//         return commandBuilder;
//     }
// 
//     public void setCommandBuilder(CommandBuilder p) {
//         commandBuilder = p;
//     }
// 
//     public Database getDatabase() {
//         return database;
//     }
// 
// 
//   public HandlerManager getMsgBus() {
//       return msgbus;
//   }
// 
// 
// 
//   public void setSelect(Select p) {
//       select = p;
//   }
// 
//   public Column resolveColumn(String alias, String columnName) {
//       return select.resolveColumn(alias, columnName);
//   }
// 
//   public ObjectArray<TableFilter> getFilters() {
//       return select.getFilters();
//   }
// 
//   public TableFilter getTableFilter(Table t) {
//       for (TableFilter tf : select.getFilters()) {
//           if (tf.getTable().equals(t)) {
//               return tf;
//           }
//       }
//       return null;
//   }
// 
//   public TableFilter createTableFilter(Table t) {
//       TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
//       select.addTableFilter(tf, true); // XXX really is true?
//       return tf;
//   }
// 
//   public TableFilter getOrCreateTableFilter(Table t) {
//       TableFilter tf = getTableFilter(t);
//       if (tf == null) {
//           tf = createTableFilter(t);
//       }
//       return tf;
//   }
// 
//   //public Table getTable(String alias) {
//   //    return select.getTable(alias);
//   //}
// 
//   public Table getRootTable() {
//       // XXX maybe if no table then grab default?
//       // or should select always have one table?
//       // or ui shouldn't offer condition button till table?
//       return select.getFilters().get(0).getTable();
//   }
// 
//     public ValueRegistry getValueRegistry() {
//         return valueRegistry;
//     }
// }


// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/SuggestEditorWidget.java
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.redspr.redquerybuilder.core.client.engine.Session;
import com.redspr.redquerybuilder.core.shared.meta.Column;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest;


                @Override
                public void onSuccess(Response result) {
                    callback.onSuggestionsReady(request, result);
                }
            });
        }

        @Override
        public void requestSuggestions(final Request request,
                final Callback callback) {
            SuggestRequest sr = create(request);

            session.getConfig().fireSuggest(sr, new AsyncCallback<Response>() {
                @Override
                public void onFailure(Throwable caught) {
                    // XXX
                }

                @Override
                public void onSuccess(Response result) {
                    callback.onSuggestionsReady(request, result);
                }
            });
        }
    }

    private final String tableName;
    private final String columnName;
    private final String columnType;
    private final Session session;