Changeset 9887


Ignore:
Timestamp:
2005-05-16T17:04:24+12:00 (19 years ago)
Author:
mdewsnip
Message:

Tidied up the way the Warnings preferences are done, in response to my recent config.xml file updating code.

File:
1 edited

Legend:

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

    r9374 r9887  
    496496    }
    497497
     498
    498499    /** The warning preferences are controlled through a checklist. */
    499     private JPanel createWarningPreferences() {
    500     // Retrieve all of the warning preferences settings.
    501     HashMap warning_preferences = Configuration.getAll("warning\\..*", true);
     500    private JPanel createWarningPreferences()
     501    {
    502502    warning_preferences_check_list = new CheckList(false);
    503     for(Iterator keys = warning_preferences.keySet().iterator(); keys.hasNext(); ) {
    504         String property = (String) keys.next();
    505         String value = (String) warning_preferences.get(property);
    506         // Remove 'warning.'
    507         String title = Dictionary.get(property.substring(8) + ".Title");
    508         CheckListEntry entry = new CheckListEntry(title, value.equalsIgnoreCase(TRUE));
    509         entry.setProperty(property);
    510         warning_preferences_check_list.addEntry(entry);
    511     }
    512     // Creation
     503
     504    // Read all the warnings from the general xml/config.xml file, and their values from the user config.xml file
     505    Document general_config_xml_file_document = Utility.parse("xml/config.xml", true);
     506    NodeList argument_elements_nodelist = general_config_xml_file_document.getDocumentElement().getElementsByTagName("Argument");
     507    for (int i = 0; i < argument_elements_nodelist.getLength(); i++) {
     508        Element argument_element = (Element) argument_elements_nodelist.item(i);
     509        String argument_element_name = argument_element.getAttribute("name");
     510        if (argument_element_name.startsWith("warning.")) {
     511        String warning_title = Dictionary.get(argument_element_name.substring("warning.".length()) + ".Title");
     512        boolean warning_enabled = Configuration.get(argument_element_name, true);
     513        CheckListEntry warning_entry = new CheckListEntry(warning_title, warning_enabled);
     514        warning_entry.setProperty(argument_element_name);
     515        warning_preferences_check_list.addEntry(warning_entry);
     516        }
     517    }
     518
    513519    JPanel warning_preferences_pane = new JPanel();
    514     // Connection
    515     // Layout
    516520    warning_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    517521    warning_preferences_pane.setLayout(new BorderLayout());
    518522    warning_preferences_pane.add(new JScrollPane(warning_preferences_check_list), BorderLayout.CENTER);
    519 
    520523    return warning_preferences_pane;
    521524    }
     525
    522526
    523527    private JPanel createWorkflowPreferences() {
Note: See TracChangeset for help on using the changeset viewer.