Ignore:
Timestamp:
2003-09-26T14:58:33+12:00 (21 years ago)
Author:
mdewsnip
Message:

Many more tooltips and improvements to the Dictionary. Still more to come.

File:
1 edited

Legend:

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

    r5527 r5536  
    99import javax.swing.event.*;
    1010import org.greenstone.gatherer.Configuration;
     11import org.greenstone.gatherer.Dictionary;
    1112import org.greenstone.gatherer.Gatherer;
    1213import org.greenstone.gatherer.checklist.CheckList;
     
    6162    this.self = this;
    6263    setSize(SIZE);
    63     setTitle("Preferences");
     64    Dictionary.registerText(this, "Preferences");
    6465    setJMenuBar(new SimpleMenuBar("preferences"));
     66
    6567    // Creation
    6668    JPanel content_pane = (JPanel) getContentPane();
    6769    tab_pane = new JTabbedPane();
    68     tab_pane.add("Preferences.General", createGeneralPreferences());
     70    JPanel general_preferences = createGeneralPreferences();
     71    tab_pane.add("Preferences.General", general_preferences);
    6972    tab_pane.add("Preferences.Workflow", createWorkflowPreferences());
    7073    tab_pane.add("Preferences.Connection", createConnectionPreferences());
    7174    tab_pane.add("Preferences.Warnings", createWarningPreferences());
     75    Dictionary.register(tab_pane);
    7276
    7377    JPanel button_pane = new JPanel();
    74     ok_button = new JButton("General.OK");
    75     apply_button = new JButton("General.Apply");
    76     cancel_button = new JButton("General.Cancel");
     78    ok_button = new JButton();
     79    Dictionary.registerBoth(ok_button, "General.OK", "General.OK_Tooltip");
     80    apply_button = new JButton();
     81    Dictionary.registerBoth(apply_button, "General.Apply", "General.Apply_Tooltip");
     82    cancel_button = new JButton();
     83    Dictionary.registerBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
     84
    7785    // Connection
    78     Gatherer.dictionary.register(this, null, false);
    79     Gatherer.dictionary.register(tab_pane, null, false);
    80     Gatherer.dictionary.register(ok_button, null, false);
    81     Gatherer.dictionary.register(apply_button, null, false);
    82     Gatherer.dictionary.register(cancel_button, null, false);
    8386    ok_button.addActionListener(new OKButtonListener(true));
    8487    apply_button.addActionListener(new OKButtonListener(false));
    8588    cancel_button.addActionListener(new CancelButtonListener());
     89
    8690    // Layout
    8791    button_pane.setBorder(BorderFactory.createEmptyBorder(5,2,2,2));
     
    114118    JPanel library_path_pane = new JPanel();
    115119    library_path_pane.setPreferredSize(ROW_SIZE);
    116     library_path_label = new JLabel("Preferences.Connection.Library_Path");
     120    library_path_label = new JLabel();
    117121    library_path_label.setPreferredSize(LABEL_SIZE);
     122    Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path");
    118123    library_path_field = new JTextField(Gatherer.config.getString("general.exec_address", true));
    119124    library_path_field.setCaretPosition(0);
     125    Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip");
    120126
    121127    boolean currently_enabled = Gatherer.config.get("general.use_proxy", true);
    122128    // Creation
    123129    JPanel connection_pane = new JPanel();
    124     use_proxy_checkbox = new JCheckBox("Preferences.Connection.Use_Proxy", currently_enabled);
     130    use_proxy_checkbox = new JCheckBox();
     131    use_proxy_checkbox.setSelected(currently_enabled);
     132    Dictionary.registerText(use_proxy_checkbox, "Preferences.Connection.Use_Proxy");
     133
    125134    use_proxy_checkbox.setPreferredSize(ROW_SIZE);
    126135    JPanel proxy_host_pane = new JPanel();
    127136    proxy_host_pane.setPreferredSize(ROW_SIZE);
    128     proxy_host_label = new JLabel("Preferences.Connection.Proxy_Host");
     137    proxy_host_label = new JLabel();
    129138    proxy_host_label.setPreferredSize(LABEL_SIZE);
     139    Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host");
    130140    proxy_host_field = new JTextField(Gatherer.config.getString("general.proxy_host", true));
    131141    proxy_host_field.setEnabled(currently_enabled);
     142    Dictionary.registerTooltip(proxy_host_field, "Preferences.Connection.Proxy_Host_Tooltip");
    132143    JPanel proxy_port_pane = new JPanel();
    133144    proxy_port_pane.setPreferredSize(ROW_SIZE);
    134     proxy_port_label = new JLabel("Preferences.Connection.Proxy_Port");
     145    proxy_port_label = new JLabel();
    135146    proxy_port_label.setPreferredSize(LABEL_SIZE);
     147    Dictionary.registerText(proxy_port_label, "Preferences.Connection.Proxy_Port");
    136148    proxy_port_field = new NumberField(Gatherer.config.getString("general.proxy_port", true));
    137149    proxy_port_field.setEnabled(currently_enabled);
     150    Dictionary.registerTooltip(proxy_port_field, "Preferences.Connection.Proxy_Port_Tooltip");
    138151
    139152    // Connection
    140     Gatherer.dictionary.register(library_path_label, null, false);
    141     Gatherer.dictionary.register(use_proxy_checkbox, null, false);
    142     Gatherer.dictionary.register(proxy_host_label, null, false);
    143     Gatherer.dictionary.register(proxy_port_label, null, false);
    144153    use_proxy_checkbox.addActionListener(new UseProxyListener());
    145154
     
    214223
    215224    // Extracted metadata
    216     view_extracted_metadata_checkbox = new JCheckBox("Preferences.General.View_Extracted_Metadata", false);
     225    view_extracted_metadata_checkbox = new JCheckBox();
     226    view_extracted_metadata_checkbox.setSelected(false);
     227    Dictionary.registerText(view_extracted_metadata_checkbox, "Preferences.General.View_Extracted_Metadata");
    217228    if (Gatherer.config.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC)) {
    218229        view_extracted_metadata_checkbox.setSelected(true);
     
    220231
    221232    // Show file sizes
    222     show_file_size_checkbox = new JCheckBox("Preferences.General.Show_File_Size", false);
     233    show_file_size_checkbox = new JCheckBox();
     234    show_file_size_checkbox.setSelected(false);
     235    Dictionary.registerText(show_file_size_checkbox, "Preferences.General.Show_File_Size");
    223236    if (Gatherer.config.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC)) {
    224237        show_file_size_checkbox.setSelected(true);
     
    227240    // Language
    228241    JPanel language_pane = new JPanel();
    229     language_label = new JLabel("Preferences.General.Interface_Language");
     242    language_label = new JLabel();
    230243    language_label.setPreferredSize(LABEL_SIZE);
     244    Dictionary.registerText(language_label, "Preferences.General.Interface_Language");
    231245    language_combobox = new JComboBox(dictionary_model.toArray());
    232246
    233247    // Connect
    234     Gatherer.dictionary.register(view_extracted_metadata_checkbox, null, false);
    235     Gatherer.dictionary.register(show_file_size_checkbox, null, false);
    236     Gatherer.dictionary.register(language_label, null, false);
    237248    language_combobox.addActionListener(new LanguageComboboxListener());
    238249
     
    260271        String value = (String) warning_preferences.get(property);
    261272        // Remove 'warning.'
    262         String title = Gatherer.dictionary.get(property.substring(8) + ".Title");
     273        String title = Dictionary.newget(property.substring(8) + ".Title");
    263274        Entry entry = new Entry(title, value.equalsIgnoreCase(TRUE));
    264275        entry.setProperty(property);
     
    277288
    278289    private JPanel createWorkflowPreferences() {
    279     // Read in the predefined configurations file.
     290    // Read in the predefined configurations file
    280291    Vector predefined = new Vector();
    281292    Document predefined_document = Utility.parse("xml/workflows.xml", true);
     
    285296        predefined.add(new WorkflowElementWrapper((Element)workflow_elements.item(i)));
    286297    }
     298
    287299    // Creation
    288300    JPanel workflow_preferences_pane = new JPanel();
    289301    JPanel checklist_pane = new JPanel();
    290     title_label = new JLabel("Preferences.Workflow.Title");
     302    title_label = new JLabel();
    291303    title_label.setPreferredSize(ROW_SIZE);
    292     workflow_browse  = new JCheckBox("Preferences.Workflow.Browse",  Gatherer.config.get("workflow.browse", false));
     304    Dictionary.registerText(title_label, "Preferences.Workflow.Title");
     305
     306    workflow_browse = new JCheckBox();
     307    workflow_browse.setSelected(Gatherer.config.get("workflow.browse", false));
    293308    workflow_browse.setPreferredSize(ROW_SIZE);
    294     workflow_mirror  = new JCheckBox("Preferences.Workflow.Mirror",  Gatherer.config.get("workflow.mirror", false));
     309    Dictionary.registerText(workflow_browse, "Preferences.Workflow.Browse");
     310
     311    workflow_mirror = new JCheckBox();
     312    workflow_mirror.setSelected(Gatherer.config.get("workflow.mirror", false));
    295313    workflow_mirror.setPreferredSize(ROW_SIZE);
    296     workflow_gather  = new JCheckBox("Preferences.Workflow.Gather",  Gatherer.config.get("workflow.gather", false));
     314    Dictionary.registerText(workflow_mirror, "Preferences.Workflow.Mirror");
     315
     316    workflow_gather = new JCheckBox();
     317    workflow_gather.setSelected(Gatherer.config.get("workflow.gather", false));
    297318    workflow_gather.setPreferredSize(ROW_SIZE);
    298     workflow_enrich  = new JCheckBox("Preferences.Workflow.Enrich",  Gatherer.config.get("workflow.enrich", false));
     319    Dictionary.registerText(workflow_gather, "Preferences.Workflow.Gather");
     320
     321    workflow_enrich = new JCheckBox();
     322    workflow_enrich.setSelected(Gatherer.config.get("workflow.enrich", false));
    299323    workflow_enrich.setPreferredSize(ROW_SIZE);
    300     workflow_design  = new JCheckBox("Preferences.Workflow.Design",  Gatherer.config.get("workflow.design", false));
     324    Dictionary.registerText(workflow_enrich, "Preferences.Workflow.Enrich");
     325
     326    workflow_design = new JCheckBox();
     327    workflow_design.setSelected(Gatherer.config.get("workflow.design", false));
    301328    workflow_design.setPreferredSize(ROW_SIZE);
    302     workflow_export  = new JCheckBox("Preferences.Workflow.Export",  Gatherer.config.get("workflow.export", false));
     329    Dictionary.registerText(workflow_design, "Preferences.Workflow.Design");
     330
     331    workflow_export = new JCheckBox();
     332    workflow_export.setSelected(Gatherer.config.get("workflow.export", false));
    303333    workflow_export.setPreferredSize(ROW_SIZE);
    304     workflow_create  = new JCheckBox("Preferences.Workflow.Create",  Gatherer.config.get("workflow.create", false));
     334    Dictionary.registerText(workflow_export, "Preferences.Workflow.Export");
     335
     336    workflow_create = new JCheckBox();
     337    workflow_create.setSelected(Gatherer.config.get("workflow.create", false));
    305338    workflow_create.setPreferredSize(ROW_SIZE);
    306     workflow_preview = new JCheckBox("Preferences.Workflow.Preview", Gatherer.config.get("workflow.preview", false));
     339    Dictionary.registerText(workflow_create, "Preferences.Workflow.Create");
     340
     341    workflow_preview = new JCheckBox();
     342    workflow_preview.setSelected(Gatherer.config.get("workflow.preview", false));
    307343    workflow_preview.setPreferredSize(ROW_SIZE);
     344    Dictionary.registerText(workflow_preview, "Preferences.Workflow.Preview");
     345
    308346    JPanel predefined_pane = new JPanel();
    309     predefined_label = new JLabel("Preferences.Workflow.Predefined.Label");
     347    predefined_label = new JLabel();
    310348    predefined_label.setPreferredSize(new Dimension(150,25));
     349    Dictionary.registerText(predefined_label, "Preferences.Workflow.Predefined.Label");
    311350    JComboBox predefined_combobox = new JComboBox(predefined);
     351
    312352    // Connection
    313     Gatherer.dictionary.register(title_label, null, false);
    314     Gatherer.dictionary.register(workflow_browse, null, false);
    315     Gatherer.dictionary.register(workflow_mirror, null, false);
    316     Gatherer.dictionary.register(workflow_gather, null, false);
    317     Gatherer.dictionary.register(workflow_enrich, null, false);
    318     Gatherer.dictionary.register(workflow_design, null, false);
    319     Gatherer.dictionary.register(workflow_export, null, false);
    320     Gatherer.dictionary.register(workflow_create, null, false);
    321     Gatherer.dictionary.register(workflow_preview, null, false);
    322     Gatherer.dictionary.register(predefined_label, null, false);
    323353    predefined_combobox.addActionListener(new PredefinedActionListener());
     354
    324355    // Layout
    325356    checklist_pane.setLayout(new BoxLayout(checklist_pane, BoxLayout.Y_AXIS));
    326357    checklist_pane.add(title_label);
    327     if(Gatherer.config.get("workflow.browse", true)) {
     358    if (Gatherer.config.get("workflow.browse", true)) {
    328359        checklist_pane.add(workflow_browse);
    329360    }
    330     if(Gatherer.config.get("workflow.mirror", true)) {
     361    if (Gatherer.config.get("workflow.mirror", true)) {
    331362        checklist_pane.add(workflow_mirror);
    332363    }
    333     if(Gatherer.config.get("workflow.gather", true)) {
     364    if (Gatherer.config.get("workflow.gather", true)) {
    334365        checklist_pane.add(workflow_gather);
    335366    }
    336     if(Gatherer.config.get("workflow.enrich", true)) {
     367    if (Gatherer.config.get("workflow.enrich", true)) {
    337368        checklist_pane.add(workflow_enrich);
    338369    }
    339     if(Gatherer.config.get("workflow.design", true)) {
     370    if (Gatherer.config.get("workflow.design", true)) {
    340371        checklist_pane.add(workflow_design);
    341372    }
    342     if(Gatherer.config.get("workflow.export", true)) {
     373    if (Gatherer.config.get("workflow.export", true)) {
    343374        checklist_pane.add(workflow_export);
    344375    }
    345     if(Gatherer.config.get("workflow.create", true)) {
     376    if (Gatherer.config.get("workflow.create", true)) {
    346377        checklist_pane.add(workflow_create);
    347378    }
    348     if(Gatherer.config.get("workflow.preview", true)) {
     379    if (Gatherer.config.get("workflow.preview", true)) {
    349380        checklist_pane.add(workflow_preview);
    350381    }
     
    362393
    363394    public void dispose() {
    364     // Deregister dictionary components
    365 
    366     // Connection
    367     Gatherer.dictionary.deregister(library_path_label);
    368     Gatherer.dictionary.deregister(use_proxy_checkbox);
    369     Gatherer.dictionary.deregister(proxy_host_label);
    370     Gatherer.dictionary.deregister(proxy_port_label);
    371 
    372     // General
    373     Gatherer.dictionary.deregister(view_extracted_metadata_checkbox);
    374     Gatherer.dictionary.deregister(show_file_size_checkbox);
    375     Gatherer.dictionary.deregister(language_label);
    376 
    377     // Workflow
    378     Gatherer.dictionary.deregister(title_label);
    379     Gatherer.dictionary.deregister(workflow_browse);
    380     Gatherer.dictionary.deregister(workflow_mirror);
    381     Gatherer.dictionary.deregister(workflow_gather);
    382     Gatherer.dictionary.deregister(workflow_enrich);
    383     Gatherer.dictionary.deregister(workflow_design);
    384     Gatherer.dictionary.deregister(workflow_export);
    385     Gatherer.dictionary.deregister(workflow_create);
    386     Gatherer.dictionary.deregister(workflow_preview);
    387     Gatherer.dictionary.deregister(predefined_label);
    388 
    389     // Dialog
    390     Gatherer.dictionary.deregister(this);
    391     Gatherer.dictionary.deregister(tab_pane);
    392     Gatherer.dictionary.deregister(ok_button);
    393     Gatherer.dictionary.deregister(apply_button);
    394     Gatherer.dictionary.deregister(cancel_button);
    395395    // Dispose
    396396    super.dispose();
     
    534534        Gatherer.dictionary.changeDictionary(entry.getLocale());
    535535        // Display message
    536         JOptionPane.showMessageDialog(Gatherer.g_man, Gatherer.dictionary.get("Preferences.General.Restart_Required"), Gatherer.dictionary.get("Preferences.General.Restart_Required"), JOptionPane.WARNING_MESSAGE);
     536        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Preferences.General.Restart_Required"), Dictionary.newget("Preferences.General.Restart_Required"), JOptionPane.WARNING_MESSAGE);
    537537        }
    538538    }
Note: See TracChangeset for help on using the changeset viewer.