001 package com.sptci.rwt.webui;
002
003 import nextapp.echo2.app.Component;
004 import nextapp.echo2.app.Row;
005
006 import com.sptci.echo2.table.TableNavigation;
007
008 /**
009 * Query executor view component used to interact with the {@link
010 * com.sptci.rwt.QueryExecutor} class.
011 *
012 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
013 * @author Adarsh 2007-08-18
014 * @version $Id: QueryExecutorView.java 4123 2008-05-25 21:49:01Z rakesh $
015 */
016 public class QueryExecutorView extends ExecutorView
017 {
018 /**
019 * Create instance of the pane using the specified controller.
020 *
021 * @param controller The controller to use to interact with the rest of the
022 * application.
023 */
024 public QueryExecutorView( final MainController controller )
025 {
026 super( controller );
027 }
028
029 /**
030 * Create the layout component to use to display the {@link #maxResults}
031 * component and the other controls used to execute the statement.
032 *
033 * @see #createExecute
034 * @see #createMaxResults
035 * @see #createMaxColumnLength
036 * @see #createHistory
037 * @see #createExport
038 * @see #createSave
039 * @return The layout component.
040 */
041 @Override
042 protected Component createControls()
043 {
044 Row row = new Row();
045 row.add( createExecute() );
046 createMaxResults( row );
047 createMaxColumnLength( row );
048 row.add( createExport() );
049 row.add( createSave() );
050 row.add( createHistory() );
051
052 return row;
053 }
054
055 /**
056 * Create a {@link com.sptci.echo2.table.TableNavigation} for the specified
057 * {@link RowTable} if necessary.
058 *
059 * @param table The results table for which the navigation is to be
060 * displayed.
061 */
062 private void createNavigation( final RowTable table )
063 {
064 if ( table.getModel().getRowCount() > TableNavigation.MINIMUM_PAGE_SIZE )
065 {
066 TableNavigation<Row> navigation =
067 new TableNavigation<Row>( table.getModel() );
068 results.add( navigation );
069 }
070 }
071
072 /**
073 * Display the specified table in {@link #results}.
074 *
075 * @see #createNavigation
076 * @param table The results table to display.
077 */
078 public void setResults( final RowTable table )
079 {
080 reset();
081 createNavigation( table );
082 results.add( table );
083 }
084 }