/[schmitzm]/trunk/src/skrueger/i8n/SwitchLanguageDialog.java
ViewVC logotype

Diff of /trunk/src/skrueger/i8n/SwitchLanguageDialog.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 124 by alfonx, Thu May 21 21:01:59 2009 UTC revision 140 by alfonx, Sun Jun 14 17:24:44 2009 UTC
# Line 25  import schmitzm.swing.SwingUtil; Line 25  import schmitzm.swing.SwingUtil;
25  import skrueger.swing.OkButton;  import skrueger.swing.OkButton;
26  import skrueger.swing.TranslationEditJPanel;  import skrueger.swing.TranslationEditJPanel;
27    
28    /**
29     * This dialog ask the user to select one of list of given languages. The dialog
30     * is modal and not visible after construction.
31     *
32     * @author Stefan A. Krueger
33     */
34  public class SwitchLanguageDialog extends JDialog {  public class SwitchLanguageDialog extends JDialog {
35          protected Logger LOGGER = Logger.getLogger(SwitchLanguageDialog.class);          protected Logger LOGGER = Logger.getLogger(SwitchLanguageDialog.class);
36    
# Line 54  public class SwitchLanguageDialog extend Line 60  public class SwitchLanguageDialog extend
60           * @param owner           * @param owner
61           * @param atlasConfig           * @param atlasConfig
62           */           */
63          public SwitchLanguageDialog(final Component owner, final List<String> languages) {          public SwitchLanguageDialog(final Component owner,
64                  super(owner instanceof Window ? (Window)owner : SwingUtil.getParentWindow(owner));                          final List<String> languages) {
65                    super(owner instanceof Window ? (Window) owner : SwingUtil
66                                    .getParentWindow(owner));
67                  this.languages = languages;                  this.languages = languages;
68    
69                  Translation.setActiveLang(languages.get(0));                  Translation.setActiveLang(languages.get(0));
# Line 67  public class SwitchLanguageDialog extend Line 75  public class SwitchLanguageDialog extend
75                  }                  }
76    
77                  initialize();                  initialize();
   
                 setVisible(true);  
78          }          }
79    
80          /**          /**
# Line 80  public class SwitchLanguageDialog extend Line 86  public class SwitchLanguageDialog extend
86                  this.setContentPane(getJContentPane());                  this.setContentPane(getJContentPane());
87                  setModal(true);                  setModal(true);
88                  SwingUtil.centerFrameOnScreenRandom(this);                  SwingUtil.centerFrameOnScreenRandom(this);
89                    
90                    setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE);
91                    
92                  pack();                  pack();
93          }          }
94    
# Line 176  public class SwitchLanguageDialog extend Line 185  public class SwitchLanguageDialog extend
185                          gridBagConstraints.insets = new Insets(0, 5, 0, 0);                          gridBagConstraints.insets = new Insets(0, 5, 0, 0);
186                          gridBagConstraints.gridy = 0;                          gridBagConstraints.gridy = 0;
187                          jLabel = new JLabel();                          jLabel = new JLabel();
188                          jLabel.setText("Select language: ");                          jLabel.setText("Select language: "); //i8n!?! Maybe replace with an icon of an index finger
189                          jPanel1 = new JPanel();                          jPanel1 = new JPanel();
190                          jPanel1.setLayout(new GridBagLayout());                          jPanel1.setLayout(new GridBagLayout());
191                          jPanel1.add(jLabel, gridBagConstraints);                          jPanel1.add(jLabel, gridBagConstraints);
# Line 231  public class SwitchLanguageDialog extend Line 240  public class SwitchLanguageDialog extend
240                                                  getJButton().setEnabled(false);                                                  getJButton().setEnabled(false);
241                                                  return;                                                  return;
242                                          }                                          }
243                                          Translation.setActiveLang(languages.get(jComboBox                                          
244                                                          .getSelectedIndex()));                                          String l = languages.get(jComboBox
245                                          getJButton().setEnabled(true);                                                          .getSelectedIndex());
246                                            try {
247                                                    Translation.setActiveLang(l);
248                                                    
249                                                    getJButton().setEnabled(true);
250                                            } catch (java.lang.IllegalArgumentException ee) {
251                                                    LOGGER.warn("The language "+l+" is not valid",ee);
252                                                    getJButton().setEnabled(false);
253                                            }
254                                            
255                                  }                                  }
256    
257                          });                          });

Legend:
Removed from v.124  
changed lines
  Added in v.140

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26