aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/frontend/FrontendPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/org/ury/frontend/FrontendPanel.java')
-rw-r--r--src/uk/org/ury/frontend/FrontendPanel.java84
1 files changed, 71 insertions, 13 deletions
diff --git a/src/uk/org/ury/frontend/FrontendPanel.java b/src/uk/org/ury/frontend/FrontendPanel.java
index 6012f22..1617ab0 100644
--- a/src/uk/org/ury/frontend/FrontendPanel.java
+++ b/src/uk/org/ury/frontend/FrontendPanel.java
@@ -1,32 +1,90 @@
-/**
- *
- */
package uk.org.ury.frontend;
+import java.net.URL;
+
import javax.swing.JPanel;
+import org.swixml.SwingEngine;
+
+
/**
- * A frontend user interface panel.
+ * An extension of JPanel providing common functionality for user
+ * interface panels in the URY system frontend.
*
- * 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
+ * @author Matt Windsor
*
*/
-public abstract class FrontendPanel extends JPanel
+public class FrontendPanel extends JPanel
{
/**
*
*/
-
- private static final long serialVersionUID = 5616222530691425635L;
+ private static final long serialVersionUID = -4481079599056565279L;
+ protected FrontendMaster master;
+
+ /**
+ * Construct a new, blank FrontendPanel.
+ *
+ * @param master The FrontendMaster driving the frontend.
+ */
+
public
- FrontendPanel ()
+ FrontendPanel (FrontendMaster master)
{
super ();
+
+ this.master = master;
+ }
+
+
+ /**
+ * Construct a new FrontendPanel from an XML layout.
+ *
+ * This is the preferred means of constructing FrontendPanels, and
+ * uses SWIXml 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.
+ */
+
+ public
+ FrontendPanel (String xmlPath, FrontendMaster master)
+ {
+ super ();
+
+ this.master = master;
+
+
+ // Acquire path.
+
+ URL path = getClass ().getResource (xmlPath);
+
+ if (path == null)
+ FrontendError.reportFatal ("UI creation failure: XML layout "
+ + xmlPath + " does not exist.", null);
+
+ SwingEngine se = new SwingEngine (this);
+
+
+ // Custom UI element tag registration.
+
+ se.getTaglib ().registerTag ("hint", HintField.class);
+
+
+ // Read the XML.
+
+ try
+ {
+ se.insert (path, this);
+ }
+ catch (Exception e)
+ {
+ FrontendError.reportFatal ("UI creation failure: " + e.getMessage (), null);
+ }
}
}