diff options
author | Matt Windsor <mbw500@student.cs.york.ac.uk> | 2011-03-07 13:50:24 +0000 |
---|---|---|
committer | Matt Windsor <mbw500@student.cs.york.ac.uk> | 2011-03-07 13:50:24 +0000 |
commit | 9b4647f1ae8c3f41163d0d4053504dab861d0c94 (patch) | |
tree | b621e8c0b75a5cadd69f938116b1637f7ad0c94d /src/uk/org/ury/show/viewer/ShowViewer.java | |
parent | c33f098de8a43a2df778d4d694e0c07bbde59828 (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/ShowViewer.java')
-rw-r--r-- | src/uk/org/ury/show/viewer/ShowViewer.java | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/src/uk/org/ury/show/viewer/ShowViewer.java b/src/uk/org/ury/show/viewer/ShowViewer.java new file mode 100644 index 0000000..8b3f2db --- /dev/null +++ b/src/uk/org/ury/show/viewer/ShowViewer.java @@ -0,0 +1,161 @@ +package uk.org.ury.show.viewer; + +import java.lang.reflect.InvocationTargetException; + +import javax.swing.SwingUtilities; + +import uk.org.ury.config.ConfigReader; +import uk.org.ury.database.DatabaseDriver; +import uk.org.ury.database.UserClass; +import uk.org.ury.database.exceptions.MissingCredentialsException; +import uk.org.ury.frontend.AbstractFrontendModule; +import uk.org.ury.frontend.FrontendError; +import uk.org.ury.frontend.FrontendFrame; +import uk.org.ury.frontend.FrontendMaster; +import uk.org.ury.frontend.FrontendModule; +import uk.org.ury.frontend.FrontendModulePanel; + +import uk.org.ury.show.ShowChannel; +import uk.org.ury.show.ShowUtils; + + +/** + * Frontend module for viewing show details. + * + * This serves as the base for the show playout and editor classes, + * but can be used stand-alone as an (admittedly rather pointless) + * module. + * + * @author Matt Windsor + * + */ + +public class ShowViewer extends AbstractFrontendModule +{ + /** + * + */ + + private static final long serialVersionUID = -2782366476480563739L; + private DatabaseDriver dd; + private ShowChannel[] channels; + private ShowViewerPanel panel; + private FrontendFrame frame; + private ConfigReader config; + + + /** + * Construct a new ShowViewer as a frontend object. + */ + + public + ShowViewer () + { + try + { + config = new ConfigReader ("res/conf.xml"); + } + catch (MissingCredentialsException e) + { + System.out.println(e); + } + + frame = null; + channels = new ShowChannel[ShowUtils.NUM_CHANNELS]; + } + + + /** + * Initialise the library viewer frontend as an applet. + */ + + public void + init () + { + frame = null; + channels = new ShowChannel[ShowUtils.NUM_CHANNELS]; + panel = new ShowViewerPanel (this, null); + + + try + { + SwingUtilities.invokeAndWait (new Runnable () + { + public void + run () + { + panel.setOpaque (true); + setContentPane (panel); + + runFrontend (null); + } + + }); + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace (); + } + catch (InvocationTargetException e) + { + // TODO Auto-generated catch block + e.printStackTrace (); + } + } + + + /** + * Run the library viewer frontend as an applet. + */ + + public void + start () + { + frame = null; + panel = new ShowViewerPanel (this, null); + + add (panel); + } + + + /** + * Run the library viewer frontend. + */ + + @Override + public FrontendModulePanel + runFrontend (FrontendMaster master) + { + dd = null; + + try + { + dd = new DatabaseDriver (config, UserClass.READ_ONLY); + } + catch (MissingCredentialsException e) + { + // TODO: Privilege de-escalation + FrontendError.reportFatal (e.getMessage (), frame); + } + catch (Exception f) + { + FrontendError.reportFatal (f.getMessage (), frame); + } + + panel = new ShowViewerPanel (this, master); + return panel; + } + + + /** + * @return the channel array. + */ + + public ShowChannel[] + getChannels () + { + // TODO Auto-generated method stub + return channels; + } +} |