aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/testrig/DemoMenu.java
blob: bc4636b53eceddbb13793a83ee2452aa2f007ca0 (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
package uk.org.ury.testrig;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import uk.org.ury.frontend.FrontendFrame;
import uk.org.ury.frontend.FrontendModulePanel;


/**
 * Application frontend, for testing early-stage frontend code.
 * 
 * @author  Matt Windsor
 *
 */

public class DemoMenu
{
  private FrontendFrame frame;
  
  /**
   * Main method.
   * 
   * @param args  The command-line arguments to the program.  These 
   *              will be ignored.
   */
  
  public static void
  main (String[] args)
  {
    DemoMenu dm = new DemoMenu ();
    dm.run ();
  }
  
  
  /**
   * 
   */
  
  public void
  loadModule (String module)
  {
    frame.loadModule (module, "testrig.DemoControlPanel");
  }
  
  /**
   * Run the demo menu, creating a user interface.
   */
  
  public void
  run ()
  {
    FrontendModulePanel panel = new FrontendModulePanel (null, frame)
    {
      private static final long serialVersionUID = 1L;
      
      {
        setLayout (new GridLayout (2, 1));
        
        JButton lb = new JButton ("Library Viewer Demo");
        JButton sb = new JButton ("Show Viewer Demo");
        
        lb.addActionListener (new ActionListener ()
        {

          @Override
          public void
          actionPerformed (ActionEvent arg0)
          {
            loadModule ("library.viewer.LibraryViewer");
          }
          
        });
        
        
        sb.addActionListener (new ActionListener ()
        {

          @Override
          public void
          actionPerformed (ActionEvent arg0)
          {
            loadModule ("show.viewer.ShowViewer");
          }
          
        });
        
        
        add (lb);
        add (sb);
      }

      
      /**
       * @return  the name of the module.
       */
      
      @Override
      public String
      getName ()
      {
        return "Demo Menu";
      }
    };
    
    
    frame = new FrontendFrame (panel);
  }
}