diff options
author | Nathan Lasseter <nathan.je.lasseter@googlemail.com> | 2011-02-20 13:43:01 +0000 |
---|---|---|
committer | Nathan Lasseter <nathan.je.lasseter@googlemail.com> | 2011-02-20 13:43:01 +0000 |
commit | 904caa25f8de49cc20823a25ce8051dfdcae7c26 (patch) | |
tree | 65c174a386c7256e4ec784167bd23554e2c1217b /src/uk/org/ury/library/viewer | |
parent | c8cb46d18ce2506e7da226b08c6521795b6e6173 (diff) |
ConfigReader and some UI changes
Diffstat (limited to 'src/uk/org/ury/library/viewer')
-rw-r--r-- | src/uk/org/ury/library/viewer/LibraryViewer.java | 6 | ||||
-rw-r--r-- | src/uk/org/ury/library/viewer/LibraryViewerPanel.java | 56 |
2 files changed, 30 insertions, 32 deletions
diff --git a/src/uk/org/ury/library/viewer/LibraryViewer.java b/src/uk/org/ury/library/viewer/LibraryViewer.java index 57ef117..970235a 100644 --- a/src/uk/org/ury/library/viewer/LibraryViewer.java +++ b/src/uk/org/ury/library/viewer/LibraryViewer.java @@ -7,6 +7,7 @@ import java.util.List; 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; @@ -42,6 +43,7 @@ public class LibraryViewer extends AbstractFrontendModule public static void main (String[] args) { + new ConfigReader(); LibraryViewer lv = new LibraryViewer (); lv.runFrontendInFrame (); } @@ -167,11 +169,11 @@ public class LibraryViewer extends AbstractFrontendModule */ public void - doSearch (String title, String artist) + doSearch (String search) { try { - libraryList = LibraryUtils.search (dd, title, artist); + libraryList = LibraryUtils.search (dd, search); } catch (QueryFailureException e) { diff --git a/src/uk/org/ury/library/viewer/LibraryViewerPanel.java b/src/uk/org/ury/library/viewer/LibraryViewerPanel.java index 37f36eb..cf2edfe 100644 --- a/src/uk/org/ury/library/viewer/LibraryViewerPanel.java +++ b/src/uk/org/ury/library/viewer/LibraryViewerPanel.java @@ -5,6 +5,7 @@ package uk.org.ury.library.viewer; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -43,11 +44,9 @@ public class LibraryViewerPanel extends FrontendPanel private JTable resultsTable; private JScrollPane resultsPane; - private JLabel titleLabel; - private JLabel artistLabel; + private JLabel searchLabel; - private JTextField titleField; - private JTextField artistField; + private JTextField searchField; private JButton searchButton; @@ -76,28 +75,32 @@ public class LibraryViewerPanel extends FrontendPanel layout.setAutoCreateGaps (true); layout.setAutoCreateContainerGaps (true); - titleLabel = new JLabel ("By title: "); - artistLabel = new JLabel ("By artist: "); + searchLabel = new JLabel ("Search"); + searchLabel.setFont(new Font("Verdana", Font.BOLD, 14)); - titleField = new JTextField (); + searchField = new JTextField (); - titleField.setPreferredSize (new Dimension (250, 15)); - - titleLabel.setDisplayedMnemonic ('T'); - titleLabel.setLabelFor (titleField); - - artistField = new JTextField (); - artistLabel.setDisplayedMnemonic ('A'); - artistLabel.setLabelFor (artistField); + searchField.setPreferredSize (new Dimension (250, 25)); + searchField.setFont(new Font("Verdana", Font.BOLD, 14)); + searchLabel.setDisplayedMnemonic ('T'); + searchLabel.setLabelFor (searchField); + searchButton = new JButton ("Search"); + + searchField.addActionListener(new ActionListener() { + public void actionPerformed (ActionEvent event) { + master.doSearch (searchField.getText ()); + resultsTable.setModel (new LibraryTableModel (master.getLibraryList ())); + } + }); searchButton.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent event) { - master.doSearch (titleField.getText (), artistField.getText ()); + master.doSearch (searchField.getText ()); resultsTable.setModel (new LibraryTableModel (master.getLibraryList ())); } }); @@ -110,11 +113,9 @@ public class LibraryViewerPanel extends FrontendPanel ( layout.createSequentialGroup () .addGroup (layout.createParallelGroup (GroupLayout.Alignment.LEADING) - .addComponent (titleLabel) - .addComponent (artistLabel)) + .addComponent (searchLabel)) .addGroup (layout.createParallelGroup (GroupLayout.Alignment.LEADING) - .addComponent (titleField) - .addComponent (artistField)) + .addComponent (searchField)) .addGroup (layout.createParallelGroup (GroupLayout.Alignment.LEADING) .addComponent (searchButton)) ); @@ -123,16 +124,13 @@ public class LibraryViewerPanel extends FrontendPanel ( layout.createSequentialGroup () .addGroup (layout.createParallelGroup (GroupLayout.Alignment.LEADING) - .addComponent (titleLabel) - .addComponent (titleField) + .addComponent (searchLabel) + .addComponent (searchField) .addComponent (searchButton)) - .addGroup (layout.createParallelGroup (GroupLayout.Alignment.LEADING) - .addComponent (artistLabel) - .addComponent (artistField)) ); - layout.linkSize (SwingConstants.HORIZONTAL, titleField, artistField); - layout.linkSize (SwingConstants.VERTICAL, titleField, artistField); + layout.linkSize (SwingConstants.HORIZONTAL, searchField); + layout.linkSize (SwingConstants.VERTICAL, searchField); add (groupPanel, BorderLayout.NORTH); @@ -149,9 +147,7 @@ public class LibraryViewerPanel extends FrontendPanel // Explanation (TODO: Subclass?) - JTextArea explanation = new JTextArea ("To narrow your search, type part or all of the record title or artist" - + " into the respective box above. If you leave a box blank, it will" - + " not be used in the search."); + JTextArea explanation = new JTextArea ("To narrow your search, type part or all of the record title or artist into the box above."); explanation.setLineWrap (true); explanation.setWrapStyleWord (true); |