View Javadoc

1   package com.melloware.jukes.gui.view;
2   
3   import java.awt.BorderLayout;
4   import java.awt.Dimension;
5   import java.awt.EventQueue;
6   import java.awt.FlowLayout;
7   import java.awt.event.ActionEvent;
8   import java.awt.event.ActionListener;
9   import java.beans.PropertyChangeEvent;
10  import java.beans.PropertyChangeListener;
11  import java.util.Map;
12  import java.util.prefs.Preferences;
13  
14  import javax.sound.sampled.SourceDataLine;
15  import javax.swing.BorderFactory;
16  import javax.swing.JComponent;
17  import javax.swing.JLabel;
18  import javax.swing.JPanel;
19  import javax.swing.JProgressBar;
20  import javax.swing.JSplitPane;
21  import javax.swing.JToolBar;
22  import javax.swing.Timer;
23  
24  import javazoom.jlgui.basicplayer.BasicController;
25  import javazoom.jlgui.basicplayer.BasicPlayer;
26  import javazoom.jlgui.basicplayer.BasicPlayerEvent;
27  import javazoom.jlgui.basicplayer.BasicPlayerListener;
28  
29  import org.apache.commons.lang.StringUtils;
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  import org.apache.log4j.Level;
33  import org.apache.log4j.Logger;
34  
35  import com.jgoodies.looks.LookUtils;
36  import com.jgoodies.uif.action.ActionManager;
37  import com.jgoodies.uif.application.Application;
38  import com.jgoodies.uif.panel.SimpleInternalFrame;
39  import com.jgoodies.uif.util.ComponentTreeUtils;
40  import com.jgoodies.uifextras.util.ActionLabel;
41  import com.jgoodies.uifextras.util.UIFactory;
42  import com.melloware.jukes.db.HibernateUtil;
43  import com.melloware.jukes.db.orm.Track;
44  import com.melloware.jukes.file.Playlist;
45  import com.melloware.jukes.file.Disclist; //AZ
46  import com.melloware.jukes.file.image.ImageFactory;
47  import com.melloware.jukes.gui.tool.Actions;
48  import com.melloware.jukes.gui.tool.MainModule;
49  import com.melloware.jukes.gui.tool.Resources;
50  import com.melloware.jukes.gui.tool.Settings;
51  import com.melloware.jukes.gui.view.component.SpectrumTimeAnalyzer;
52  import com.melloware.jukes.gui.view.editor.ArtistEditor;
53  import com.melloware.jukes.gui.view.editor.DiscEditor;
54  import com.melloware.jukes.gui.view.editor.EditorPanel;
55  import com.melloware.jukes.gui.view.editor.EmptyPanel;
56  import com.melloware.jukes.gui.view.editor.TrackEditor;
57  import com.melloware.jukes.gui.view.editor.WelcomePanel;
58  import com.melloware.jukes.util.TimeSpan;
59  
60  /**
61   * Builds the main page of the Jukes application:
62   * the tool bar, navigator, help navigation, all editors,
63   * the dynamic help viewer, and the status bar.
64   * <p>
65   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
66   * @author Emil A. Lefkof III <info@melloware.com>
67   * @version 4.0
68   */
69  public final class MainPageBuilder
70      implements BasicPlayerListener {
71  
72      private static final Log LOG = LogFactory.getLog(MainPageBuilder.class);
73      private static final Dimension PREFERRED_SIZE = LookUtils.IS_LOW_RESOLUTION ? new Dimension(800, 600)
74                                                                                  : new Dimension(1024, 768);
75      private static final String MAIN_DIVIDER_LOCATION_KEY = "mainDividerLocation";
76      private static final String VIEWER_DIVIDER_LOCATION_KEY = "viewerDividerLocation";
77      private static final String NAVIGATOR_DIVIDER_LOCATION_KEY = "navigatorDividerLocation";
78      private static final String NAVIGATOR_VISIBLE_KEY = "navigatorVisible";
79      private static final String PLAYLIST_VISIBLE_KEY = "playlistVisible";
80      private static final String DISCLIST_VISIBLE_KEY = "disclistVisible"; //AZ
81      private static final TimeSpan TIMESPAN = new TimeSpan(0);
82      private ActionLabel trackField;
83      private EditorPanel editorPanel;
84      private FilterPanel filterPanel;
85      private JLabel bitrateField;
86      private JLabel durationField;
87      private JPanel mainPage;
88      private JProgressBar elapsedBar;
89      private JSplitPane editorPlaylistSplitPane;
90      private JSplitPane mainSplitPane;
91      private JSplitPane navigatorSplitPane;
92      private long elapsedTime;
93      private final MainFrame mainframe;
94      private final MainModule mainModule;
95      private Map audioInfo;
96      private NavigationPanelBuilder navigationPanel;
97      private final Playlist playlist;
98      private PlaylistPanel playlistPanel;
99      private final Disclist disclist; //AZ
100     private DisclistPanel disclistPanel; //AZ
101     private SimpleInternalFrame navigator;
102     private Timer timer;
103     private Boolean disclistVisible; //AZ
104     private Boolean playlistVisible; //AZ
105 
106     /**
107      * Constructs a MainPageBuilder for the given main module.
108      *
109      * @param mainModule   provides high-level models
110      */
111     MainPageBuilder(MainModule mainModule) {
112         this.mainModule = mainModule;
113         this.playlist = new Playlist();
114         this.disclist = new Disclist();
115         this.mainModule.addPropertyChangeListener(this.playlist);
116         this.mainModule.addPropertyChangeListener(this.disclist);
117         this.mainframe = (MainFrame)Application.getDefaultParentFrame();
118         MainModule.SETTINGS.addPropertyChangeListener(new PresentationSettingsChangeHandler());
119     }
120 
121     /**
122      * Gets the playlist.
123      * <p>
124      * @return Returns the playlist.
125      */
126     public Playlist getPlaylist() {
127         return this.playlist;
128     }
129     
130     /**
131      * Gets the disclist.
132      * <p>
133      * @return Returns the disclist.
134      */
135     public Disclist getDisclist() {
136         return this.disclist;
137     }
138 
139     /* (non-Javadoc)
140      * @see javazoom.jlgui.basicplayer.BasicPlayerListener#setController(javazoom.jlgui.basicplayer.BasicController)
141      */
142     public void setController(BasicController controller) {
143         if (LOG.isDebugEnabled()) {
144             LOG.debug("Controller " + controller);
145         }
146     }
147 
148     /**
149      * Sets the visibility of the filter panel.
150      */
151     public void setFilterVisible(boolean b) {
152         if (isFilterVisible() == b) {
153             return;
154         }
155         if (b) {
156             navigatorSplitPane.setTopComponent(navigator);
157             navigatorSplitPane.setBottomComponent(filterPanel);
158             int navigatorDividerLocation = Application.getUserPreferences().getInt(NAVIGATOR_DIVIDER_LOCATION_KEY, -1);
159             if ((navigatorDividerLocation > 50) && (navigatorDividerLocation < (mainPage.getHeight() - 50))) {
160                 navigatorSplitPane.setDividerLocation(navigatorDividerLocation);
161             }
162         } else {
163             navigatorSplitPane.setTopComponent(navigator);
164             navigatorSplitPane.setBottomComponent(null);
165         }
166     }
167 
168     /**
169      * Sets the visibility of the playlist panel.
170      * <p>
171      * @param visible whether or not the window is visible
172      */
173     public void setPlaylistVisible(boolean visible) {
174         /** AZ
175     	if (isPlaylistVisible() == visible) {
176             return;
177         } **/
178     	
179         if (visible) {
180             editorPlaylistSplitPane.setTopComponent(editorPanel);
181             editorPlaylistSplitPane.setBottomComponent(playlistPanel);
182             int verticalDividerLocation = Application.getUserPreferences().getInt(VIEWER_DIVIDER_LOCATION_KEY, -1);
183             if ((verticalDividerLocation > 100) && (verticalDividerLocation < (mainPage.getHeight() - 50))) {
184                 editorPlaylistSplitPane.setDividerLocation(verticalDividerLocation);
185             }
186             playlistVisible = true;
187         } else {
188         	if (disclistVisible != null) {
189         	if (disclistVisible) {
190                 editorPlaylistSplitPane.setBottomComponent(disclistPanel);
191         	} else {
192                 editorPlaylistSplitPane.setBottomComponent(null);        		
193         	}
194             editorPlaylistSplitPane.setTopComponent(editorPanel);
195             playlistVisible = false;
196             } else {
197             editorPlaylistSplitPane.setTopComponent(editorPanel);
198             editorPlaylistSplitPane.setBottomComponent(null); 
199             playlistVisible = false;        	
200             }
201       }	
202     }
203 
204     /**
205      * Answers if the filter panel is visible.
206      */
207     public boolean isFilterVisible() {
208         return navigatorSplitPane.getBottomComponent() != null;
209     }
210 
211     /**
212      * Answers if the playlist panel is visible.
213      */
214     public boolean isPlaylistVisible() {
215     	return playlistVisible;
216         //return editorPlaylistSplitPane.getBottomComponent() != null;
217     }
218 
219     /* (non-Javadoc)
220      * @see javazoom.jlgui.basicplayer.BasicPlayerListener#opened(java.lang.Object, java.util.Map)
221      */
222     public void opened(Object stream, Map properties) {
223         audioInfo = properties;
224 
225         /*
226          * mp3.frequency.hz='44100' title='We' mp3.length.bytes='6078464' comment='Test Comments !' mp3.channels='2'
227          * date='2003' mp3.version.layer='3' mp3.framesize.bytes='413' mp3.id3tag.track='3' mp3.version.mpeg='1'
228          * mp3.bitrate.nominal.bps='229000' mp3.vbr.scale='78' copyright='copy' mp3.length.frames='8122' mp3.crc='false'
229          * album='The Sta no Expe' mp3.vbr='true' mp3.copyright='false' mp3.framerate.fps='38.28125'
230          * mp3.id3tag.v2='java.io.ByteArrayInputStream@13caecd' mp3.id3tag.v2.version='3' mp3.version.encoding='MPEG1L3'
231          * mp3.header.pos='2150' mp3.id3tag.genre='(18)Techno' mp3.original='false' mp3.mode='1' mp3.padding='false'
232          * author='Scer' duration='212167000' vbr='true' bitrate='229000'
233          *
234          */
235         final Track track = playlist.getCurrentTrack();
236         final String title = track.getName();
237         final String disc = track.getDisc().getName();
238         final String artist = track.getDisc().getArtist().getName();
239         final Long duration = Long.valueOf(track.getDuration() * 1000);
240         final String bitrate = (track.getBitrate().intValue()) + " kbps";
241         final Runnable updateList = new Runnable() {
242            public void run() {
243               trackField.setText(artist + " - " + disc + " - " + title);
244               bitrateField.setText(bitrate);
245               final int ms = (int)(duration.longValue());
246               TIMESPAN.setTime(duration.longValue());
247               durationField.setText(TIMESPAN.getMusicDuration());
248               elapsedBar.setValue(0);
249               elapsedBar.setMaximum(ms);
250               
251               // set the tray icon tooltip
252               if (mainframe.getTrayIcon() != null) {
253                   mainframe.getTrayIcon().setToolTip(artist + " - " + title);
254               }
255               
256               // refresh the window
257               refreshUI();
258            }
259         };
260         EventQueue.invokeLater(updateList);
261 
262         
263     }
264 
265     /* (non-Javadoc)
266      * @see javazoom.jlgui.basicplayer.BasicPlayerListener#progress(int, long, byte[], java.util.Map)
267      */
268     public void progress(int bytesread, long microseconds, byte[] pcmdata, Map properties) {
269       if (audioInfo.containsKey("audio.type")) {
270          String audioformat = (String) audioInfo.get("audio.type");
271          if (audioformat.equalsIgnoreCase("mp3")) {
272             mainframe.getAnalyzer().writeDSP(pcmdata);
273          }
274       }
275 
276       this.setElapsedTime(microseconds);
277    }
278 
279     /**
280      * Repaints the screen after a track changes.
281      */
282     public void refreshUI() {
283         //mainPage.updateUI();
284        navigator.updateUI();
285        editorPanel.updateUI();
286        //disclistPanel.repaint();     
287     }
288 
289     /**
290      * Restores the frame's state from the user preferences.
291      */
292     public void restoreFrom(Preferences userPrefs) {
293         int mainDividerLocation = userPrefs.getInt(MAIN_DIVIDER_LOCATION_KEY, -1);
294         int verticalDividerLocation = userPrefs.getInt(VIEWER_DIVIDER_LOCATION_KEY, -1);
295         int navigatorDividerLocation = userPrefs.getInt(NAVIGATOR_DIVIDER_LOCATION_KEY, -1);
296         setPlaylistVisible(userPrefs.getBoolean(PLAYLIST_VISIBLE_KEY, true));
297         setDisclistVisible(userPrefs.getBoolean(DISCLIST_VISIBLE_KEY, true)); //AZ
298         setFilterVisible(userPrefs.getBoolean(NAVIGATOR_VISIBLE_KEY, true));
299 
300         if ((mainDividerLocation > 100) && (mainDividerLocation < (mainPage.getWidth() - 50))) {
301             mainSplitPane.setDividerLocation(mainDividerLocation);
302         }
303         if ((verticalDividerLocation > 100) && (verticalDividerLocation < (mainPage.getHeight() - 50))) {
304             editorPlaylistSplitPane.setDividerLocation(verticalDividerLocation);
305         }
306         if ((navigatorDividerLocation > 50) && (navigatorDividerLocation < (mainPage.getHeight() - 50))) {
307             navigatorSplitPane.setDividerLocation(navigatorDividerLocation);
308         }
309     }
310 
311     /* (non-Javadoc)
312      * @see javazoom.jlgui.basicplayer.BasicPlayerListener#stateUpdated(javazoom.jlgui.basicplayer.BasicPlayerEvent)
313      */
314     public void stateUpdated(BasicPlayerEvent event) {
315         if (LOG.isDebugEnabled()) {
316            LOG.debug("stateUpdated : " + event.toString());
317         }
318         final SpectrumTimeAnalyzer analyzer = mainframe.getAnalyzer();
319         switch (event.getCode()) {
320 //            case BasicPlayerEvent.PLAYING: {
321 //                break;
322 //            }
323             case BasicPlayerEvent.PLAYING:
324             case BasicPlayerEvent.OPENED:
325             case BasicPlayerEvent.RESUMED: {
326                 mainframe.updateTrayIcon(ImageFactory.ICO_TRAYPLAY.getImage());
327                 if ((audioInfo.containsKey("basicplayer.sourcedataline")) && (analyzer != null)) {
328                    analyzer.setupDSP((SourceDataLine)audioInfo.get("basicplayer.sourcedataline"));
329                    analyzer.startDSP((SourceDataLine)audioInfo.get("basicplayer.sourcedataline"));
330                 }
331                 timer.start();
332                 break;
333             }
334             case BasicPlayerEvent.PAUSED: {
335                 timer.stop();
336                 mainframe.updateTrayIcon(ImageFactory.ICO_TRAYPAUSE.getImage());
337                 break;
338             }
339             case BasicPlayerEvent.STOPPED: {
340                 timer.stop();
341                 mainframe.updateTrayIcon(ImageFactory.ICO_TRAYSTOP.getImage());
342                 if (analyzer != null) {
343                    analyzer.stopDSP();
344                    analyzer.repaint();
345                 }
346                 final Runnable updateList = new Runnable() {
347                    public void run() {
348                       elapsedBar.setValue(0);
349                       TIMESPAN.setTime(0);
350                       elapsedBar.setString(TIMESPAN.getMusicDuration());
351                    }
352                 };
353                 EventQueue.invokeLater(updateList);
354                 break;
355             }
356             case BasicPlayerEvent.EOM: {
357                 timer.stop();
358                 final Track track = (Track)getPlaylist().getNext();
359                 if (track != null) {
360                     mainframe.getPlayer().play(track.getTrackUrl());
361                 }
362                 break;
363             }
364             default: {
365                 break;
366             }
367         }
368     }
369     
370     
371 
372     /**
373      * Stores the frame's state in the user preferences.
374      */
375     public void storeIn(Preferences userPrefs) {
376         if (isPlaylistVisible()) {
377             int verticalDividerLocation = editorPlaylistSplitPane.getDividerLocation();
378             userPrefs.putInt(VIEWER_DIVIDER_LOCATION_KEY, verticalDividerLocation);
379         }
380         if (isFilterVisible()) {
381             int navigatorDividerLocation = navigatorSplitPane.getDividerLocation();
382             userPrefs.putInt(NAVIGATOR_DIVIDER_LOCATION_KEY, navigatorDividerLocation);
383         }
384         //AZ
385         if (isDisclistVisible()) {
386             int verticalDividerLocation = editorPlaylistSplitPane.getDividerLocation();
387             userPrefs.putInt(VIEWER_DIVIDER_LOCATION_KEY, verticalDividerLocation);
388         }
389         int mainDividerLocation = mainSplitPane.getDividerLocation();
390         userPrefs.putInt(MAIN_DIVIDER_LOCATION_KEY, mainDividerLocation);
391         userPrefs.putBoolean(NAVIGATOR_VISIBLE_KEY, isFilterVisible());
392         userPrefs.putBoolean(PLAYLIST_VISIBLE_KEY, isPlaylistVisible());
393         userPrefs.putBoolean(DISCLIST_VISIBLE_KEY, isDisclistVisible());
394     }
395 
396     /**
397      * Builds this panel with the horizontal <code>JSplitPane</code> in the
398      * center and a status bar in the south.
399      */
400     JComponent build() {
401         initComponents();
402 
403         mainPage = new RefreshedPanel();
404         mainPage.setLayout(new BorderLayout());
405         mainPage.add(new MainToolBarBuilder().build(), BorderLayout.NORTH);
406         mainPage.add(buildMainSplitPane(), BorderLayout.CENTER);
407         mainPage.add(buildStatusBar(), BorderLayout.SOUTH);
408         mainPage.setPreferredSize(PREFERRED_SIZE);
409 
410         return mainPage;
411     }
412 
413     /**
414      * Builds the <code>EditorPanel</code>, the <code>PlaylistPanel</code>
415      * and answers them wrapped by a stripped <code>JSplitPane</code>.
416      */
417     private JComponent buildEditorHelpPanel() {
418         editorPlaylistSplitPane = UIFactory.createStrippedSplitPane(JSplitPane.VERTICAL_SPLIT, buildEditorPanel(),
419                                                                     playlistPanel, 0.667);
420         return editorPlaylistSplitPane;
421     }
422 
423     /**
424      * Builds and answers the <code>EditorPanel</code>.
425      */
426     private EditorPanel buildEditorPanel() {
427         WelcomePanel welcomePanel = new WelcomePanel();
428 
429         editorPanel.addEditor(welcomePanel);
430         editorPanel.addEditor(new EmptyPanel());
431         editorPanel.addEditor(new ArtistEditor());
432         editorPanel.addEditor(new DiscEditor());
433         editorPanel.addEditor(new TrackEditor());
434 
435         editorPanel.setActiveEditor(welcomePanel);
436         return editorPanel;
437     }
438 
439     /**
440      * Builds the <code>Navigator</code>, the <code>HelpNavigator</code>
441      * and answers them wrapped by a stripped <code>JSplitPane</code>.
442      */
443     private JComponent buildFilterPanel() {
444         return UIFactory.createStrippedSplitPane(JSplitPane.VERTICAL_SPLIT, navigator, filterPanel, 0.64);
445     }
446 
447     /**
448      * Builds and answers the main <code>JSplitPane</code> that contains
449      * the navigation elements on the left, and the view panels on the right.
450      */
451     private JComponent buildMainSplitPane() {
452         navigatorSplitPane = (JSplitPane)buildFilterPanel();
453         mainSplitPane = UIFactory.createStrippedSplitPane(JSplitPane.HORIZONTAL_SPLIT, navigatorSplitPane,
454                                                           buildEditorHelpPanel(), 0.25);
455         mainSplitPane.setBorder(BorderFactory.createEmptyBorder(6, 4, 0, 4));
456         return mainSplitPane;
457     }
458 
459     /**
460      * Builds and answers the status bar.
461      */
462     private JPanel buildStatusBar() {
463         final JPanel statusPanel = new JPanel(new BorderLayout());
464         final JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
465         final JToolBar toolbar = MainToolBarBuilder.buildPlayerToolBar();
466         toolbar.setBorder(BorderFactory.createEmptyBorder());
467         infoPanel.setBorder(BorderFactory.createEmptyBorder());
468         statusPanel.add(toolbar, BorderLayout.WEST);
469         statusPanel.add(infoPanel, BorderLayout.EAST);
470         statusPanel.setBorder(BorderFactory.createEmptyBorder());
471         infoPanel.add(trackField);
472         trackField.setBorder(BorderFactory.createEmptyBorder());
473         infoPanel.add(bitrateField);
474         bitrateField.setBorder(BorderFactory.createEmptyBorder());
475         infoPanel.add(durationField);
476         durationField.setBorder(BorderFactory.createEmptyBorder());
477         infoPanel.add(elapsedBar);
478         elapsedBar.setBorder(BorderFactory.createEmptyBorder());
479         return statusPanel;
480     }
481 
482     /**
483      * Creates, binds and configures the subpanels and components.
484      */
485     private void initComponents() {
486         navigator = new SimpleInternalFrame(Resources.getString("navigator.label"));
487         navigator.setFrameIcon(Resources.NAVIGATOR_ICON);
488         navigationPanel = new NavigationPanelBuilder(mainModule);
489         navigator.setContent(navigationPanel.build());
490         navigator.setSelected(true);
491         navigator.setMinimumSize(new Dimension(100, 100));
492         navigator.setPreferredSize(new Dimension(160, 200));
493         navigator.setFrameIcon(Resources.NAVIGATOR_ICON);
494 
495         filterPanel = new FilterPanel(MainModule.SETTINGS);
496         filterPanel.setSelected(true);
497         filterPanel.setMinimumSize(new Dimension(100, 45));
498         filterPanel.setPreferredSize(new Dimension(100, 45));
499 
500         editorPanel = new EditorPanel(mainModule);
501         editorPanel.setMinimumSize(new Dimension(200, 100));
502         editorPanel.setPreferredSize(new Dimension(400, 200));
503 
504         playlistPanel = new PlaylistPanel(this.playlist);
505         playlistPanel.setName("playlistPanel");
506         playlistPanel.setMinimumSize(new Dimension(300, 100));
507         playlistPanel.setPreferredSize(new Dimension(300, 100));
508         
509         //AZ
510         disclistPanel = new DisclistPanel(this.disclist);
511         disclistPanel.setName("disclistPanel");
512         disclistPanel.setMinimumSize(new Dimension(300, 100));
513         disclistPanel.setPreferredSize(new Dimension(300, 100));
514 
515         trackField = new ActionLabel("");
516         trackField.addActionListener(new ActionListener() {
517 
518                 // select the track in the editor
519                 public void actionPerformed(ActionEvent event) {
520                     LOG.debug("Track clicked");
521                     if (playlist.getCurrentTrack() != null) {
522                         mainModule.selectNodeInTree(playlist.getCurrentTrack());
523                     }
524                 }
525             });
526         bitrateField = UIFactory.createPlainLabel("");
527         durationField = UIFactory.createPlainLabel("");
528         elapsedBar = new JProgressBar(0, 1);
529         elapsedBar.setIndeterminate(false);
530         elapsedBar.setStringPainted(true);
531         elapsedBar.setString("");
532 
533         timer = new Timer(950, new ActionListener() {
534 
535                 public void actionPerformed(ActionEvent aE) {
536                    final int elapsed = (int)(getElapsedTime() / 1000);
537                    TIMESPAN.setTime(elapsed);
538                    elapsedBar.setValue(elapsed);
539                    elapsedBar.setString(TIMESPAN.getMusicDuration());
540                 }
541             });
542     }
543     
544     /**
545      * Gets the elapsedTime.
546      * <p>
547      * @return Returns the elapsedTime.
548      */
549     protected synchronized long getElapsedTime() {
550        return this.elapsedTime;
551     }
552 
553     /**
554      * Sets the elapsedTime.
555      * <p>
556      * @param aElapsedTime The elapsedTime to set.
557      */
558     protected synchronized void setElapsedTime(long aElapsedTime) {
559        this.elapsedTime = aElapsedTime;
560     }
561 
562     // Updates the application if settings changed
563     private class PresentationSettingsChangeHandler
564         implements PropertyChangeListener {
565 
566         /**
567          * The presentation settings have changed.
568          *
569          * @param evt   describes the property change
570          */
571         public void propertyChange(PropertyChangeEvent evt) {
572             final String[] props = {
573                 Settings.PROPERTYNAME_AUDIT_INFO, Settings.PROPERTYNAME_COVER_SIZE_LARGE,
574                 Settings.PROPERTYNAME_COVER_SIZE_SMALL
575             };
576             final String[] refreshprops = {
577                 Settings.PROPERTYNAME_DISPLAY_FORMAT_DISC, Settings.PROPERTYNAME_DISPLAY_FORMAT_TRACK,
578                 Settings.PROPERTYNAME_NEW_FILE_IN_DAYS
579             };
580             final String[] connectProps = {
581                 Settings.PROPERTYNAME_REMOTE_DATABASE_URL, Settings.PROPERTYNAME_DIRECTORY_DB_LOCATION
582             };
583 
584             if (Settings.PROPERTYNAME_PLAYER_BUFFER_SIZE.equals(evt.getPropertyName())) {
585                 LOG.debug("Buffer size changed");
586                 BasicPlayer.EXTERNAL_BUFFER_SIZE = MainModule.SETTINGS.getPlayerBufferSize();
587             }
588             
589             if (Settings.PROPERTYNAME_LOG_LEVEL.equals(evt.getPropertyName())) {
590                 LOG.info("Log Level changed");
591                 Logger.getRootLogger().setLevel(Level.toLevel(MainModule.SETTINGS.getLogLevel()));
592                 Logger.getLogger("com.melloware").setLevel(Level.toLevel(MainModule.SETTINGS.getLogLevel()));
593                 Logger.getLogger("com.melloware.jukes.gui").setLevel(Level.toLevel(MainModule.SETTINGS.getLogLevel()));
594             }
595 
596             // if any of the editor settings changes reload
597             if (StringUtils.indexOfAny(evt.getPropertyName(), props) >= 0) {
598                 LOG.debug("Editor options changed");
599                 editorPanel.clearEditors();
600                 buildEditorPanel();
601             }
602 
603             // do we need to reconnect on prop change
604             if (StringUtils.indexOfAny(evt.getPropertyName(), connectProps) >= 0) {
605                 LOG.debug("DB Location changed, reconnecting to DB and refreshing tree.");
606                 HibernateUtil.shutdown();
607                 final String remoteURL = MainModule.SETTINGS.getRemoteDatabaseURL();
608                 if ((StringUtils.isNotBlank(remoteURL)) && (!Settings.DEFAULT_REMOTE_DATABASE_URL.equals(remoteURL))) {
609                     HibernateUtil.setRemoteUrl(remoteURL);
610                 } else {
611                     HibernateUtil.setRemoteUrl(null);
612                 }
613                 ActionManager.get(Actions.CONNECT_ID).actionPerformed(null);
614             }
615 
616             // do we need to refresh the tree on prop change
617             if (StringUtils.indexOfAny(evt.getPropertyName(), refreshprops) >= 0) {
618                 LOG.debug("Navigation options changed.");
619                 ActionManager.get(Actions.REFRESH_ID).actionPerformed(null);
620             }
621             
622             if (Settings.PROPERTYNAME_ANALYZER_MODE.equals(evt.getPropertyName())) {
623                 mainframe.getAnalyzer().setDisplayMode(MainModule.SETTINGS.getAnalyzerMode());
624             }
625         }
626     }
627 
628     private class RefreshedPanel
629         extends JPanel {
630 
631         /**
632          * In case some panels are invisible, we explicitly update their UIs.
633          */
634         public void updateUI() {
635             super.updateUI();
636             if (getComponentCount() == 0) {
637                 return;
638             }
639             if ((editorPlaylistSplitPane == null) || isPlaylistVisible()) {
640                 return;
641             }
642             ComponentTreeUtils.updateComponentTreeUI(editorPlaylistSplitPane);
643         }
644 
645     }
646 
647     /**
648      * Sets the visibility of the disclist panel.
649      * <p>
650      * @param visible whether or not the window is visible
651      */
652     public void setDisclistVisible(boolean visible) {
653         if (visible) {
654             editorPlaylistSplitPane.setTopComponent(editorPanel);
655             editorPlaylistSplitPane.setBottomComponent(disclistPanel);
656             int verticalDividerLocation = Application.getUserPreferences().getInt(VIEWER_DIVIDER_LOCATION_KEY, -1);
657             if ((verticalDividerLocation > 100) && (verticalDividerLocation < (mainPage.getHeight() - 50))) {
658                 editorPlaylistSplitPane.setDividerLocation(verticalDividerLocation);
659             }
660             disclistVisible = true;
661         } else {
662         	if (playlistVisible != null) {
663         	if (playlistVisible) {
664              editorPlaylistSplitPane.setBottomComponent(playlistPanel);        		
665         	} else {
666              editorPlaylistSplitPane.setBottomComponent(null);
667         	}
668             editorPlaylistSplitPane.setTopComponent(editorPanel);
669             disclistVisible = false;
670         } else {
671             editorPlaylistSplitPane.setTopComponent(editorPanel);
672             editorPlaylistSplitPane.setBottomComponent(null);
673             disclistVisible = false;        	
674           }
675         }
676     }
677 
678 
679     /**
680      * Answers if the disclist panel is visible.
681      */
682     public boolean isDisclistVisible() {
683     	//AZ 
684     	return disclistVisible;
685         //return editorPlaylistSplitPane.getBottomComponent() != null;
686     }  
687     
688     /**
689      * Returns the name of list panel currently visible.
690      */
691     public String panelVisible() {
692     	String panelName;
693     	if (editorPlaylistSplitPane.getBottomComponent() != null) {
694     		panelName = editorPlaylistSplitPane.getBottomComponent().getName();
695     	} else {
696     		panelName = "No Panel";
697     	}
698      	return panelName;
699     }  
700 
701 }