aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/org/ury/frontend')
-rw-r--r--src/uk/org/ury/frontend/AbstractFrontendModule.java11
-rw-r--r--src/uk/org/ury/frontend/FrontendApplet.java343
-rw-r--r--src/uk/org/ury/frontend/FrontendControlPanel.java18
-rw-r--r--src/uk/org/ury/frontend/FrontendError.java15
-rw-r--r--src/uk/org/ury/frontend/FrontendFrame.java125
-rw-r--r--src/uk/org/ury/frontend/FrontendMaster.java45
-rw-r--r--src/uk/org/ury/frontend/FrontendModulePanel.java10
-rw-r--r--src/uk/org/ury/frontend/FrontendPanel.java42
-rw-r--r--src/uk/org/ury/frontend/FrontendSubBanner.java5
-rw-r--r--src/uk/org/ury/frontend/exceptions/LoadFailureException.java44
-rw-r--r--src/uk/org/ury/frontend/exceptions/UICreationFailureException.java44
11 files changed, 643 insertions, 59 deletions
diff --git a/src/uk/org/ury/frontend/AbstractFrontendModule.java b/src/uk/org/ury/frontend/AbstractFrontendModule.java
index 99ff9cf..b5b55b6 100644
--- a/src/uk/org/ury/frontend/AbstractFrontendModule.java
+++ b/src/uk/org/ury/frontend/AbstractFrontendModule.java
@@ -1,6 +1,5 @@
package uk.org.ury.frontend;
-import javax.swing.JApplet;
/**
* An abstract implementation of the FrontendModule interface.
@@ -9,7 +8,7 @@ import javax.swing.JApplet;
*
*/
-public abstract class AbstractFrontendModule extends JApplet implements FrontendModule
+public abstract class AbstractFrontendModule implements FrontendModule
{
/**
@@ -17,11 +16,5 @@ public abstract class AbstractFrontendModule extends JApplet implements Frontend
*/
private static final long serialVersionUID = 5309585577127763538L;
-
- /**
- * Initialise the module as an applet.
- */
-
- public abstract void
- init ();
+ /* Space for rent */
}
diff --git a/src/uk/org/ury/frontend/FrontendApplet.java b/src/uk/org/ury/frontend/FrontendApplet.java
new file mode 100644
index 0000000..18f0c7a
--- /dev/null
+++ b/src/uk/org/ury/frontend/FrontendApplet.java
@@ -0,0 +1,343 @@
+/**
+ *
+ */
+package uk.org.ury.frontend;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+import javax.swing.JApplet;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+import uk.org.ury.frontend.exceptions.LoadFailureException;
+import uk.org.ury.testrig.Launcher;
+
+/**
+ * A frame that hosts a FrontendModulePanel, used for serving frontend
+ * panels in a window (application mode).
+ *
+ * @author Matt Windsor
+ *
+ */
+
+public class FrontendApplet extends JApplet implements FrontendMaster, Launcher
+{
+ /**
+ *
+ */
+
+ private static final long serialVersionUID = 740928181256928433L;
+
+ private FrontendModulePanel child;
+ private FrontendControlPanel cpanel;
+
+
+ /**
+ * Main method.
+ *
+ * @param args The command-line arguments to the program. These
+ * will currently be ignored.
+ */
+
+ @Override
+ public void
+ init ()
+ {
+ try
+ {
+ javax.swing.SwingUtilities.invokeAndWait (new Runnable()
+ {
+ public void
+ run ()
+ {
+ try
+ {
+ loadModule (DEFAULT_MODULE_NAME);
+ }
+ catch (LoadFailureException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace ();
+ }
+ setupUI ();
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace ();
+ System.err.println("createGUI didn't successfully complete");
+ }
+ }
+
+
+ /**
+ * Set up the user interface of the frame.
+ */
+
+ @Override
+ public void
+ setupUI ()
+ {
+ try
+ {
+ // Set System L&F
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName ());
+ }
+ catch (UnsupportedLookAndFeelException e)
+ {
+ // handle exception
+ }
+ catch (ClassNotFoundException e)
+ {
+ // handle exception
+ }
+ catch (InstantiationException e)
+ {
+ // handle exception
+ }
+ catch (IllegalAccessException e)
+ {
+ // handle exception
+ }
+
+
+ // Composition
+
+ add (child, BorderLayout.CENTER);
+
+ setPreferredSize (new Dimension (800, 600));
+ setMinimumSize (new Dimension (800, 600));
+
+ setVisible (true);
+ }
+
+
+ /**
+ * Load a module into the frontend frame.
+ *
+ * Loading will fail with a fatal error if the class is not found,
+ * or is not an implementor of FrontendModule.
+ *
+ * @param moduleName The fully qualified class-name of the module,
+ * minus the leading "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
+ */
+
+ @Override
+ public void
+ loadModule (String moduleName)
+ throws LoadFailureException
+ {
+ Class<?> moduleClass = null;
+
+ try
+ {
+ moduleClass = Class.forName ("uk.org.ury." + moduleName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
+ }
+
+
+ if (FrontendModule.class.isAssignableFrom (moduleClass) == false)
+ {
+ throw new LoadFailureException ("Could not load module: Not a FrontendModule");
+ }
+ else
+ {
+ FrontendModulePanel temp = child;
+
+ try
+ {
+ child = ((FrontendModule) moduleClass.newInstance ()).runFrontend (this);
+ }
+ catch (InstantiationException e)
+ {
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
+ }
+
+ if (temp != null)
+ remove (temp);
+
+ getContentPane ().add (child, BorderLayout.CENTER);
+ child.setMaster (this);
+
+ repaint ();
+ }
+ }
+
+
+ /**
+ * Load a module into the frontend frame, additionally installing
+ * a control panel to communicate with the previous module.
+ *
+ * Loading will fail with a fatal error if the class is not found,
+ * or is not an implementor of FrontendModule.
+ *
+ * @param moduleName The fully qualified class-name of the module,
+ * minus the leading "uk.org.ury." domain.
+ *
+ * @param cPanelName The fully qualified class-name of the control
+ * panel to install, minus the leading
+ * "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
+ */
+
+ @Override
+ public void
+ loadModule (String moduleName, String cPanelName)
+ throws LoadFailureException
+ {
+ FrontendModulePanel newParent = child;
+ loadModule (moduleName);
+ FrontendModulePanel newChild = child;
+
+ loadControlPanel (cPanelName, newParent, newChild);
+ }
+
+
+ /**
+ * Load and install a control panel class given the class name.
+ *
+ * @param cPanelName The fully qualified class-name of the control
+ * panel to load, minus the leading
+ * "uk.org.ury." domain.
+ *
+ * @param parent The parent panel in the relationship modelled
+ * by the control panel interface.
+ *
+ * @param child The child panel in the relationship modelled
+ * by the control panel interface.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendControlPanel.
+ */
+
+ private void
+ loadControlPanel (String cPanelName, FrontendModulePanel parent,
+ FrontendModulePanel child)
+ throws LoadFailureException
+ {
+ Class<?> cPanelClass = null;
+
+ try
+ {
+ cPanelClass = Class.forName ("uk.org.ury." + cPanelName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
+ }
+
+
+ if (FrontendControlPanel.class.isAssignableFrom (cPanelClass))
+ {
+ FrontendControlPanel temp = cpanel;
+
+ try
+ {
+ cpanel = ((FrontendControlPanel) cPanelClass.newInstance ());
+ }
+ catch (InstantiationException e)
+ {
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
+ }
+
+ if (temp != null)
+ remove (temp);
+
+ cpanel.setPanels (parent, child);
+ cpanel.setMaster (this);
+ cpanel.setPreviousCPanel (temp);
+
+ add (cpanel, BorderLayout.SOUTH);
+ repaint ();
+ }
+ }
+
+
+ /**
+ * Restore an existing module and control panel into the frontend
+ * frame.
+ *
+ * @param mpanel The module panel to restore.
+ *
+ * @param cpanel The control panel to restore, if any. A null
+ * value signifies a lack of control panel.
+ *
+ * @throws IllegalArgumentException if the mpanel is null.
+ */
+
+ @Override
+ public void
+ restoreModule (FrontendModulePanel mpanel,
+ FrontendControlPanel cpanel)
+ {
+ if (mpanel == null)
+ throw new IllegalArgumentException ("mpanel is null.");
+
+ remove (child);
+ remove (this.cpanel);
+
+ child = mpanel;
+ add (child);
+
+ if (cpanel != null)
+ add (cpanel, BorderLayout.SOUTH);
+
+ this.cpanel = cpanel;
+
+ repaint ();
+ }
+
+
+ /**
+ * Report a fatal error,
+ *
+ * @param message The message, eg the exception message, to report
+ * to the user.
+ */
+
+ @Override
+ public void
+ fatalError (String message)
+ {
+ FrontendError.reportFatal (message, this);
+ }
+
+
+ /**
+ * @return the resource directory.
+ */
+
+ @Override
+ public String
+ getResourceDirectory ()
+ {
+ return getCodeBase () + "res/";
+ }
+} \ No newline at end of file
diff --git a/src/uk/org/ury/frontend/FrontendControlPanel.java b/src/uk/org/ury/frontend/FrontendControlPanel.java
index 5b7f486..b79021a 100644
--- a/src/uk/org/ury/frontend/FrontendControlPanel.java
+++ b/src/uk/org/ury/frontend/FrontendControlPanel.java
@@ -3,6 +3,8 @@
*/
package uk.org.ury.frontend;
+import uk.org.ury.frontend.exceptions.UICreationFailureException;
+
/**
* Abstract class for frontend module control panels.
@@ -38,26 +40,16 @@ public abstract class FrontendControlPanel extends FrontendPanel
* @param xmlPath The path, relative from this source file, to the
* XML file from which this panel will read its
* layout.
+ *
+ * @throws UICreationFailureException if the UI creation fails.
*/
public
FrontendControlPanel (String xmlPath)
+ throws UICreationFailureException
{
super (xmlPath, null);
}
-
-
- /**
- * Set the frontend master to which this panel is bound.
- *
- * @param master The master to set.
- */
-
- public void
- setMaster (FrontendMaster master)
- {
- this.master = master;
- }
/**
diff --git a/src/uk/org/ury/frontend/FrontendError.java b/src/uk/org/ury/frontend/FrontendError.java
index a08b966..4a13c0a 100644
--- a/src/uk/org/ury/frontend/FrontendError.java
+++ b/src/uk/org/ury/frontend/FrontendError.java
@@ -29,8 +29,8 @@ public class FrontendError
/**
* Create an error dialogue to report a fatal error.
*
- * @string message The message, eg the exception message,
- * to report to the user.
+ * @param message The message, eg the exception message,
+ * to report to the user.
*/
public static void
@@ -47,4 +47,15 @@ public class FrontendError
System.exit (-1);
}
+
+
+ public static void
+ reportFatal (String message, FrontendApplet panel)
+ {
+ // TODO: Log
+
+ // TODO: Error dialogue
+
+ System.out.println (message);
+ }
}
diff --git a/src/uk/org/ury/frontend/FrontendFrame.java b/src/uk/org/ury/frontend/FrontendFrame.java
index aabdfbd..39cb89b 100644
--- a/src/uk/org/ury/frontend/FrontendFrame.java
+++ b/src/uk/org/ury/frontend/FrontendFrame.java
@@ -11,6 +11,8 @@ import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
+import uk.org.ury.frontend.exceptions.LoadFailureException;
+
/**
* A frame that hosts a FrontendModulePanel, used for serving frontend
* panels in a window (application mode).
@@ -31,11 +33,39 @@ public class FrontendFrame extends JFrame implements FrontendMaster
private FrontendModulePanel child;
private FrontendControlPanel cpanel;
+
+ /**
+ * Construct a new FrontendFrame given an initial frontend module.
+ *
+ * Loading will fail with a fatal error if the class is not found,
+ * or is not an implementor of FrontendModule.
+ *
+ * @param moduleName The fully qualified class-name of the module,
+ * minus the leading "uk.org.ury." domain.
+ */
+
public
- FrontendFrame (FrontendModulePanel parent)
+ FrontendFrame (String moduleName)
+ {
+ super ("URY newBAPS");
+ try
+ {
+ loadModule (moduleName);
+ }
+ catch (LoadFailureException e)
+ {
+ fatalError (e.getMessage ());
+ }
+ }
+
+
+ /**
+ * Set up the user interface of the frame.
+ */
+
+ public void
+ setupUI ()
{
- super (parent.getName ());
-
try
{
// Set System L&F
@@ -43,7 +73,7 @@ public class FrontendFrame extends JFrame implements FrontendMaster
}
catch (UnsupportedLookAndFeelException e)
{
- // handle exception
+ // handle exception
}
catch (ClassNotFoundException e)
{
@@ -60,21 +90,19 @@ public class FrontendFrame extends JFrame implements FrontendMaster
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
- this.child = parent;
-
Container cp = getContentPane ();
// Banner
-
- banner = new FrontendBanner (parent.getName ());
+ System.out.println (child);
+ banner = new FrontendBanner (child.getName ());
// Composition
cp.add (banner, BorderLayout.NORTH);
- cp.add (parent, BorderLayout.CENTER);
+ cp.add (child, BorderLayout.CENTER);
setPreferredSize (new Dimension (800, 600));
- setMinimumSize (new Dimension (800, 600));
+ setMinimumSize (new Dimension (800, 600));
pack ();
setVisible (true);
@@ -89,11 +117,16 @@ public class FrontendFrame extends JFrame implements FrontendMaster
*
* @param moduleName The fully qualified class-name of the module,
* minus the leading "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
*/
@Override
public void
loadModule (String moduleName)
+ throws LoadFailureException
{
Class<?> moduleClass = null;
@@ -103,11 +136,16 @@ public class FrontendFrame extends JFrame implements FrontendMaster
}
catch (ClassNotFoundException e)
{
- FrontendError.reportFatal ("Could not load module: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
}
- if (FrontendModule.class.isAssignableFrom (moduleClass))
+ if (FrontendModule.class.isAssignableFrom (moduleClass) == false)
+ {
+ throw new LoadFailureException ("Could not load module: Not a FrontendModule");
+ }
+ else
{
FrontendModulePanel temp = child;
@@ -117,17 +155,24 @@ public class FrontendFrame extends JFrame implements FrontendMaster
}
catch (InstantiationException e)
{
- FrontendError.reportFatal ("Could not load module: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
}
catch (IllegalAccessException e)
{
- FrontendError.reportFatal ("Could not load module: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load module: "
+ + e.getMessage ());
}
- remove (temp);
+ if (temp != null)
+ remove (temp);
+
add (child);
+ child.setMaster (this);
+
+ if (banner != null)
+ banner.setTitle (child.getName ());
- banner.setTitle (child.getName ());
pack ();
}
}
@@ -146,11 +191,16 @@ public class FrontendFrame extends JFrame implements FrontendMaster
* @param cPanelName The fully qualified class-name of the control
* panel to install, minus the leading
* "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
*/
@Override
public void
loadModule (String moduleName, String cPanelName)
+ throws LoadFailureException
{
FrontendModulePanel newParent = child;
loadModule (moduleName);
@@ -172,11 +222,16 @@ public class FrontendFrame extends JFrame implements FrontendMaster
*
* @param child The child panel in the relationship modelled
* by the control panel interface.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendControlPanel.
*/
-
+
private void
loadControlPanel (String cPanelName, FrontendModulePanel parent,
FrontendModulePanel child)
+ throws LoadFailureException
{
Class<?> cPanelClass = null;
@@ -186,7 +241,8 @@ public class FrontendFrame extends JFrame implements FrontendMaster
}
catch (ClassNotFoundException e)
{
- FrontendError.reportFatal ("Could not load control panel: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
}
@@ -200,11 +256,13 @@ public class FrontendFrame extends JFrame implements FrontendMaster
}
catch (InstantiationException e)
{
- FrontendError.reportFatal ("Could not load module: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
}
catch (IllegalAccessException e)
{
- FrontendError.reportFatal ("Could not load module: " + e.getMessage (), this);
+ throw new LoadFailureException ("Could not load control panel: "
+ + e.getMessage ());
}
if (temp != null)
@@ -255,4 +313,31 @@ public class FrontendFrame extends JFrame implements FrontendMaster
pack ();
repaint ();
}
+
+
+ /**
+ * Report a fatal error,
+ *
+ * @param message The message, eg the exception message, to report
+ * to the user.
+ */
+
+ @Override
+ public void
+ fatalError (String message)
+ {
+ FrontendError.reportFatal (message, this);
+ }
+
+
+ /**
+ * @return the resource directory.
+ */
+
+ @Override
+ public String
+ getResourceDirectory ()
+ {
+ return "res/";
+ }
}
diff --git a/src/uk/org/ury/frontend/FrontendMaster.java b/src/uk/org/ury/frontend/FrontendMaster.java
index c169d04..0a89e89 100644
--- a/src/uk/org/ury/frontend/FrontendMaster.java
+++ b/src/uk/org/ury/frontend/FrontendMaster.java
@@ -3,6 +3,8 @@
*/
package uk.org.ury.frontend;
+import uk.org.ury.frontend.exceptions.LoadFailureException;
+
/**
* Interface for classes providing the parent unit of a frontend
@@ -24,10 +26,15 @@ public interface FrontendMaster
*
* @param moduleName The fully qualified class-name of the module,
* minus the leading "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
*/
public void
- loadModule (String moduleName);
+ loadModule (String moduleName)
+ throws LoadFailureException;
/**
@@ -40,13 +47,18 @@ public interface FrontendMaster
* @param moduleName The fully qualified class-name of the module,
* minus the leading "uk.org.ury." domain.
*
- * @param cpanelName The fully qualified class-name of the control
+ * @param cPanelName The fully qualified class-name of the control
* panel to install, minus the leading
* "uk.org.ury." domain.
+ *
+ * @throws LoadFailureException if the class is
+ * not found, or is not an implementor of
+ * FrontendModule.
*/
public void
- loadModule (String moduleName, String cPanelName);
+ loadModule (String moduleName, String cPanelName)
+ throws LoadFailureException;
/**
@@ -62,4 +74,31 @@ public interface FrontendMaster
public void
restoreModule (FrontendModulePanel mpanel, FrontendControlPanel cpanel);
+
+
+ /**
+ * Report a fatal error,
+ *
+ * @param message The message, eg the exception message, to report
+ * to the user.
+ */
+
+ public void
+ fatalError (String message);
+
+
+ /**
+ * Set up the frontend master's user interface.
+ */
+
+ public void
+ setupUI ();
+
+
+ /**
+ * @return the resource directory.
+ */
+
+ public String
+ getResourceDirectory ();
}
diff --git a/src/uk/org/ury/frontend/FrontendModulePanel.java b/src/uk/org/ury/frontend/FrontendModulePanel.java
index 148875f..f5009c4 100644
--- a/src/uk/org/ury/frontend/FrontendModulePanel.java
+++ b/src/uk/org/ury/frontend/FrontendModulePanel.java
@@ -3,6 +3,8 @@
*/
package uk.org.ury.frontend;
+import uk.org.ury.frontend.exceptions.UICreationFailureException;
+
/**
* A frontend user interface panel.
@@ -52,11 +54,14 @@ public abstract class FrontendModulePanel extends FrontendPanel
* layout.
*
* @param master The FrontendMaster driving the frontend.
+ *
+ * @throws UICreationFailureException if the UI creation fails.
*/
public
FrontendModulePanel (FrontendModule module, String xmlPath,
FrontendMaster master)
+ throws UICreationFailureException
{
super (xmlPath, master);
this.module = module;
@@ -82,9 +87,4 @@ public abstract class FrontendModulePanel extends FrontendPanel
{
return module;
}
-
-
- /**
- *
- */
}
diff --git a/src/uk/org/ury/frontend/FrontendPanel.java b/src/uk/org/ury/frontend/FrontendPanel.java
index 0ec8003..931f86b 100644
--- a/src/uk/org/ury/frontend/FrontendPanel.java
+++ b/src/uk/org/ury/frontend/FrontendPanel.java
@@ -6,11 +6,18 @@ import javax.swing.JPanel;
import org.swixml.SwingEngine;
+import uk.org.ury.frontend.exceptions.UICreationFailureException;
+
/**
* An extension of JPanel providing common functionality for user
* interface panels in the URY system frontend.
*
+ * Most notably, this includes automated access to XML-based
+ * preparation of the user interface provided by the panel,
+ * using an appropriate constructor call giving the XML file from
+ * which the user interface form should be read.
+ *
* @author Matt Windsor
*
*/
@@ -27,7 +34,9 @@ public class FrontendPanel extends JPanel
/**
* Construct a new, blank FrontendPanel.
*
- * @param master The FrontendMaster driving the frontend.
+ * @param master The FrontendMaster driving the frontend, if any.
+ * For direct instantiations of this class,
+ * providing null here is guaranteed to be safe.
*/
public
@@ -43,17 +52,22 @@ public class FrontendPanel extends JPanel
* Construct a new FrontendPanel from an XML layout.
*
* This is the preferred means of constructing FrontendPanels, and
- * uses SWIXml to construct the panel layout.
+ * uses an XML-based engine to construct the panel layout.
*
* @param xmlPath The path, relative from this source file, to the
* XML file from which this panel will read its
* layout.
*
- * @param master The FrontendMaster driving the frontend.
+ * @param master The FrontendMaster driving the frontend, if any.
+ * For direct instantiations of this class,
+ * providing null here is guaranteed to be safe.
+ *
+ * @throws UICreationFailureException if the UI creation fails.
*/
public
FrontendPanel (String xmlPath, FrontendMaster master)
+ throws UICreationFailureException
{
super ();
@@ -65,8 +79,10 @@ public class FrontendPanel extends JPanel
URL path = getClass ().getResource (xmlPath);
if (path == null)
- FrontendError.reportFatal ("UI creation failure: XML layout "
- + xmlPath + " does not exist.", null);
+ throw new UICreationFailureException ("UI creation failure:"
+ + "XML layout "
+ + xmlPath
+ + " does not exist.");
SwingEngine se = new SwingEngine (this);
@@ -85,7 +101,21 @@ public class FrontendPanel extends JPanel
}
catch (Exception e)
{
- FrontendError.reportFatal ("UI creation failure: " + e.getMessage (), null);
+ throw new UICreationFailureException ("UI creation failure: "
+ + e.getMessage ());
}
}
+
+
+ /**
+ * Set the frontend master.
+ *
+ * @param master The new frontend master to use.
+ */
+
+ public void
+ setMaster (FrontendMaster master)
+ {
+ this.master = master;
+ }
}
diff --git a/src/uk/org/ury/frontend/FrontendSubBanner.java b/src/uk/org/ury/frontend/FrontendSubBanner.java
index da162bb..6942fe1 100644
--- a/src/uk/org/ury/frontend/FrontendSubBanner.java
+++ b/src/uk/org/ury/frontend/FrontendSubBanner.java
@@ -2,7 +2,6 @@ package uk.org.ury.frontend;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
-import javax.swing.JTextArea;
import javax.swing.UIManager;
@@ -15,6 +14,10 @@ import javax.swing.UIManager;
public class FrontendSubBanner extends JLabel
{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7843563245601622086L;
private static final String TITLE_PREFIX = "<html><b>";
private static final String TITLE_SUFFIX = "</b></html>";
diff --git a/src/uk/org/ury/frontend/exceptions/LoadFailureException.java b/src/uk/org/ury/frontend/exceptions/LoadFailureException.java
new file mode 100644
index 0000000..691eaa0
--- /dev/null
+++ b/src/uk/org/ury/frontend/exceptions/LoadFailureException.java
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package uk.org.ury.frontend.exceptions;
+
+
+/**
+ * Exception thrown when the loading of a new frontend module fails.
+ *
+ * @author Matt Windsor
+ */
+
+public class LoadFailureException extends Exception
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7353531873142099828L;
+
+
+/**
+ * Construct a new LoadFailureException with a
+ * default reason.
+ */
+
+ public
+ LoadFailureException ()
+ {
+ super ("Module load failure.");
+ }
+
+
+ /**
+ * Construct a new LoadFailureException.
+ *
+ * @param reason The explanation for the exception.
+ */
+
+ public
+ LoadFailureException (String reason)
+ {
+ super (reason);
+ }
+}
diff --git a/src/uk/org/ury/frontend/exceptions/UICreationFailureException.java b/src/uk/org/ury/frontend/exceptions/UICreationFailureException.java
new file mode 100644
index 0000000..6d51ef3
--- /dev/null
+++ b/src/uk/org/ury/frontend/exceptions/UICreationFailureException.java
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package uk.org.ury.frontend.exceptions;
+
+
+/**
+ * Exception thrown when the creation of a UI element fails.
+ *
+ * @author Matt Windsor
+ */
+
+public class UICreationFailureException extends Exception
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7353531873142099828L;
+
+
+/**
+ * Construct a new UICreationFailureException with a
+ * default reason.
+ */
+
+ public
+ UICreationFailureException ()
+ {
+ super ("UI creation failure.");
+ }
+
+
+ /**
+ * Construct a new UICreationFailureException.
+ *
+ * @param reason The explanation for the exception.
+ */
+
+ public
+ UICreationFailureException (String reason)
+ {
+ super (reason);
+ }
+}