001    /**
002     * iFish - An iRiver iHP jukebox database creation tool
003     *
004     * Copyright (C) 2009 Richard "Shred" Körber
005     *   http://ifish.shredzone.org
006     *
007     * This program is free software: you can redistribute it and/or modify
008     * it under the terms of the GNU General Public License as published by
009     * the Free Software Foundation, either version 3 of the License, or
010     * (at your option) any later version.
011     *
012     * This program is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015     * GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
019     */
020    package net.shredzone.ifish.gui;
021    
022    import java.awt.BorderLayout;
023    import java.awt.Component;
024    import java.awt.FlowLayout;
025    import java.awt.GridLayout;
026    import java.awt.SystemColor;
027    import java.awt.event.ActionEvent;
028    import java.awt.event.ActionListener;
029    import java.nio.charset.Charset;
030    import java.util.Locale;
031    import java.util.Map;
032    import java.util.Vector;
033    
034    import javax.swing.BorderFactory;
035    import javax.swing.BoxLayout;
036    import javax.swing.ButtonGroup;
037    import javax.swing.JButton;
038    import javax.swing.JCheckBox;
039    import javax.swing.JComboBox;
040    import javax.swing.JFileChooser;
041    import javax.swing.JLabel;
042    import javax.swing.JList;
043    import javax.swing.JPanel;
044    import javax.swing.JRadioButton;
045    import javax.swing.JSeparator;
046    import javax.swing.JTabbedPane;
047    import javax.swing.JTextField;
048    import javax.swing.plaf.basic.BasicComboBoxRenderer;
049    
050    import net.shredzone.ifish.IFishPane;
051    import net.shredzone.ifish.IFishPrefs;
052    import net.shredzone.ifish.i18n.L;
053    import net.shredzone.ifish.pool.ImgPool;
054    import net.shredzone.jshred.swing.JLAFSelector;
055    import net.shredzone.jshred.swing.JLabelGroup;
056    import net.shredzone.jshred.swing.SwingUtils;
057    
058    /**
059     * This panel allows to see and change the preferences.
060     *
061     * @author    Richard Körber &lt;dev@shredzone.de&gt;
062     * @version   $Id: PrefsPane.java 291 2009-04-28 21:29:27Z shred $
063     */
064    public class PrefsPane extends JPanel implements ActionListener {
065      private static final long serialVersionUID = 3258126942757730101L;
066    
067      private final IFishPane fish;
068      private final IFishPrefs prefs;
069      private Map<String, Charset> mCharsetMap;
070      private JTextField jtPath;
071      private JButton jbDirOpen;
072      private JCheckBox jcCompat;
073      private JComboBox jcbCharset;
074      private JComboBox jcbCharsetV1;
075      private JComboBox jcbCharsetV2;
076      private JButton jbRestore;
077      private JRadioButton jrbAlways;
078      private JRadioButton jrbIncremental;
079      private JCheckBox jcPlaylists;
080      private JCheckBox jcNewPL;
081      private JTextField jtName;
082      private JCheckBox jcDelMac;
083      private JCheckBox jcCheckDate;
084      private JComboBox jcbDirRename;
085      private JComboBox jcbFileRename;
086      private JCheckBox jcCheckTracks;
087      private JLAFSelector jLAF;
088      private JComboBox jcbLanguage;
089      private JTextField jtPLPath;
090      private JTextField jtPlay;
091      private JTextField jtPause;
092      private JTextField jtStop;
093      private Locale[] locales;
094    
095      /**
096       * Create a new Prefs pane.
097       *
098       * @param   fish        IFishPane
099       */
100      public PrefsPane( IFishPane fish ) {
101        this.fish = fish;
102        this.prefs = fish.getPrefs();
103        
104        //--- Prepare the Locale array ---
105        locales = new Locale[ IFishPrefs.LOCALES.length+1 ];
106        System.arraycopy( IFishPrefs.LOCALES, 0, locales, 1, IFishPrefs.LOCALES.length );
107        locales[0] = null;
108        
109        mCharsetMap = Charset.availableCharsets();
110        
111        setLayout( new BorderLayout() );
112        JTabbedPane jTab = new JTabbedPane();
113    //    jTab.setTabPlacement( JTabbedPane.RIGHT );
114        add( jTab, BorderLayout.CENTER );
115        
116        jTab.addTab( L.tr("prefs.tab.database"), createDatabaseTab() );
117        jTab.addTab( L.tr("prefs.tab.sync")    , createSyncTab()     );
118        jTab.addTab( L.tr("prefs.tab.player")  , createPlayerTab()   );
119        jTab.addTab( L.tr("prefs.tab.misc")    , createMiscTab()     );
120        
121        prefsToGui();
122      }
123    
124      /**
125       * Creates the Database tab.
126       * 
127       * @return    Component
128       */
129      private Component createDatabaseTab() {
130        JPanel panel = new JPanel();
131        panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) ); 
132        JLabelGroup group = null;
133    
134        //--- Database Settings ---
135        JPanel boxDatabase = new JPanel();
136        boxDatabase.setLayout( new BoxLayout( boxDatabase, BoxLayout.Y_AXIS ) );
137        {
138          //--- iRiver mount point ---
139          JPanel jpPath = new JPanel( new BorderLayout() );
140          {
141            jtPath = new JTextField();
142            jtPath.addActionListener( this );
143            jtPath.setToolTipText( L.tr("prefs.mount.tt") );
144            jpPath.add( jtPath, BorderLayout.CENTER );
145            
146            jbDirOpen = new JButton( ImgPool.get( "opendir.png" ) );
147            jbDirOpen.setToolTipText( L.tr("prefs.mount.tt") );
148            jbDirOpen.addActionListener( this );
149            jbDirOpen.setMargin( new java.awt.Insets(0,0,0,0) );
150            jpPath.add( jbDirOpen, BorderLayout.EAST );
151          }
152          group = new JLabelGroup( jpPath, L.tr("prefs.mount"), group );
153          boxDatabase.add( group );
154          
155          //--- Compatibility ---
156          jcCompat = new JCheckBox( L.tr("prefs.compat") );
157          jcCompat.addActionListener( this );
158          jcCompat.setToolTipText( L.tr("prefs.compat.tt") );
159          group = new JLabelGroup( jcCompat, "", group );
160          boxDatabase.add( group );
161        }
162        boxDatabase.setBorder( new MyTitledBorder( L.tr("prefs.group.database") ) );
163        SwingUtils.setMinimumHeight( boxDatabase );
164        panel.add( boxDatabase );
165    
166        //--- Database Scanning ---
167        JPanel jpScanner = new JPanel( new GridLayout( 0,1 ) );
168        {
169          ButtonGroup buttongroup = new ButtonGroup();
170          
171          jrbAlways = new JRadioButton( L.tr("prefs.scan.always") );
172          jrbAlways.addActionListener( this );
173          jrbAlways.setToolTipText( L.tr("prefs.scan.always.tt") );
174          buttongroup.add( jrbAlways );
175          jpScanner.add( jrbAlways );
176    
177          jrbIncremental = new JRadioButton( L.tr("prefs.scan.incremental") );
178          jrbIncremental.addActionListener( this );
179          jrbIncremental.setToolTipText( L.tr("prefs.scan.incremental.tt") );
180          buttongroup.add( jrbIncremental );
181          jpScanner.add( jrbIncremental );
182          
183          JPanel jpIncPanel = new JPanel();
184          jpIncPanel.setLayout( new BoxLayout( jpIncPanel, BoxLayout.Y_AXIS ) );
185          {
186            jcCheckDate = new JCheckBox( L.tr("prefs.scan.checkdate") );
187            jcCheckDate.addActionListener( this );
188            jcCheckDate.setToolTipText( L.tr("prefs.scan.checkdate.tt") );
189            jpIncPanel.add( jcCheckDate );
190          }
191          jpIncPanel.setBorder( BorderFactory.createEmptyBorder(0,15,0,0) );
192          jpScanner.add( jpIncPanel );
193        }
194        jpScanner.setBorder( new MyTitledBorder( L.tr("prefs.group.scanner") ) );
195        SwingUtils.setMinimumHeight( jpScanner );
196        panel.add( jpScanner );
197        
198        //--- Charsets ---
199        JPanel jpCharsets = new JPanel( new GridLayout( 0,1 ) );
200        {
201          //--- Database Charset ---
202          jcbCharset = new JComboBox( new Vector<Charset>( mCharsetMap.values() ) );
203          jcbCharset.addActionListener( this );
204          jcbCharset.setToolTipText( L.tr("prefs.charset.tt") );
205          group = new JLabelGroup( jcbCharset, L.tr("prefs.charset"), group );
206          jpCharsets.add( group );
207    
208          //--- MP3 ID3V1 Charset ---
209          jcbCharsetV1 = new JComboBox( new Vector<Charset>( mCharsetMap.values() ) );
210          jcbCharsetV1.addActionListener( this );
211          jcbCharsetV1.setToolTipText( L.tr("prefs.charsetv1.tt") );
212          group = new JLabelGroup( jcbCharsetV1, L.tr("prefs.charsetv1"), group );
213          jpCharsets.add( group );
214    
215          //--- MP3 ID3V2 Charset ---
216          jcbCharsetV2 = new JComboBox( new Vector<Charset>( mCharsetMap.values() ) );
217          jcbCharsetV2.addActionListener( this );
218          jcbCharsetV2.setToolTipText( L.tr("prefs.charsetv2.tt") );
219          group = new JLabelGroup( jcbCharsetV2, L.tr("prefs.charsetv2"), group );
220          jpCharsets.add( group );
221          
222          //--- Restore defaults ---
223          JPanel jpSmall = new JPanel( new FlowLayout( FlowLayout.LEADING, 0 ,0 ) );
224          {
225            jbRestore = new JButton( L.tr("prefs.charsetrestore") );
226            jbRestore.setToolTipText( L.tr("prefs.charsetrestore.tt") );
227            jbRestore.addActionListener( this );
228            jpSmall.add( jbRestore );
229          }
230          group = new JLabelGroup( jpSmall, "", group );
231          jpCharsets.add( group );
232        }
233        jpCharsets.setBorder( new MyTitledBorder( L.tr("prefs.group.charsets") ) );
234        SwingUtils.setMinimumHeight( jpCharsets );
235        panel.add( jpCharsets );
236    
237        group.rearrange();
238        return panel;
239      }
240      
241      /**
242       * Creates the Sync tab.
243       * 
244       * @return    Component
245       */
246      private Component createSyncTab() {
247        JPanel panel = new JPanel();
248        panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) ); 
249        JLabelGroup group = null;
250    
251        //--- Auto Renaming ---
252        JPanel boxRename = new JPanel();
253        boxRename.setLayout( new BoxLayout( boxRename, BoxLayout.Y_AXIS ) );
254        {
255          //--- Check Track Numbers ---
256          jcCheckTracks = new JCheckBox( L.tr("prefs.pl.tracks") );
257          jcCheckTracks.addActionListener( this );
258          jcCheckTracks.setToolTipText( L.tr("prefs.pl.tracks.tt") );
259          group = new JLabelGroup( jcCheckTracks, "", group );
260          boxRename.add( group );
261    
262          boxRename.add( new JSeparator() );
263          
264          //--- Headline ---
265          JPanel jpText = new JPanel( new FlowLayout( FlowLayout.LEADING, 0, 1 ) );
266          JLabel jlTitle = new JLabel( L.tr("prefs.rename.title") );
267          jlTitle.setForeground( SystemColor.textInactiveText );
268          jpText.add( jlTitle );
269          group = new JLabelGroup( jpText, "", group );
270          boxRename.add( group );
271          
272          //--- Directories ---
273          jcbDirRename = new JComboBox( new String[] {
274            L.tr("prefs.rename.ignoredir"),
275            L.tr("prefs.rename.abort"),
276          } );
277          jcbDirRename.addActionListener( this );
278          jcbDirRename.setToolTipText( L.tr("prefs.rename.dir.tt") );
279          group = new JLabelGroup( jcbDirRename, L.tr("prefs.rename.dir"), group );
280          boxRename.add( group );
281    
282          //--- Files ---
283          jcbFileRename = new JComboBox( new String[] {
284            L.tr("prefs.rename.ignorefile"),
285            L.tr("prefs.rename.abort"),
286            L.tr("prefs.rename.renamefile"),
287            L.tr("prefs.rename.askme"),
288          } );
289          jcbFileRename.addActionListener( this );
290          jcbFileRename.setToolTipText( L.tr("prefs.rename.files.tt") );
291          group = new JLabelGroup( jcbFileRename, L.tr("prefs.rename.files"), group );
292          boxRename.add( group );
293        }
294        boxRename.setBorder( new MyTitledBorder( L.tr("prefs.group.rename") ) );
295        SwingUtils.setMinimumHeight( boxRename );
296        panel.add( boxRename );
297    
298        //--- Playlists ---
299        JPanel boxPL = new JPanel( new GridLayout(0,1) );
300        {
301          jcPlaylists = new JCheckBox( L.tr("prefs.pl.generate") );
302          jcPlaylists.addActionListener( this );
303          jcPlaylists.setToolTipText( L.tr("prefs.pl.generate.tt") );
304          boxPL.add( jcPlaylists );
305          
306          jcNewPL = new JCheckBox( L.tr("prefs.pl.news") );
307          jcNewPL.addActionListener( this );
308          jcNewPL.setToolTipText( L.tr("prefs.pl.news.tt") );
309          boxPL.add( jcNewPL );
310          
311          jtName = new JTextField();
312          jtName.addActionListener( this );
313          jtName.setToolTipText( L.tr("prefs.pl.name.tt") );
314          group = new JLabelGroup( jtName, "   "+L.tr("prefs.pl.name"), group );
315          boxPL.add( group );
316    
317          JLabel jlUsage = new JLabel( L.tr("prefs.pl.name.usage") );
318          jlUsage.setForeground( SystemColor.textInactiveText );
319          group = new JLabelGroup( jlUsage, "", group );
320          boxPL.add( group );
321        }
322        boxPL.setBorder( new MyTitledBorder( L.tr("prefs.group.playlist") ) );
323        SwingUtils.setMinimumHeight( boxPL );
324        panel.add( boxPL );
325    
326        //--- Delete MacOS-X resource files ---
327        JPanel boxMac = new JPanel();
328        boxMac.setLayout( new BoxLayout( boxMac, BoxLayout.Y_AXIS ) );
329        {
330          JPanel jpDelMac = new JPanel( new BorderLayout() );
331          jcDelMac = new JCheckBox( L.tr("prefs.delmac") );
332          jcDelMac.addActionListener( this );
333          jcDelMac.setToolTipText( L.tr("prefs.delmac.tt") );
334          jpDelMac.add( jcDelMac, BorderLayout.WEST );
335          boxMac.add( jpDelMac );
336          
337          JLabel jlWarn = new JLabel( L.tr("prefs.delmac.warn") );
338          jlWarn.setForeground( SystemColor.textInactiveText );
339          group = new JLabelGroup( jlWarn, "", group );
340          boxMac.add( group );
341        }
342        boxMac.setBorder( new MyTitledBorder( L.tr("prefs.group.mac") ) );
343        SwingUtils.setMinimumHeight( boxMac );
344        panel.add( boxMac );
345    
346        group.rearrange();
347        return panel;
348      }
349    
350      /**
351       * Creates the Player tab.
352       * 
353       * @return    Component
354       */
355      private Component createPlayerTab() {
356        JPanel panel = new JPanel();
357        panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) ); 
358        JLabelGroup group = null;
359    
360        //--- Player commands ---
361        JPanel boxPlayer = new JPanel();
362        boxPlayer.setLayout( new BoxLayout( boxPlayer, BoxLayout.Y_AXIS ) );
363        {
364          JPanel jpText = new JPanel( new FlowLayout( FlowLayout.LEADING, 0, 1 ) );
365          JLabel jlMsg = new JLabel( L.tr("prefs.wildcard") );
366          jlMsg.setForeground( SystemColor.textInactiveText );
367          jpText.add( jlMsg );
368          group = new JLabelGroup( jpText, "", group );
369          boxPlayer.add( group );
370          
371          jtPlay = new JTextField();
372          jtPlay.addActionListener( this );
373          jtPlay.setToolTipText( L.tr("prefs.play.tt") );
374          group = new JLabelGroup( jtPlay, L.tr("prefs.play"), group );
375          boxPlayer.add( group );
376    
377          jtPause = new JTextField();
378          jtPause.addActionListener( this );
379          jtPause.setToolTipText( L.tr("prefs.pause.tt") );
380          group = new JLabelGroup( jtPause, L.tr("prefs.pause"), group );
381          boxPlayer.add( group );
382    
383          jtStop = new JTextField();
384          jtStop.addActionListener( this );
385          jtStop.setToolTipText( L.tr("prefs.stop.tt") );
386          group = new JLabelGroup( jtStop, L.tr("prefs.stop"), group );
387          boxPlayer.add( group );
388        }
389        boxPlayer.setBorder( new MyTitledBorder( L.tr("prefs.group.player") ) );
390        SwingUtils.setMinimumHeight( boxPlayer );
391        panel.add( boxPlayer );
392    
393        group.rearrange();
394        return panel;
395      }
396    
397      /**
398       * Creates the Misc tab.
399       * 
400       * @return    Component
401       */
402      private Component createMiscTab() {
403        JPanel panel = new JPanel();
404        panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) ); 
405        JLabelGroup group = null;
406    
407        //--- Look&Feel ---
408        JPanel boxLAF = new JPanel();
409        boxLAF.setLayout( new BoxLayout( boxLAF, BoxLayout.Y_AXIS ) );
410        {
411          jLAF = new JLAFSelector();
412          group = new JLabelGroup( jLAF, L.tr("prefs.laf.type"), group );
413          boxLAF.add( group );
414                
415          jcbLanguage = new JComboBox( locales );
416          jcbLanguage.setRenderer( new LanguageRenderer() );
417          group = new JLabelGroup( jcbLanguage, L.tr("prefs.pl.language"), group );
418          boxLAF.add( group );
419    
420          JPanel jpText = new JPanel( new FlowLayout( FlowLayout.LEADING, 0, 1 ) );
421          JLabel jlMsg = new JLabel( L.tr("prefs.laf.restart") );
422          jlMsg.setForeground( SystemColor.textInactiveText );
423          jpText.add( jlMsg );
424          group = new JLabelGroup( jpText, "", group );
425          boxLAF.add( group );
426        }
427        boxLAF.setBorder( new MyTitledBorder( L.tr("prefs.group.laf") ) );
428        SwingUtils.setMinimumHeight( boxLAF );
429        panel.add( boxLAF );
430    
431        //--- Playlist base directory ---
432        JPanel boxPLBase = new JPanel();
433        boxPLBase.setLayout( new BoxLayout( boxPLBase, BoxLayout.Y_AXIS ) );
434        {
435          jtPLPath = new JTextField();
436          jtPLPath.addActionListener( this );
437          jtPLPath.setToolTipText( L.tr("prefs.pl.base.tt") );
438          group = new JLabelGroup( jtPLPath, L.tr("prefs.pl.base"), group );
439          boxPLBase.add( group );
440                
441          JPanel jpText = new JPanel( new FlowLayout( FlowLayout.LEADING, 0, 1 ) );
442          JLabel jlMsg = new JLabel( L.tr("prefs.laf.restart") );
443          jlMsg.setForeground( SystemColor.textInactiveText );
444          jpText.add( jlMsg );
445          group = new JLabelGroup( jpText, "", group );
446          boxPLBase.add( group );
447        }
448        boxPLBase.setBorder( new MyTitledBorder( L.tr("prefs.group.plbase") ) );
449        SwingUtils.setMinimumHeight( boxPLBase );
450        panel.add( boxPLBase );
451        
452        group.rearrange();
453        return panel;
454      }
455    
456      /**
457       * Internal ActionListener implementation, do not use.
458       *
459       * @param   e         ActionEvent
460       */
461      @Override
462      public void actionPerformed( ActionEvent e ) {
463        Object src = e.getSource();
464        
465        if( src==jbDirOpen ) {
466          String start = prefs.getDirectory();
467          if( start.equals("") ) start = null;
468          JFileChooser chooser = new JFileChooser( start );
469          chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
470          chooser.setMultiSelectionEnabled( false );
471          if( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog( this ) ) {
472            java.io.File dir = chooser.getSelectedFile();
473            jtPath.setText( dir.getAbsolutePath() );
474          }
475    
476        }else if( src==jbRestore ) {
477          String charkey = System.getProperty( "file.encoding", "ISO-8859-1" );
478          if( charkey.startsWith("UTF") ) charkey = "ISO-8859-1";  // no UTF encoding!
479          try {
480            Charset charset88591 = Charset.forName( "ISO-8859-1" );
481            Charset charsetsys   = (Charset) mCharsetMap.get( charkey );
482            if( charsetsys==null ) charsetsys = charset88591;
483    
484            jcbCharset.setSelectedItem( charset88591 );
485            jcbCharsetV1.setSelectedItem( charsetsys );
486            jcbCharsetV2.setSelectedItem( charset88591 );
487          }catch( Exception ex ) {}
488          
489        }else if( src==jrbAlways || src==jrbIncremental || src==jcNewPL || src==jcCompat ) {
490          updateState();
491        }
492      }
493      
494      /**
495       * Updates the enabled state of some GUI elements according to the
496       * state of other elements.
497       */
498      protected void updateState() {
499        jcCheckDate.setEnabled( jrbIncremental.isSelected() );
500        jtName.setEnabled( jcNewPL.isSelected() );
501      }
502      
503      /**
504       * Store the current GUI settings as preferences.
505       */
506      public void guiToPrefs() {
507        prefs.setDirectory(     jtPath.getText()                          );
508        prefs.setCharset(       jcbCharset.getSelectedItem().toString()   );
509        prefs.setID3v1Charset(  jcbCharsetV1.getSelectedItem().toString() );
510        prefs.setID3v2Charset(  jcbCharsetV2.getSelectedItem().toString() );
511        prefs.setCompatibility( jcCompat.isSelected()                     );
512        prefs.setRebuild(       jrbAlways.isSelected()                    );
513        prefs.setPLComment(     jcPlaylists.isSelected()                  );
514        prefs.setPLNew(         jcNewPL.isSelected()                      );
515        prefs.setPLName(        jtName.getText()                          );
516        prefs.setPLBaseDir(     jtPLPath.getText()                        );
517        prefs.setDirRename(     jcbDirRename.getSelectedIndex()           );
518        prefs.setFileRename(    jcbFileRename.getSelectedIndex()          );
519        prefs.setCheckDate(     jcCheckDate.isSelected()                  );
520        prefs.setCheckTracks(   jcCheckTracks.isSelected()                );
521        prefs.setDelMac(        jcDelMac.isSelected()                     );
522        prefs.setLAF(           jLAF.getSelectedLAF()                     );
523        prefs.setLanguage(      (Locale) jcbLanguage.getSelectedItem()    );
524        prefs.setPlayerPlay(    jtPlay.getText()                          );
525        prefs.setPlayerPause(   jtPause.getText()                         );
526        prefs.setPlayerStop(    jtStop.getText()                          );
527      }
528      
529      /**
530       * Set the GUI according to the current preferences.
531       */
532      protected void prefsToGui() {
533        //--- Database Path ---
534        jtPath.setText( prefs.getDirectory() );
535    
536        //--- Charset Jukebox ---
537        jcCompat.setSelected( prefs.isCompatibility() );
538        String charkey = prefs.getCharset();
539        Charset charset = (Charset) mCharsetMap.get( charkey );
540        if( charset==null ) {
541          try {
542            charset = Charset.forName( "ISO-8859-1" );
543          }catch( Exception e ) {}
544        }
545        jcbCharset.setSelectedItem( charset );
546        
547        //--- Charset ID3v1 ---
548        charkey = prefs.getID3v1Charset();
549        charset = (Charset) mCharsetMap.get( charkey );
550        if( charset==null ) {
551          try {
552            charset = Charset.forName( "ISO-8859-1" );
553          }catch( Exception e ) {}
554        }
555        jcbCharsetV1.setSelectedItem( charset );
556    
557        //--- Charset ID3v2 ---
558        charkey = prefs.getID3v2Charset();
559        charset = (Charset) mCharsetMap.get( charkey );
560        if( charset==null ) {
561          try {
562            charset = Charset.forName( "ISO-8859-1" );
563          }catch( Exception e ) {}
564        }
565        jcbCharsetV2.setSelectedItem( charset );
566    
567        //--- Database Scanning ---
568        boolean alwaysRebuild = prefs.isRebuild();
569        jrbAlways.setSelected( alwaysRebuild );
570        jrbIncremental.setSelected( !alwaysRebuild );
571        jcCheckDate.setSelected( prefs.isCheckDate() );
572        jcCheckTracks.setSelected( prefs.isCheckTracks() );
573        jcPlaylists.setSelected( prefs.isPLComment() );
574        jcNewPL.setSelected( prefs.isPLNew() );
575        jtName.setText( prefs.getPLName() );
576        jcDelMac.setSelected( prefs.isDelMac() );
577        
578        //--- Directory Auto Renaming ---
579        int rebuildDirType = prefs.getDirRename();
580        jcbDirRename.setSelectedIndex( rebuildDirType );
581        
582        //--- File Auto Renaming ---
583        int rebuildFileType = prefs.getFileRename();
584        jcbFileRename.setSelectedIndex( rebuildFileType );
585        
586        //--- Player commands ---
587        jtPlay.setText(  prefs.getPlayerPlay()  );
588        jtPause.setText( prefs.getPlayerPause() );
589        jtStop.setText(  prefs.getPlayerStop()  );
590        
591        //--- Miscellaneous ---
592        jLAF.setSelectedLAF( prefs.getLAF() );
593        jcbLanguage.setSelectedItem( prefs.getLanguage() );
594        jtPLPath.setText( prefs.getPLBaseDir() );
595        
596        //--- Update GUI state ---
597        updateState();
598      }
599      
600      
601      private static class LanguageRenderer extends BasicComboBoxRenderer {
602        private static final long serialVersionUID = -7382577807756221463L;
603    
604        @Override
605        public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
606          if( value==null ) {
607            value = L.tr("prefs.autolang");
608          }else {
609            Locale loc = (Locale) value;
610            value = loc.getDisplayLanguage( loc );
611          }
612          return super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
613        }
614      }
615    
616    }