aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/show/viewer/ShowViewerPanel.java
blob: ce1b7943556ebf71d3aa759c162a892271603772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
 * 
 */
package uk.org.ury.show.viewer;

import java.awt.GridLayout;
import java.util.List;

import javax.swing.JPanel;

import uk.org.ury.database.exceptions.QueryFailureException;
import uk.org.ury.frontend.FrontendMaster;
import uk.org.ury.frontend.FrontendModulePanel;
import uk.org.ury.frontend.exceptions.LoadFailureException;
import uk.org.ury.frontend.exceptions.UICreationFailureException;
import uk.org.ury.show.ShowChannel;


/**
 * Frontend panel providing access to an underlying show viewer.
 * 
 * The various show user interfaces (show editor, playout etc.) 
 * are derived from this.
 * 
 * @author Matt Windsor, Nathan Lasseter
 */

public class ShowViewerPanel extends FrontendModulePanel
{
  /**
   * 
   */
  private static final long serialVersionUID = -2441616418398056712L;
 
  
  /* Panel widgets exposed by the SwiXML user interface. */
  
  private JPanel channelGroupPanel;
  private JPanel binGroupPanel; 
  
  
  /**
   * Construct a new ShowViewerPanel.
   * 
   * The panel will interface with the given show viewer and is 
   * expected to be placed as a sub-component in the given 
   * FrontendMaster.
   * 
   * @param viewer  The ShowViewer controlling this LibraryViewerPanel.
   * 
   * @param master  The FrontendMaster driving the frontend.
   * 
   * @throws        UICreationFailureException if the UI creation fails.
   */
  
  public
  ShowViewerPanel (ShowViewer viewer, FrontendMaster master)
  throws UICreationFailureException
  {
    super (viewer, "show_viewer_gui.xml", master);
    
    int channelNumber = 1;
    ChannelPanel cp;
    
    for (ShowChannel channel : viewer.getChannels ())
      {
        cp = new ChannelPanel (channelNumber, channel);
        
        channelGroupPanel.add (cp);
        channelNumber++;
      }
    
    channelGroupPanel.setLayout (new GridLayout (1, channelNumber - 1));
    
    
    // TEST
    List<String> binNames = null;
    
    try
      {
        binNames = viewer.getBins ();
      }
    catch (QueryFailureException e)
      {
        master.fatalError (e.getMessage ());
      }
    
    TrackBin tb;
    
    for (String name : binNames)
      {
        tb = new TrackBin (name);
        
        binGroupPanel.add (tb);
      }
    
    binGroupPanel.setLayout (new GridLayout (1, binNames.size ()));
  }
  
  
  /**
   * @return  the name of the panel.
   * 
   * @see     uk.org.ury.frontend.FrontendModulePanel#getName()
   */
  
  @Override
  public String
  getName ()
  {
    return "Show Viewer Demo";
  }
  
  
  /**
   * Initialise the library viewer for the purposes of adding tracks 
   * and/or browsing the library.
   */
  
  public void
  search ()
  {
    try
      {
        master.loadModule ("library.viewer.LibraryViewer",
                           "show.viewer.LibraryControlPanel");
      }
    catch (LoadFailureException e)
      {
        master.fatalError (e.getMessage ());
      }
  }
}