aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/show/viewer/ChannelPanel.java
diff options
context:
space:
mode:
authorMatt Windsor <mbw500@student.cs.york.ac.uk>2011-03-07 13:50:24 +0000
committerMatt Windsor <mbw500@student.cs.york.ac.uk>2011-03-07 13:50:24 +0000
commit9b4647f1ae8c3f41163d0d4053504dab861d0c94 (patch)
treeb621e8c0b75a5cadd69f938116b1637f7ad0c94d /src/uk/org/ury/show/viewer/ChannelPanel.java
parentc33f098de8a43a2df778d4d694e0c07bbde59828 (diff)
Emergency impending hard drive failure dump - lots of changes on the frontend, but they're all potentially controversial so I'm not pushing to master yet. Beginnings of show viewer. Application now run through demo menu, which allows for the links between modules to be tested.
Diffstat (limited to 'src/uk/org/ury/show/viewer/ChannelPanel.java')
-rw-r--r--src/uk/org/ury/show/viewer/ChannelPanel.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/uk/org/ury/show/viewer/ChannelPanel.java b/src/uk/org/ury/show/viewer/ChannelPanel.java
new file mode 100644
index 0000000..187aa86
--- /dev/null
+++ b/src/uk/org/ury/show/viewer/ChannelPanel.java
@@ -0,0 +1,100 @@
+/**
+ *
+ */
+package uk.org.ury.show.viewer;
+
+import java.awt.event.KeyEvent;
+import java.net.URL;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.ListModel;
+
+import org.swixml.SwingEngine;
+
+import uk.org.ury.frontend.FrontendError;
+import uk.org.ury.show.ShowChannel;
+
+
+/**
+ * A panel displaying channel informstion.
+ *
+ * @author Matt Windsor.
+ */
+
+public class ChannelPanel extends JPanel
+{
+ private JLabel channelName;
+ private JList itemList;
+ private JButton playButton;
+ private JButton pauseButton;
+ private JButton stopButton;
+
+
+ /**
+ * Construct a new ChannelPanel.
+ *
+ * This constructor reads the channel panel layout from the
+ * XML manifest "channel_panel.xml" in the same directory as
+ * this class file.
+ *
+ * @param number The number of the channel.
+ *
+ * @param channel The channel whose data the ChannelPanel is viewing.
+ */
+
+ public
+ ChannelPanel (int number, ShowChannel channel)
+ {
+ super ();
+
+ // Acquire path.
+
+ URL path = getClass ().getResource ("channel_panel.xml");
+
+ if (path == null)
+ FrontendError.reportFatal ("UI creation failure: XML layout does not exist.", null);
+
+ SwingEngine se = new SwingEngine (this);
+
+
+ // Read the XML.
+
+ try
+ {
+ se.insert (path, this);
+ }
+ catch (Exception e)
+ {
+ FrontendError.reportFatal ("UI creation failure: " + e.getMessage (), null);
+ }
+
+ // Tweak buttons to add function key mnemonics, if function keys are available.
+
+ if (number <= 4)
+ {
+ int base = number * 3;
+
+ playButton.setText ("Play (F" + (base - 2) + ")");
+ playButton.setMnemonic (KeyEvent.VK_F1 + (base - 1));
+ playButton.setDisplayedMnemonicIndex (7);
+
+ pauseButton.setText ("Stop (F" + (base - 1) + ")");
+ pauseButton.setMnemonic (KeyEvent.VK_F2 + (base - 1));
+ pauseButton.setDisplayedMnemonicIndex (7);
+
+ stopButton.setText ("Pause (F" + (base ) + ")");
+ stopButton.setMnemonic (KeyEvent.VK_F3 + (base - 1));
+ stopButton.setDisplayedMnemonicIndex (8);
+ }
+
+ // Test stuff
+ DefaultListModel test = new DefaultListModel ();
+ test.add (0, "Test");
+ itemList.setModel (test);
+ channelName.setText ("Channel " + number);
+ }
+}