Search in sources :

Example 1 with XmlWriter

use of com.mucommander.commons.util.xml.XmlWriter in project mucommander by mucommander.

the class ShellHistoryWriter method write.

/**
 * Writes the content of the {@link com.mucommander.shell.ShellHistoryManager} to the specified output stream.
 * @param stream where to save the shell history.
 */
public static void write(OutputStream stream) {
    // Iterator on the shell history.
    Iterator<String> history;
    // Where to write the shell history to.
    XmlWriter out;
    // Initialises writing.
    history = ShellHistoryManager.getHistoryIterator();
    try {
        // Opens the file for writing.
        out = new XmlWriter(stream);
        // Version the file
        XmlAttributes attributes = new XmlAttributes();
        attributes.add(ATTRIBUTE_VERSION, RuntimeConstants.VERSION);
        out.startElement(ROOT_ELEMENT, attributes);
        out.println();
        // Writes the content of the shell history.
        while (history.hasNext()) {
            out.startElement(COMMAND_ELEMENT);
            out.writeCData(history.next());
            out.endElement(COMMAND_ELEMENT);
        }
        out.endElement(ROOT_ELEMENT);
    } catch (Exception e) {
        LOGGER.debug("Failed to write shell history", e);
    }
}
Also used : XmlAttributes(com.mucommander.commons.util.xml.XmlAttributes) XmlWriter(com.mucommander.commons.util.xml.XmlWriter)

Example 2 with XmlWriter

use of com.mucommander.commons.util.xml.XmlWriter in project mucommander by mucommander.

the class CredentialsWriter method write.

/**
 * Writes the credentials XML file in the user's preferences folder.
 * This method should only be called by {@link CredentialsManager}.
 */
static void write(OutputStream stream) throws IOException {
    XmlWriter out = new XmlWriter(stream);
    // Root element, add the encryption method used
    XmlAttributes attributes = new XmlAttributes();
    attributes.add(ATTRIBUTE_ENCRYPTION, WEAK_ENCRYPTION_METHOD);
    // Version the file
    attributes.add(ATTRIBUTE_VERSION, RuntimeConstants.VERSION);
    out.startElement(ELEMENT_ROOT, attributes);
    out.println();
    Iterator<CredentialsMapping> iterator = CredentialsManager.getPersistentCredentialMappings().iterator();
    CredentialsMapping credentialsMapping;
    FileURL realm;
    Enumeration<String> propertyKeys;
    String name;
    while (iterator.hasNext()) {
        credentialsMapping = iterator.next();
        realm = credentialsMapping.getRealm();
        // Start credentials element
        out.startElement(ELEMENT_CREDENTIALS);
        out.println();
        // Write URL
        out.startElement(ELEMENT_URL);
        out.writeCData(realm.toString(false));
        out.endElement(ELEMENT_URL);
        Credentials credentials = credentialsMapping.getCredentials();
        // Write login
        out.startElement(ELEMENT_LOGIN);
        out.writeCData(credentials.getLogin());
        out.endElement(ELEMENT_LOGIN);
        // Write password (XOR encrypted)
        out.startElement(ELEMENT_PASSWORD);
        out.writeCData(XORCipher.encryptXORBase64(credentials.getPassword()));
        out.endElement(ELEMENT_PASSWORD);
        // Write properties, each property is stored in a separate 'property' element
        propertyKeys = realm.getPropertyNames();
        while (propertyKeys.hasMoreElements()) {
            name = propertyKeys.nextElement();
            attributes = new XmlAttributes();
            attributes.add(ATTRIBUTE_NAME, name);
            attributes.add(ATTRIBUTE_VALUE, realm.getProperty(name));
            out.startElement(ELEMENT_PROPERTY, attributes);
            out.endElement(ELEMENT_PROPERTY);
        }
        // End credentials element
        out.endElement(ELEMENT_CREDENTIALS);
    }
    // End root element
    out.endElement(ELEMENT_ROOT);
}
Also used : FileURL(com.mucommander.commons.file.FileURL) XmlAttributes(com.mucommander.commons.util.xml.XmlAttributes) XmlWriter(com.mucommander.commons.util.xml.XmlWriter) Credentials(com.mucommander.commons.file.Credentials)

Example 3 with XmlWriter

use of com.mucommander.commons.util.xml.XmlWriter in project mucommander by mucommander.

the class ThemeWriter method write.

// - XML output ----------------------------------------------------------------------
// -----------------------------------------------------------------------------------
/**
 * Saves the specified theme to the specified output stream.
 * @param  theme       theme to save.
 * @param  stream      where to write the theme to.
 * @throws IOException thrown if any IO related error occurs.
 */
public static void write(ThemeData theme, OutputStream stream) throws IOException {
    XmlWriter out;
    out = new XmlWriter(stream);
    out.startElement(ELEMENT_ROOT);
    out.println();
    // - File table description ------------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_TABLE);
    out.println();
    // Global values.
    if (theme.isColorSet(Theme.FILE_TABLE_BORDER_COLOR))
        out.writeStandAloneElement(ELEMENT_BORDER, getColorAttributes(theme.getColor(Theme.FILE_TABLE_BORDER_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_BORDER_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_BORDER, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_BORDER_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_SELECTED_OUTLINE_COLOR))
        out.writeStandAloneElement(ELEMENT_OUTLINE, getColorAttributes(theme.getColor(Theme.FILE_TABLE_SELECTED_OUTLINE_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_SELECTED_OUTLINE_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_OUTLINE, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_SELECTED_OUTLINE_COLOR)));
    if (theme.isFontSet(Theme.FILE_TABLE_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.FILE_TABLE_FONT)));
    // Normal background colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.FILE_TABLE_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected background colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.FILE_TABLE_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_SELECTED_SECONDARY_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_SECONDARY_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_SELECTED_SECONDARY_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_SELECTED_SECONDARY_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_SECONDARY_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_SELECTED_SECONDARY_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    // Alternate background colors.
    out.startElement(ELEMENT_ALTERNATE);
    out.println();
    if (theme.isColorSet(Theme.FILE_TABLE_ALTERNATE_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_ALTERNATE_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_INACTIVE_ALTERNATE_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_INACTIVE_ALTERNATE_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_ALTERNATE);
    // Unmatched colors.
    out.startElement(ELEMENT_UNMATCHED);
    out.println();
    if (theme.isColorSet(Theme.FILE_TABLE_UNMATCHED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_UNMATCHED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_TABLE_UNMATCHED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.FILE_TABLE_UNMATCHED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_UNMATCHED);
    // Hidden files.
    out.startElement(ELEMENT_HIDDEN);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.HIDDEN_FILE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.HIDDEN_FILE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.HIDDEN_FILE_INACTIVE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.HIDDEN_FILE_INACTIVE_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.HIDDEN_FILE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.HIDDEN_FILE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.HIDDEN_FILE_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.HIDDEN_FILE_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_HIDDEN);
    // Folders.
    out.startElement(ELEMENT_FOLDER);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.FOLDER_INACTIVE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.FOLDER_INACTIVE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.FOLDER_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.FOLDER_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.FOLDER_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.FOLDER_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.FOLDER_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.FOLDER_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_FOLDER);
    // Archives.
    out.startElement(ELEMENT_ARCHIVE);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.ARCHIVE_INACTIVE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.ARCHIVE_INACTIVE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.ARCHIVE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.ARCHIVE_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.ARCHIVE_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.ARCHIVE_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.ARCHIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.ARCHIVE_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_ARCHIVE);
    // Symlink.
    out.startElement(ELEMENT_SYMLINK);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.SYMLINK_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.SYMLINK_INACTIVE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.SYMLINK_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SYMLINK_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.SYMLINK_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.SYMLINK_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.SYMLINK_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SYMLINK_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_SYMLINK);
    // Marked files.
    out.startElement(ELEMENT_MARKED);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.MARKED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.MARKED_INACTIVE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.MARKED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.MARKED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.MARKED_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.MARKED_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.MARKED_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.MARKED_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_MARKED);
    // Plain files.
    out.startElement(ELEMENT_FILE);
    out.println();
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.FILE_INACTIVE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.FILE_INACTIVE_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.FILE_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.FILE_INACTIVE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_INACTIVE_FOREGROUND, getColorAttributes(theme.getColor(Theme.FILE_INACTIVE_SELECTED_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.FILE_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.FILE_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_FILE);
    out.endElement(ELEMENT_TABLE);
    // - Shell description ----------------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_SHELL);
    out.println();
    if (theme.isFontSet(Theme.SHELL_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.SHELL_FONT)));
    // Normal colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.SHELL_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.SHELL_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.SHELL_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SHELL_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.SHELL_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.SHELL_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.SHELL_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SHELL_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_SHELL);
    // - Shell history description ---------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_SHELL_HISTORY);
    out.println();
    if (theme.isFontSet(Theme.SHELL_HISTORY_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.SHELL_HISTORY_FONT)));
    // Normal colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.SHELL_HISTORY_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.SHELL_HISTORY_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.SHELL_HISTORY_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SHELL_HISTORY_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.SHELL_HISTORY_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.SHELL_HISTORY_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.SHELL_HISTORY_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.SHELL_HISTORY_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_SHELL_HISTORY);
    // - Editor description ----------------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_EDITOR);
    out.println();
    if (theme.isFontSet(Theme.EDITOR_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.EDITOR_FONT)));
    // Normal colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.EDITOR_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.EDITOR_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.EDITOR_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.EDITOR_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.EDITOR_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.EDITOR_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.EDITOR_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.EDITOR_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_EDITOR);
    // - Location bar description ----------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_LOCATION_BAR);
    out.println();
    if (theme.isFontSet(Theme.LOCATION_BAR_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.LOCATION_BAR_FONT)));
    if (theme.isColorSet(Theme.LOCATION_BAR_PROGRESS_COLOR))
        out.writeStandAloneElement(ELEMENT_PROGRESS, getColorAttributes(theme.getColor(Theme.LOCATION_BAR_PROGRESS_COLOR)));
    // Normal colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.LOCATION_BAR_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.LOCATION_BAR_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.LOCATION_BAR_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.LOCATION_BAR_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.LOCATION_BAR_SELECTED_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.LOCATION_BAR_SELECTED_FOREGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_LOCATION_BAR);
    // - Volume label description ----------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_STATUS_BAR);
    out.println();
    // Font.
    if (theme.isFontSet(Theme.STATUS_BAR_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.STATUS_BAR_FONT)));
    // Colors.
    if (theme.isColorSet(Theme.STATUS_BAR_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.STATUS_BAR_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.STATUS_BAR_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.STATUS_BAR_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.STATUS_BAR_BORDER_COLOR))
        out.writeStandAloneElement(ELEMENT_BORDER, getColorAttributes(theme.getColor(Theme.STATUS_BAR_BORDER_COLOR)));
    if (theme.isColorSet(Theme.STATUS_BAR_OK_COLOR))
        out.writeStandAloneElement(ELEMENT_OK, getColorAttributes(theme.getColor(Theme.STATUS_BAR_OK_COLOR)));
    if (theme.isColorSet(Theme.STATUS_BAR_WARNING_COLOR))
        out.writeStandAloneElement(ELEMENT_WARNING, getColorAttributes(theme.getColor(Theme.STATUS_BAR_WARNING_COLOR)));
    if (theme.isColorSet(Theme.STATUS_BAR_CRITICAL_COLOR))
        out.writeStandAloneElement(ELEMENT_CRITICAL, getColorAttributes(theme.getColor(Theme.STATUS_BAR_CRITICAL_COLOR)));
    out.endElement(ELEMENT_STATUS_BAR);
    // - Quick list label description ----------------------------------------------------
    // -------------------------------------------------------------------------------
    out.startElement(ELEMENT_QUICK_LIST);
    out.println();
    // Quick list header
    out.startElement(ELEMENT_HEADER);
    out.println();
    // Font.
    if (theme.isFontSet(Theme.QUICK_LIST_HEADER_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.QUICK_LIST_HEADER_FONT)));
    // Colors.
    if (theme.isColorSet(Theme.QUICK_LIST_HEADER_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_HEADER_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.QUICK_LIST_HEADER_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_HEADER_BACKGROUND_COLOR)));
    if (theme.isColorSet(Theme.QUICK_LIST_HEADER_SECONDARY_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_SECONDARY_BACKGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_HEADER_SECONDARY_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_HEADER);
    // Quick list item
    out.startElement(ELEMENT_ITEM);
    out.println();
    // Font.
    if (theme.isFontSet(Theme.QUICK_LIST_ITEM_FONT))
        out.writeStandAloneElement(ELEMENT_FONT, getFontAttributes(theme.getFont(Theme.QUICK_LIST_ITEM_FONT)));
    // Colors.
    // Normal colors.
    out.startElement(ELEMENT_NORMAL);
    out.println();
    if (theme.isColorSet(Theme.QUICK_LIST_ITEM_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_ITEM_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.QUICK_LIST_ITEM_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_ITEM_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_NORMAL);
    // Selected colors.
    out.startElement(ELEMENT_SELECTED);
    out.println();
    if (theme.isColorSet(Theme.QUICK_LIST_SELECTED_ITEM_FOREGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_FOREGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_SELECTED_ITEM_FOREGROUND_COLOR)));
    if (theme.isColorSet(Theme.QUICK_LIST_SELECTED_ITEM_BACKGROUND_COLOR))
        out.writeStandAloneElement(ELEMENT_BACKGROUND, getColorAttributes(theme.getColor(Theme.QUICK_LIST_SELECTED_ITEM_BACKGROUND_COLOR)));
    out.endElement(ELEMENT_SELECTED);
    out.endElement(ELEMENT_ITEM);
    out.endElement(ELEMENT_QUICK_LIST);
    out.endElement(ELEMENT_ROOT);
}
Also used : XmlWriter(com.mucommander.commons.util.xml.XmlWriter)

Aggregations

XmlWriter (com.mucommander.commons.util.xml.XmlWriter)3 XmlAttributes (com.mucommander.commons.util.xml.XmlAttributes)2 Credentials (com.mucommander.commons.file.Credentials)1 FileURL (com.mucommander.commons.file.FileURL)1