diff options
Diffstat (limited to 'src/uk/org/ury/frontend')
-rw-r--r-- | src/uk/org/ury/frontend/AbstractFrontendModule.java | 27 | ||||
-rw-r--r-- | src/uk/org/ury/frontend/FrontendError.java | 50 | ||||
-rw-r--r-- | src/uk/org/ury/frontend/FrontendFrame.java | 67 | ||||
-rw-r--r-- | src/uk/org/ury/frontend/FrontendModule.java | 31 | ||||
-rw-r--r-- | src/uk/org/ury/frontend/FrontendPanel.java | 34 | ||||
-rw-r--r-- | src/uk/org/ury/frontend/images/ury.jpg | bin | 0 -> 30139 bytes | |||
-rw-r--r-- | src/uk/org/ury/frontend/images/ury.png | bin | 0 -> 10143 bytes |
7 files changed, 209 insertions, 0 deletions
diff --git a/src/uk/org/ury/frontend/AbstractFrontendModule.java b/src/uk/org/ury/frontend/AbstractFrontendModule.java new file mode 100644 index 0000000..99ff9cf --- /dev/null +++ b/src/uk/org/ury/frontend/AbstractFrontendModule.java @@ -0,0 +1,27 @@ +package uk.org.ury.frontend; + +import javax.swing.JApplet; + +/** + * An abstract implementation of the FrontendModule interface. + * + * @author Matt Windsor + * + */ + +public abstract class AbstractFrontendModule extends JApplet implements FrontendModule +{ + + /** + * + */ + private static final long serialVersionUID = 5309585577127763538L; + + + /** + * Initialise the module as an applet. + */ + + public abstract void + init (); +} diff --git a/src/uk/org/ury/frontend/FrontendError.java b/src/uk/org/ury/frontend/FrontendError.java new file mode 100644 index 0000000..a08b966 --- /dev/null +++ b/src/uk/org/ury/frontend/FrontendError.java @@ -0,0 +1,50 @@ +/** + * + */ +package uk.org.ury.frontend; + +import javax.swing.JOptionPane; + +/** + * Factory for descriptive error dialogues. + * + * @author Matt Windsor + * + */ + +public class FrontendError +{ + private final static String FATAL_TITLE = "Unrecoverable Error"; + + private final static String FATAL_PREFIX = + "An unrecoverable error has occurred, and the program must close " + + "immediately.\n" + + "Any unsaved work may have been permanently lost.\n\n" + + "Please let URY Computing know about this error.\n\n" + + "The error message reported was:\n\t"; + + private final static String FATAL_SUFFIX = ""; + + + /** + * Create an error dialogue to report a fatal error. + * + * @string message The message, eg the exception message, + * to report to the user. + */ + + public static void + reportFatal (String message, FrontendFrame frame) + { + // TODO: Log + + // TODO: Replace with bespoke error dialogue? + + JOptionPane.showMessageDialog (frame, + FATAL_PREFIX + message + FATAL_SUFFIX, + FATAL_TITLE, + JOptionPane.ERROR_MESSAGE); + + System.exit (-1); + } +} diff --git a/src/uk/org/ury/frontend/FrontendFrame.java b/src/uk/org/ury/frontend/FrontendFrame.java new file mode 100644 index 0000000..d27a85a --- /dev/null +++ b/src/uk/org/ury/frontend/FrontendFrame.java @@ -0,0 +1,67 @@ +/** + * + */ +package uk.org.ury.frontend; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Container; +import java.awt.FlowLayout; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +/** + * A frame that hosts a FrontendPanel, used for serving frontend + * panels in a window (application mode). + * + * @author Matt Windsor + * + */ + +public class FrontendFrame extends JFrame +{ + /** + * + */ + + private static final long serialVersionUID = 740928181256928433L; + + private FrontendPanel parent; + + public + FrontendFrame (FrontendPanel parent) + { + super (parent.getName ()); + + setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); + + this.parent = parent; + + Container cp = getContentPane (); + + // Banner + + JPanel banner = new JPanel (); + JLabel bannerLabel = new JLabel ("<html><h1><font color=white>" + + parent.getName () + "</font></h1></html>"); + + bannerLabel.setBorder (BorderFactory.createEmptyBorder (5, 15, 5, 5)); + + banner.setLayout (new FlowLayout (FlowLayout.LEFT)); + banner.setBackground (new Color (0, 0, 0)); + banner.add (new JLabel (new ImageIcon (getClass ().getResource ("images/ury.png")))); + banner.add (bannerLabel); + + // Composition + + cp.add (banner, BorderLayout.NORTH); + cp.add (parent, BorderLayout.CENTER); + + pack (); + setVisible (true); + } +} diff --git a/src/uk/org/ury/frontend/FrontendModule.java b/src/uk/org/ury/frontend/FrontendModule.java new file mode 100644 index 0000000..407b2db --- /dev/null +++ b/src/uk/org/ury/frontend/FrontendModule.java @@ -0,0 +1,31 @@ +/** + * + */ +package uk.org.ury.frontend; + +/** + * Interface for all system modules that are to be reachable from + * the frontend array. + * + * Frontend-exposed modules must: + * + * - be runnable standalone, as either an application or an applet; + * + * - contain their user interface in a subclass of FrontendPanel + * which can be embedded either in a FrontendFrame, a web page + * or another module; + * + * - use the frontend error reporting systems. + * + * An abstract implementation of this interface, + * AbstractFrontendModule, is provided to simplify the creation of + * frontend modules. + * + * @author Matt Windsor + * + */ + +public interface FrontendModule +{ + // Space for rent +} diff --git a/src/uk/org/ury/frontend/FrontendPanel.java b/src/uk/org/ury/frontend/FrontendPanel.java new file mode 100644 index 0000000..e2e8c44 --- /dev/null +++ b/src/uk/org/ury/frontend/FrontendPanel.java @@ -0,0 +1,34 @@ +/** + * + */ +package uk.org.ury.frontend; + +import javax.swing.JPanel; + +/** + * A frontend user interface panel. + * + * All frontend user interfaces should subclass this as their main + * interface space, so that frontend panels can include each other + * and panels can be embedded into application frames or applets. + * + * @author Matt Windsor + * + */ +public abstract class FrontendPanel extends JPanel +{ + /** + * + */ + + private static final long serialVersionUID = 5616222530691425635L; + + public + FrontendPanel () + { + super (); + } + + public abstract String + getName (); +} diff --git a/src/uk/org/ury/frontend/images/ury.jpg b/src/uk/org/ury/frontend/images/ury.jpg Binary files differnew file mode 100644 index 0000000..96d2740 --- /dev/null +++ b/src/uk/org/ury/frontend/images/ury.jpg diff --git a/src/uk/org/ury/frontend/images/ury.png b/src/uk/org/ury/frontend/images/ury.png Binary files differnew file mode 100644 index 0000000..f71a461 --- /dev/null +++ b/src/uk/org/ury/frontend/images/ury.png |