From 9b4647f1ae8c3f41163d0d4053504dab861d0c94 Mon Sep 17 00:00:00 2001 From: Matt Windsor Date: Mon, 7 Mar 2011 13:50:24 +0000 Subject: 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. --- src/uk/org/ury/show/viewer/ChannelPanel.java | 100 +++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/uk/org/ury/show/viewer/ChannelPanel.java (limited to 'src/uk/org/ury/show/viewer/ChannelPanel.java') 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); + } +} -- cgit v1.2.3