Search in sources :

Example 11 with XmlAttributes

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

the class AssociationWriter method setIsHidden.

public void setIsHidden(boolean isHidden) throws CommandException {
    XmlAttributes attr;
    attr = new XmlAttributes();
    attr.add(ATTRIBUTE_VALUE, isHidden ? VALUE_TRUE : VALUE_FALSE);
    try {
        out.writeStandAloneElement(ELEMENT_IS_HIDDEN, attr);
    } catch (IOException e) {
        throw new CommandException(e);
    }
}
Also used : XmlAttributes(com.mucommander.commons.util.xml.XmlAttributes) IOException(java.io.IOException)

Example 12 with XmlAttributes

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

the class CommandWriter method addCommand.

/**
 * Writes the specified command's XML description.
 * @param  command          command that should be written.
 * @throws CommandException if an error occurs.
 */
public void addCommand(Command command) throws CommandException {
    XmlAttributes attributes;
    // Builds the XML description of the command.
    attributes = new XmlAttributes();
    attributes.add(ATTRIBUTE_ALIAS, command.getAlias());
    attributes.add(ATTRIBUTE_VALUE, command.getCommand());
    if (command.getType().toString() != null)
        attributes.add(ATTRIBUTE_TYPE, command.getType().toString());
    if (command.isDisplayNameSet())
        attributes.add(ATTRIBUTE_DISPLAY, command.getDisplayName());
    // Writes the XML description.
    try {
        out.writeStandAloneElement(ELEMENT_COMMAND, attributes);
    } catch (IOException e) {
        throw new CommandException(e);
    }
}
Also used : XmlAttributes(com.mucommander.commons.util.xml.XmlAttributes) IOException(java.io.IOException)

Example 13 with XmlAttributes

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

the class ThemeWriter method getColorAttributes.

/**
 * Returns the XML attributes describing the specified color.
 * @param  color color to described as XML attributes.
 * @return       the XML attributes describing the specified color.
 */
private static XmlAttributes getColorAttributes(Color color) {
    // Stores the color's description.
    XmlAttributes attributes;
    // Used to build the color's string representation.
    StringBuilder buffer;
    buffer = new StringBuilder();
    // Red component.
    if (color.getRed() < 16)
        buffer.append('0');
    buffer.append(Integer.toString(color.getRed(), 16));
    // Green component.
    if (color.getGreen() < 16)
        buffer.append('0');
    buffer.append(Integer.toString(color.getGreen(), 16));
    // Blue component.
    if (color.getBlue() < 16)
        buffer.append('0');
    buffer.append(Integer.toString(color.getBlue(), 16));
    // Builds the XML attributes.
    attributes = new XmlAttributes();
    attributes.add(ATTRIBUTE_COLOR, buffer.toString());
    if (color.getAlpha() != 255) {
        buffer.setLength(0);
        if (color.getAlpha() < 16)
            buffer.append('0');
        buffer.append(Integer.toString(color.getAlpha(), 16));
        attributes.add(ATTRIBUTE_ALPHA, buffer.toString());
    }
    return attributes;
}
Also used : XmlAttributes(com.mucommander.commons.util.xml.XmlAttributes)

Aggregations

XmlAttributes (com.mucommander.commons.util.xml.XmlAttributes)13 IOException (java.io.IOException)9 XmlWriter (com.mucommander.commons.util.xml.XmlWriter)2 Credentials (com.mucommander.commons.file.Credentials)1 FileURL (com.mucommander.commons.file.FileURL)1