Example usage for com.google.gwt.dom.client OptionElement removeClassName

List of usage examples for com.google.gwt.dom.client OptionElement removeClassName

Introduction

In this page you can find the example usage for com.google.gwt.dom.client OptionElement removeClassName.

Prototype

@Override
    public boolean removeClassName(String className) 

Source Link

Usage

From source file:org.xwiki.gwt.wysiwyg.client.plugin.style.StylePlugin.java

License:Open Source License

/**
 * Updates the selected state of all the options in the specified list.
 * /*from w w w . j a va 2  s  .c om*/
 * @param styleNameOptions the list of style name options to update
 * @param styleNameCommand the command used to retrieve the list of applied style names
 */
private void update(List<OptionElement> styleNameOptions, Command styleNameCommand) {
    // Ignore if the list of options is empty.
    if (styleNameOptions.size() == 0) {
        return;
    }

    // Check if the style name picker needs to be updated.
    String appliedStyleNames = getTextArea().getCommandManager().getStringValue(styleNameCommand);
    String previouslyAppliedStyleNames = previousValue.get(styleNameCommand);
    if (appliedStyleNames.equals(previouslyAppliedStyleNames)) {
        return;
    }
    previousValue.put(styleNameCommand, appliedStyleNames);

    // Update the style name picker.
    Set<String> styleNames = new HashSet<String>(Arrays.asList(appliedStyleNames.split("\\s+")));
    for (OptionElement option : styleNameOptions) {
        if (styleNames.contains(option.getValue())) {
            option.addClassName(SELECTED);
        } else {
            option.removeClassName(SELECTED);
        }
    }

    // Some browsers (e.g. Internet Explorer) don't update the selected options if we don't redisplay the select.
    styleNamePicker.getElement().getStyle().setDisplay(Display.NONE);
    styleNamePicker.getElement().getStyle().clearDisplay();
}