aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/show/viewer/ShowViewer.java
diff options
context:
space:
mode:
authorMatt Windsor <matt@deling.(none)>2011-03-18 08:28:09 +0000
committerMatt Windsor <matt@deling.(none)>2011-03-18 08:28:09 +0000
commitd547f87da5f68c12dede7c9d45618cae11ff5699 (patch)
tree613aa95d94b363c72ba9a7be639c74f76edf81f8 /src/uk/org/ury/show/viewer/ShowViewer.java
parentc8bb324e757587e742df0824304144e1eb881cee (diff)
Mega-commit to the rescue! Added Javadoc snapshot (admittedly old); show UI now fixed-layout; UI uses system selection colours for accents; now uses bapsserver password and can thus talk to show database relations; removed member relation dependencies until further notice; attempted to get application and applet launchers working but having issues with the latter; started working on a server communicating via a minimal implementation of HTTP 1.1 (standardisation required eventually).
Diffstat (limited to 'src/uk/org/ury/show/viewer/ShowViewer.java')
-rw-r--r--src/uk/org/ury/show/viewer/ShowViewer.java131
1 files changed, 58 insertions, 73 deletions
diff --git a/src/uk/org/ury/show/viewer/ShowViewer.java b/src/uk/org/ury/show/viewer/ShowViewer.java
index 8a0e46a..24e696b 100644
--- a/src/uk/org/ury/show/viewer/ShowViewer.java
+++ b/src/uk/org/ury/show/viewer/ShowViewer.java
@@ -1,21 +1,20 @@
package uk.org.ury.show.viewer;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.swing.SwingUtilities;
+import java.util.List;
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.database.exceptions.QueryFailureException;
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.FrontendModulePanel;
+import uk.org.ury.frontend.exceptions.UICreationFailureException;
import uk.org.ury.show.ShowChannel;
import uk.org.ury.show.ShowUtils;
+import uk.org.ury.show.item.ShowItem;
/**
@@ -39,7 +38,6 @@ public class ShowViewer extends AbstractFrontendModule
private DatabaseDriver dd;
private ShowChannel[] channels;
private ShowViewerPanel panel;
- private FrontendFrame frame;
private ConfigReader config;
@@ -50,75 +48,11 @@ public class ShowViewer extends AbstractFrontendModule
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.
*/
@@ -127,6 +61,18 @@ public class ShowViewer extends AbstractFrontendModule
runFrontend (FrontendMaster master)
{
dd = null;
+ config = null;
+
+ try
+ {
+ config = new ConfigReader (master.getResourceDirectory () + "conf.xml");
+ }
+ catch (MissingCredentialsException e)
+ {
+ System.out.println(e);
+ }
+
+
try
{
@@ -135,14 +81,39 @@ public class ShowViewer extends AbstractFrontendModule
catch (MissingCredentialsException e)
{
// TODO: Privilege de-escalation
- FrontendError.reportFatal (e.getMessage (), frame);
+ master.fatalError (e.getMessage ());
}
catch (Exception f)
{
- FrontendError.reportFatal (f.getMessage (), frame);
+ master.fatalError (f.getMessage ());
+ }
+
+ for (int i = 0; i < channels.length; i++)
+ {
+ channels[i] = new ShowChannel ();
+
+ try
+ {
+ for (ShowItem item : ShowUtils.getChannelList (dd, 4696, i))
+ {
+ channels[i].add (item);
+ }
+ }
+ catch (QueryFailureException e)
+ {
+ master.fatalError (e.getMessage ());
+ }
+ }
+
+ try
+ {
+ panel = new ShowViewerPanel (this, master);
+ }
+ catch (UICreationFailureException e)
+ {
+ master.fatalError (e.getMessage ());
}
- panel = new ShowViewerPanel (this, master);
return panel;
}
@@ -157,4 +128,18 @@ public class ShowViewer extends AbstractFrontendModule
// TODO Auto-generated method stub
return channels;
}
+
+
+ /**
+ * @return the list of bin names.
+ *
+ * @throws QueryFailureException if the underlying database query
+ * fails.
+ */
+
+ public List<String>
+ getBins () throws QueryFailureException
+ {
+ return ShowUtils.getPublicFolders (dd);
+ }
}