Ignore:
Timestamp:
2005-02-17T14:45:29+13:00 (19 years ago)
Author:
mdewsnip
Message:

Added font selection field (for users that need a non-standard font with more Unicode support).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r8992 r9075  
    3434import javax.swing.*;
    3535import javax.swing.event.*;
     36import javax.swing.plaf.*;
    3637import org.greenstone.gatherer.Configuration;
    3738import org.greenstone.gatherer.DebugStream;
     
    7778    private JComboBox servlet_combobox; // GS3
    7879    private JComboBox site_combobox; // GS3
    79     private JLabel email_label;
    80     private JLabel language_label;
    81     private JLabel library_path_label;
    82     private JLabel predefined_label;
    83     private JLabel program_label;
    84     private JLabel proxy_host_label;
    85     private JLabel proxy_port_label;
    86     private JLabel title_label;
    87     private JPanel servlet_pane;
    8880    private JRadioButton assistant_mode_radio_button;
    8981    private JRadioButton expert_mode_radio_button;
     
    9385    private JTabbedPane tab_pane;
    9486    private JTextArea mode_description_textarea;
     87    private JTextField font_field;
    9588    private JTextField library_path_field;
    9689    private JTextField program_field;
     
    180173    JPanel program_pane = new JPanel();
    181174    program_pane.setPreferredSize(ROW_SIZE);
    182     program_label = new JLabel();
     175    JLabel program_label = new JLabel();
    183176    program_label.setPreferredSize(LABEL_SIZE);
    184177    Dictionary.registerText(program_label, "Preferences.Connection.ProgramCommand");
     
    189182    JPanel library_path_pane = new JPanel();
    190183    library_path_pane.setPreferredSize(ROW_SIZE);
    191     library_path_label = new JLabel();
     184    JLabel library_path_label = new JLabel();
    192185    library_path_label.setPreferredSize(LABEL_SIZE);
    193186    String library_url_string = "";
     
    208201    JPanel site_pane = null;
    209202    JLabel site_label = null;
     203    JPanel servlet_pane = null;
    210204    JLabel servlet_label = null;
    211205    if (Gatherer.GS3) {
     
    271265    JPanel proxy_host_pane = new JPanel();
    272266    proxy_host_pane.setPreferredSize(ROW_SIZE);
    273     proxy_host_label = new JLabel();
     267    JLabel proxy_host_label = new JLabel();
    274268    proxy_host_label.setPreferredSize(LABEL_SIZE);
    275269    Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host");
     
    279273    JPanel proxy_port_pane = new JPanel();
    280274    proxy_port_pane.setPreferredSize(ROW_SIZE);
    281     proxy_port_label = new JLabel();
     275    JLabel proxy_port_label = new JLabel();
    282276    proxy_port_label.setPreferredSize(LABEL_SIZE);
    283277    Dictionary.registerText(proxy_port_label, "Preferences.Connection.Proxy_Port");
     
    365359    // Users email
    366360    JPanel email_pane = new JPanel();
    367     email_label = new JLabel();
     361    JLabel email_label = new JLabel();
    368362    email_label.setPreferredSize(LABEL_SIZE);
    369363    Dictionary.registerText(email_label, "Preferences.General.Email");
     
    372366    Dictionary.registerTooltip(email_field, "Preferences.General.Email_Tooltip");
    373367
     368    // Font selection
     369    JPanel font_pane = new JPanel();
     370    JLabel font_label = new JLabel();
     371    font_label.setPreferredSize(LABEL_SIZE);
     372    Dictionary.registerText(font_label, "Preferences.General.Font");
     373    font_field = new JTextField(Configuration.getString("general.font", true));
     374    Dictionary.registerTooltip(font_field, "Preferences.General.Font_Tooltip");
     375
    374376    // Extracted metadata
    375377    view_extracted_metadata_checkbox = new JCheckBox();
     
    390392    // Language
    391393    JPanel language_pane = new JPanel();
    392     language_label = new JLabel();
     394    JLabel language_label = new JLabel();
    393395    language_label.setPreferredSize(LABEL_SIZE);
    394396    Dictionary.registerText(language_label, "Preferences.General.Interface_Language");
     
    397399    // Try to locate and select the current language
    398400    String language_code = Configuration.getLanguage();
    399     for(int b = 0; b < language_combobox.getItemCount(); b++) {
     401    for (int b = 0; b < language_combobox.getItemCount(); b++) {
    400402        DictionaryEntry entry = (DictionaryEntry) language_combobox.getItemAt(b);
    401         if(language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) {
     403        if (language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) {
    402404        language_combobox.setSelectedIndex(b);
    403         }
    404     }
    405 
    406     // Connect
    407     language_combobox.addActionListener(new LanguageComboboxListener());
     405        break;
     406        }
     407    }
    408408
    409409    // Layout
     
    416416    language_pane.add(language_combobox, BorderLayout.CENTER);
    417417
     418    font_pane.setLayout(new BorderLayout());
     419    font_pane.add(font_label, BorderLayout.WEST);
     420    font_pane.add(font_field, BorderLayout.CENTER);
     421
    418422    general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    419423    general_pane.setLayout(new GridLayout(5,1,0,5));
    420424    general_pane.add(email_pane);
    421425    general_pane.add(language_pane);
     426    general_pane.add(font_pane);
    422427    general_pane.add(view_extracted_metadata_checkbox);
    423428    general_pane.add(show_file_size_checkbox);
     
    529534    JPanel workflow_preferences_pane = new JPanel();
    530535    JPanel checklist_pane = new JPanel();
    531     title_label = new JLabel();
     536    JLabel title_label = new JLabel();
    532537    title_label.setPreferredSize(ROW_SIZE);
    533538    Dictionary.registerText(title_label, "Preferences.Workflow.Title");
     
    559564
    560565    JPanel predefined_pane = new JPanel();
    561     predefined_label = new JLabel();
     566    JLabel predefined_label = new JLabel();
    562567    Dictionary.registerText(predefined_label, "Preferences.Workflow.Predefined.Label");
    563568    JComboBox predefined_combobox = new JComboBox(predefined);
     
    647652        Configuration.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected());
    648653
     654        // Two options requiring restarting the GLI to apply: interface font, and interface language
     655        boolean restart_required = false;
     656
     657        // GLI interface font
     658        String current_font = Configuration.getString("general.font", true);
     659        if (!current_font.equals(font_field.getText())) {
     660        Configuration.setString("general.font", true, font_field.getText());
     661        restart_required = true;
     662        }
     663
     664        // GLI interface language
    649665        String current_lang = Configuration.getLanguage();
    650         String new_lang = ((DictionaryEntry)language_combobox.getSelectedItem()).getLocale().getLanguage();
    651         if (!current_lang.equals(new_lang)) {
    652         Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry)language_combobox.getSelectedItem()).getLocale());
    653         // delete the plugins and classifiers.dat files
     666        if (!current_lang.equals(((DictionaryEntry) language_combobox.getSelectedItem()).getLocale().getLanguage())) {
     667        Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry) language_combobox.getSelectedItem()).getLocale());
     668        restart_required = true;
     669
     670        // Delete the plugins.dat and classifiers.dat files
    654671        PluginManager.clearPluginCache();
    655672        ClassifierManager.clearClassifierCache();
     673        }
     674
     675        // Inform the user that a restart is required, if necessary
     676        if (restart_required) {
     677        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.General.Restart_Required"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
    656678        }
    657679
     
    804826    }
    805827
    806     private class LanguageComboboxListener
    807     implements ActionListener {
    808     public void actionPerformed(ActionEvent event) {
    809         // Retrieve the entry
    810         DictionaryEntry entry = (DictionaryEntry) language_combobox.getSelectedItem();
    811         if (entry != null) {
    812         // Display message
    813         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.General.Restart_Required"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
    814         }
    815     }
    816     }
    817828
    818829    private class SiteComboboxListener
Note: See TracChangeset for help on using the changeset viewer.