001         package com.croftsoft.apps.agoracast.c2p;
002    
003         import java.awt.*;
004         import java.awt.event.*;
005         import java.io.*;
006         import javax.swing.*;
007    
008         import com.croftsoft.core.lang.NullArgumentException;
009         import com.croftsoft.core.util.pubsub.Subscriber;
010    
011         /*********************************************************************
012         *
013         * <p />
014         *
015         * @version
016         *   2002-01-29
017         * @since
018         *   2001-07-31
019         * @author
020         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
021         *********************************************************************/
022    
023         public final class  AgoracastBrowsePanel
024           extends JPanel
025           implements Subscriber
026         //////////////////////////////////////////////////////////////////////
027         //////////////////////////////////////////////////////////////////////
028         {
029    
030         private final AgoracastMediator       agoracastMediator;
031    
032         private final CardLayout              cardLayout;
033    
034         private final AgoracastTablePanel     agoracastTablePanel;
035    
036         private final AgoracastDownloadPanel  agoracastDownloadPanel;
037    
038         private final AgoracastFieldsPanel    agoracastFieldsPanel;
039    
040         private final AgoracastSourcePanel    agoracastSourcePanel;
041    
042         //////////////////////////////////////////////////////////////////////
043         //////////////////////////////////////////////////////////////////////
044    
045         public  AgoracastBrowsePanel ( AgoracastMediator  agoracastMediator )
046         //////////////////////////////////////////////////////////////////////
047         {
048           super ( true ); // isDoubleBuffered
049    
050           NullArgumentException.check (
051             this.agoracastMediator = agoracastMediator );
052    
053           setLayout ( cardLayout = new CardLayout ( ) );
054    
055           AgoracastLib.setColor ( this, agoracastMediator );
056    
057           agoracastTablePanel
058             = new AgoracastTablePanel ( agoracastMediator, this );
059    
060           add ( agoracastTablePanel, "0" );
061    
062           agoracastDownloadPanel
063             = new AgoracastDownloadPanel ( agoracastMediator, this );
064    
065           add ( agoracastDownloadPanel, "1" );
066    
067           agoracastFieldsPanel
068             = new AgoracastFieldsPanel ( agoracastMediator, this );
069    
070           add ( agoracastFieldsPanel, "2" );
071    
072           agoracastSourcePanel
073             = new AgoracastSourcePanel ( agoracastMediator, this );
074    
075           add ( agoracastSourcePanel, "3" );
076         }
077    
078         //////////////////////////////////////////////////////////////////////
079         //////////////////////////////////////////////////////////////////////
080    
081         public synchronized void  download ( )
082         //////////////////////////////////////////////////////////////////////
083         {
084           cardLayout.show ( this, "1" );
085    
086           agoracastDownloadPanel.download ( );
087         }
088    
089         public synchronized void  showFieldsPanel ( String [ ]  columnNames )
090         //////////////////////////////////////////////////////////////////////
091         {
092           cardLayout.show ( this, "2" );
093    
094           agoracastFieldsPanel.setSelectedFieldNames ( columnNames );
095         }
096    
097         public synchronized void  showTable ( )
098         //////////////////////////////////////////////////////////////////////
099         {
100           cardLayout.show ( this, "0" );
101    
102           String [ ]  columnNames
103             = agoracastFieldsPanel.getSelectedFieldNames ( );
104    
105           agoracastTablePanel.updateTable ( columnNames );
106         }
107    
108         public synchronized void  viewSource ( AgoracastData  agoracastData )
109         //////////////////////////////////////////////////////////////////////
110         {
111           cardLayout.show ( this, "3" );
112    
113           agoracastSourcePanel.viewSource ( agoracastData );
114         }
115    
116         //////////////////////////////////////////////////////////////////////
117         //////////////////////////////////////////////////////////////////////
118    
119         public synchronized void  receive ( Object  message )
120         //////////////////////////////////////////////////////////////////////
121         {
122           if ( message == AgoracastFieldsPanel.DONE_BUTTON_EVENT )
123           {
124             showTable ( );
125           }
126         }
127    
128         //////////////////////////////////////////////////////////////////////
129         //////////////////////////////////////////////////////////////////////
130         }