001    package com.sptci.rwt.webui.model;
002    
003    import nextapp.echo2.app.Component;
004    import nextapp.echo2.app.Grid;
005    
006    import echopointng.GroupBox;
007    
008    import com.sptci.echo2.Configuration;
009    
010    import com.sptci.rwt.IndexMetaData;
011    import com.sptci.rwt.KeyMetaData;
012    
013    /**
014     * A view component used to display the information contained in
015     * {@link com.sptci.rwt.IndexMetaData}.
016     *
017     * <p>&copy; Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
018     * @author Rakesh Vidyadharan 2007-10-07
019     * @version $Id: IndexView.java 4123 2008-05-25 21:49:01Z rakesh $
020     */
021    public class IndexView extends KeyView
022    {
023      /** The meta data object whose details are to be displayed. */
024      private final IndexMetaData metaData;
025    
026      /**
027       * Create a new instance of the view using the specified model object.
028       *
029       * @param metaData The {@link #metaData} model object to use.
030       */
031      public IndexView( final IndexMetaData metaData )
032      {
033        this.metaData = metaData;
034      }
035    
036      /**
037       * Lifecycle method used to initialise component when added to a
038       * container hierarchy.
039       *
040       * @see #createDetails
041       * @see #createColumnDetails
042       */
043      @Override
044      public void init()
045      {
046        removeAll();
047        add( createDetails() );
048        add( createColumnDetails() );
049      }
050    
051      /**
052       * Create the component used to display the details of the index.
053       *
054       * @see #createLabels
055       * @return The component that displays the index information.
056       */
057      protected Component createDetails()
058      {
059        Grid grid = new Grid();
060    
061        createLabels( "name", metaData, grid );
062        createLabels( "unique", metaData, grid );
063        createLabels( "type", metaData, grid );
064        createLabels( "sortSequence", metaData, grid );
065        createLabels( "cardinality", metaData, grid );
066        createLabels( "pages", metaData, grid );
067    
068        GroupBox box = new GroupBox( Configuration.getString( this, "title" ) );
069        box.add( grid );
070        return box;
071      }
072    
073      /**
074       * Method to return the model object for this view.
075       *
076       * @return The meta data object.
077       */
078      @Override
079      protected KeyMetaData getMetaData()
080      {
081        return metaData;
082      }
083    }