/[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 207 by alfonx, Thu Jul 9 20:14:21 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(SwingUtil.getParentWindow(owner));
66                  this.languages = languages;                  this.languages = languages;
67    
68                  Translation.setActiveLang(languages.get(0));                  Translation.setActiveLang(languages.get(0));
# Line 67  public class SwitchLanguageDialog extend Line 74  public class SwitchLanguageDialog extend
74                  }                  }
75    
76                  initialize();                  initialize();
   
                 setVisible(true);  
77          }          }
78    
79          /**          /**
# Line 80  public class SwitchLanguageDialog extend Line 85  public class SwitchLanguageDialog extend
85                  this.setContentPane(getJContentPane());                  this.setContentPane(getJContentPane());
86                  setModal(true);                  setModal(true);
87                  SwingUtil.centerFrameOnScreenRandom(this);                  SwingUtil.centerFrameOnScreenRandom(this);
88    
89                    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
90    
91                  pack();                  pack();
92          }          }
93    
# Line 176  public class SwitchLanguageDialog extend Line 184  public class SwitchLanguageDialog extend
184                          gridBagConstraints.insets = new Insets(0, 5, 0, 0);                          gridBagConstraints.insets = new Insets(0, 5, 0, 0);
185                          gridBagConstraints.gridy = 0;                          gridBagConstraints.gridy = 0;
186                          jLabel = new JLabel();                          jLabel = new JLabel();
187                          jLabel.setText("Select language: ");                          jLabel.setText("Select language: "); // i8n!?! Maybe replace with an
188                                                                                                            // 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.getSelectedIndex());
245                                          getJButton().setEnabled(true);                                          try {
246                                                    Translation.setActiveLang(l);
247    
248                                                    getJButton().setEnabled(true);
249                                            } catch (java.lang.IllegalArgumentException ee) {
250                                                    LOGGER.warn("The language " + l + " is not valid", ee);
251                                                    getJButton().setEnabled(false);
252                                            }
253    
254                                  }                                  }
255    
256                          });                          });

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26