Example usage for com.google.gwt.user.client.ui RichTextArea getBasicFormatter

List of usage examples for com.google.gwt.user.client.ui RichTextArea getBasicFormatter

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui RichTextArea getBasicFormatter.

Prototype

@Deprecated
public BasicFormatter getBasicFormatter() 

Source Link

Document

Gets the basic rich text formatting interface.

Usage

From source file:cazcade.vortex.widgets.client.misc.toolbar.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 *
 * @param richText the rich text area to be controlled
 *///from w  w w  .j a v a  2s  .c o m
public RichTextToolbar(@Nonnull final RichTextArea richText, final boolean large) {
    super();
    this.richText = richText;
    basic = richText.getBasicFormatter();
    extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        if (large) {
            topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
            topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        }
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        if (large) {
            topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
            topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
            topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        }
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        if (large) {
            topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
        }
    }

    if (basic != null) {
        if (large) {
            bottomPanel.add(backColors = createColorList("Background"));
            bottomPanel.add(foreColors = createColorList("Foreground"));
        }
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these listeners for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyboardListener(listener);
        richText.addClickListener(listener);
    }
}

From source file:ch.unibas.medizin.osce.client.style.widgets.richtext.RichTextToolbar.java

License:Apache License

public RichTextToolbar(RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();
    outer.add(topPanel);//from  ww  w  . j  av a 2 s  . c o  m
    outer.add(bottomPanel);
    //      topPanel.setWidth("100%");
    //      bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());
        // We only use these handlers for updating status, so don't hook
        // them up
        // unless at least basic editing is supported.
        richText.addKeyUpHandler(handler);
        richText.addClickHandler(handler);
    }
}

From source file:com.appspot.codsallarts.client.texteditor.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 * //  ww  w.j ava 2s.  co m
 * @param richText the rich text area to be controlled
 */
public RichTextToolbar(RichTextArea richText, EditCompleteHandler parent) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();
    this.parent = parent;
    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fontSizes = createFontSizes());

        bottomPanel.add(saveButton = new Button("Save", handler));
        bottomPanel.add(cancelButton = new Button("Cancel", handler));

        // We only use these handlers for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyUpHandler(handler);
        richText.addClickHandler(handler);
    }
}

From source file:com.apress.progwt.client.college.gui.ext.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 * //  w ww.j  av  a 2 s  .  c o m
 * @param richText
 *            the rich text area to be controlled
 */
public RichTextToolbar(RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these listeners for updating status, so don't
        // hook them up
        // unless at least basic editing is supported.
        richText.addKeyboardListener(listener);
        richText.addClickListener(listener);
    }
}

From source file:com.arcbees.gquery.tooltip.client.widget.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 *
 * @param richText the rich text area to be controlled
 *//*from w  w w . j a  va 2 s  . co m*/
public RichTextToolbar(RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these handlers for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyUpHandler(handler);
        richText.addClickHandler(handler);
    }
}

From source file:com.dimad.gwt.control.text.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 * /*from   www . j a  v a2 s. com*/
 * @param richText
 *            the rich text area to be controlled
 */
public RichTextToolbar(RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
        // topPanel.add(texthtml = createToggleButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these handlers for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyUpHandler(handler);
        richText.addClickHandler(handler);
    }
}

From source file:com.goodow.web.core.client.text.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 * /* w w w .  j  a  v  a 2 s  . com*/
 * @param richText the rich text area to be controlled
 */
public RichTextToolbar(final RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these handlers for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyUpHandler(handler);
        richText.addClickHandler(handler);
    }
}

From source file:com.google.code.p.gwtchismes.client.editor.Toolbar.java

License:Apache License

public Toolbar(RichTextArea richText, ToolbarConstants strings, ToolbarImages images) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    topPanel.setWidth("100%");

    initWidget(topPanel);/*from w w w. j  a  v  a  2 s.  co m*/
    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("hasRichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.editor_bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.editor_italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.editor_underline()));
        topPanel.add(backColors = createPushButton(images.backColors(), strings.editor_background()));
        topPanel.add(foreColors = createPushButton(images.foreColors(), strings.editor_foreground()));
        topPanel.add(fontFamily = createPushButton(images.fonts(), strings.editor_font()));
        topPanel.add(fontSize = createPushButton(images.fontSizes(), strings.editor_size()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.editor_subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.editor_superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.editor_justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.editor_justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.editor_justifyRight()));
    }

    if (extended != null) {
        topPanel.add(
                strikethrough = createToggleButton(images.strikeThrough(), strings.editor_strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.editor_indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.editor_outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.editor_hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.editor_ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.editor_ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.editor_insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.editor_createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.editor_removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.editor_removeFormat()));
    }

    HTML topEmtyCell = new HTML("");
    topPanel.add(topEmtyCell);
    topPanel.setCellWidth(topEmtyCell, "100%");

    richText.addKeyDownHandler(handler);
    richText.addKeyUpHandler(handler);
    richText.addClickHandler(handler);
    backColorsPicker.addValueChangeHandler(colorHandler);
    foreColorsPicker.addValueChangeHandler(colorHandler);
    fontFamilyPicker.addValueChangeHandler(fontHandler);
    fontSizePicker.addValueChangeHandler(fontHandler);
}

From source file:com.google.gwt.gears.sample.gwtnote.client.ui.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area.
 * //ww  w. ja v a2s .  co  m
 * @param richText the rich text area to be controlled
 */
public RichTextToolbar(RichTextArea richText) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    outer.add(topPanel);
    outer.add(bottomPanel);
    topPanel.setWidth("100%");
    bottomPanel.setWidth("100%");

    initWidget(outer);
    setStyleName("gwt-RichTextToolbar");

    if (basic != null) {
        topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
        topPanel.add(italic = createToggleButton(images.italic(), strings.italic()));
        topPanel.add(underline = createToggleButton(images.underline(), strings.underline()));
        topPanel.add(subscript = createToggleButton(images.subscript(), strings.subscript()));
        topPanel.add(superscript = createToggleButton(images.superscript(), strings.superscript()));
        topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), strings.justifyLeft()));
        topPanel.add(justifyCenter = createPushButton(images.justifyCenter(), strings.justifyCenter()));
        topPanel.add(justifyRight = createPushButton(images.justifyRight(), strings.justifyRight()));
    }

    if (extended != null) {
        topPanel.add(strikethrough = createToggleButton(images.strikeThrough(), strings.strikeThrough()));
        topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
        topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));
        topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
        topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
        topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
        topPanel.add(insertImage = createPushButton(images.insertImage(), strings.insertImage()));
        topPanel.add(createLink = createPushButton(images.createLink(), strings.createLink()));
        topPanel.add(removeLink = createPushButton(images.removeLink(), strings.removeLink()));
        topPanel.add(removeFormat = createPushButton(images.removeFormat(), strings.removeFormat()));
    }

    if (basic != null) {
        bottomPanel.add(backColors = createColorList("Background"));
        bottomPanel.add(foreColors = createColorList("Foreground"));
        bottomPanel.add(fonts = createFontList());
        bottomPanel.add(fontSizes = createFontSizes());

        // We only use these listeners for updating status, so don't hook them up
        // unless at least basic editing is supported.
        richText.addKeyboardListener(listener);
        richText.addClickListener(listener);
    }
}

From source file:com.google.livingstories.client.ui.richtexttoolbar.RichTextToolbar.java

License:Apache License

/**
 * Creates a new toolbar that drives the given rich text area, provides the
 * given controls, and optionally divides the toolbar into two rows.  If you
 * prefer to specify which controls are disabled (and keep the rest), then
 * use {@link EnumSet#complementOf} or the combination of
 * {@link EnumSet#allOf} and {@link EnumSet#remove}.
 *
 * <p>The {@code divideToolbar} argument, if true, will divide the toolbar into
 * two sections - one for buttons, and one for the lists.  If false, both
 * sections will be on the same row.  With all buttons enabled, a single-row
 * toolbar can take upwards of 800 pixels of horizontal space.
 *
 * <p>If {@code controls} is null, then all available controls are enabled.
 * //from  w  ww .ja  va  2  s  .  c  o m
 * @param richText the {@link RichTextArea} to be controlled
 * @param controls the set of enabled controls
 * @param divideToolbar whether or not to divide the toolbar
 */
public RichTextToolbar(RichTextArea richText, Set<Control> controls, boolean divideToolbar) {
    this.richText = richText;
    this.basic = richText.getBasicFormatter();
    this.extended = richText.getExtendedFormatter();

    boolean hasToggle = false;
    boolean hasTopPanel = false;
    boolean hasBottomPanel = false;

    HorizontalPanel topPanel = new HorizontalPanel();
    HorizontalPanel bottomPanel = null;
    VerticalPanel outer = null;

    if (divideToolbar) {
        bottomPanel = new HorizontalPanel();
        outer = new VerticalPanel();
        outer.add(topPanel);
        outer.add(bottomPanel);
    }

    if (basic != null) {
        if (controls.contains(Control.BOLD_TOGGLE)) {
            bold = createToggleButton(images.bold(), MESSAGES.bold());
            addControlToToolbar(topPanel, bold, "gwt-BoldToggle");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.ITALIC_TOGGLE)) {
            italic = createToggleButton(images.italic(), MESSAGES.italic());
            addControlToToolbar(topPanel, italic, "gwt-ItalicToggle");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.UNDERLINE_TOGGLE)) {
            underline = createToggleButton(images.underline(), MESSAGES.underline());
            addControlToToolbar(topPanel, underline, "gwt-UnderlineToggle");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.SUBSCRIPT_TOGGLE)) {
            subscript = createToggleButton(images.subscript(), MESSAGES.subscript());
            addControlToToolbar(topPanel, subscript, "gwt-SubscriptToggle");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.SUPERSCRIPT_TOGGLE)) {
            superscript = createToggleButton(images.superscript(), MESSAGES.superscript());
            addControlToToolbar(topPanel, superscript, "gwt-SuperscriptToggle");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.JUSTIFY_LEFT_BUTTON)) {
            justifyLeft = createPushButton(images.justifyLeft(), MESSAGES.justifyLeft());
            addControlToToolbar(topPanel, justifyLeft, "gwt-JustifyLeftButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.JUSTIFY_CENTER_BUTTON)) {
            justifyCenter = createPushButton(images.justifyCenter(), MESSAGES.justifyCenter());
            addControlToToolbar(topPanel, justifyCenter, "gwt-JustifyCenterButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.JUSTIFY_RIGHT_BUTTON)) {
            justifyRight = createPushButton(images.justifyRight(), MESSAGES.justifyRight());
            addControlToToolbar(topPanel, justifyRight, "gwt-JustifyRightButton");
            hasTopPanel = true;
        }
    }

    if (extended != null) {
        if (controls.contains(Control.STRIKETHROUGH_TOGGLE)) {
            strikethrough = createToggleButton(images.strikeThrough(), MESSAGES.strikeThrough());
            addControlToToolbar(topPanel, strikethrough, "gwt-StrikethroughButton");
            hasTopPanel = true;
            hasToggle = true;
        }

        if (controls.contains(Control.INDENT_BUTTON)) {
            indent = createPushButton(images.indent(), MESSAGES.indent());
            addControlToToolbar(topPanel, indent, "gwt-IndentButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.OUTDENT_BUTTON)) {
            outdent = createPushButton(images.outdent(), MESSAGES.outdent());
            addControlToToolbar(topPanel, outdent, "gwt-OutdentButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.HORIZONTAL_RULE_BUTTON)) {
            hr = createPushButton(images.hr(), MESSAGES.hr());
            addControlToToolbar(topPanel, hr, "gwt-HorizontalRuleButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.ORDERED_LIST_BUTTON)) {
            ol = createPushButton(images.ol(), MESSAGES.ol());
            addControlToToolbar(topPanel, ol, "gwt-OrderedListButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.UNORDERED_LIST_BUTTON)) {
            ul = createPushButton(images.ul(), MESSAGES.ul());
            addControlToToolbar(topPanel, ul, "gwt-UnorderedListButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.INSERT_IMAGE_BUTTON)) {
            insertImage = createPushButton(images.insertImage(), MESSAGES.insertImage());
            addControlToToolbar(topPanel, insertImage, "gwt-InsertImageButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.INSERT_GO_TO_CONTENT_ITEM_BUTTON)) {
            insertGoToContentItem = createPushButton(images.insertGoToContentItem(),
                    MESSAGES.insertGoToContentItem());
            addControlToToolbar(topPanel, insertGoToContentItem, "gwt-InsertGoToContentItemButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.INSERT_CONTENT_ITEM_BUTTON)) {
            insertContentItem = createPushButton(images.insertContentItem(), MESSAGES.insertContentItem());
            addControlToToolbar(topPanel, insertContentItem, "gwt-InsertContentItemButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.INSERT_SOURCE_BUTTON)) {
            insertSource = createPushButton(images.insertSource(), MESSAGES.insertSource());
            addControlToToolbar(topPanel, insertSource, "gwt-InsertSourceButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.INSERT_LIGHTBOX_BUTTON)) {
            insertLightbox = createPushButton(images.insertLightbox(), MESSAGES.insertLightbox());
            addControlToToolbar(topPanel, insertLightbox, "gwt-InsertLightboxButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.CREATE_LINK_BUTTON)) {
            createLink = createPushButton(images.createLink(), MESSAGES.createLink());
            addControlToToolbar(topPanel, createLink, "gwt-CreateLinkButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.REMOVE_LINK_BUTTON)) {
            removeLink = createPushButton(images.removeLink(), MESSAGES.removeLink());
            addControlToToolbar(topPanel, removeLink, "gwt-RemoveLinkButton");
            hasTopPanel = true;
        }

        if (controls.contains(Control.REMOVE_FORMAT_BUTTON)) {
            removeFormat = createPushButton(images.removeFormat(), MESSAGES.removeFormat());
            addControlToToolbar(topPanel, removeFormat, "gwt-RemoveFormatButton");
            hasTopPanel = true;
        }
    }

    if (basic != null) {
        HorizontalPanel panelToAddTo = bottomPanel != null ? bottomPanel : topPanel;
        if (controls.contains(Control.BACK_COLORS_LIST)) {
            backColors = createColorList(MESSAGES.background());
            addControlToToolbar(panelToAddTo, backColors, "gwt-BackColorsList");
            hasBottomPanel = true;
        }

        if (controls.contains(Control.FORE_COLORS_LIST)) {
            foreColors = createColorList(MESSAGES.foreground());
            addControlToToolbar(panelToAddTo, foreColors, "gwt-ForeColorsList");
            hasBottomPanel = true;
        }

        if (controls.contains(Control.FONTS_LIST)) {
            fonts = createFontList();
            addControlToToolbar(panelToAddTo, fonts, "gwt-FontsList");
            hasBottomPanel = true;
        }

        if (controls.contains(Control.FONT_SIZES_LIST)) {
            fontSizes = createFontSizes();
            addControlToToolbar(panelToAddTo, fontSizes, "gwt-FontSizesList");
            hasBottomPanel = true;
        }

        // We only use these listeners for updating status, so don't hook them up
        // unless at least basic editing is supported, and unless we have at
        // least one toggle button.
        if (hasToggle) {
            richText.addKeyUpHandler(new ToolbarKeyUpHandler());
            richText.addClickHandler(new ToolbarClickHandler());
        }
    }

    if (divideToolbar) {
        if (hasTopPanel && hasBottomPanel) {
            initWidget(outer);
        } else if (hasBottomPanel) {
            initWidget(bottomPanel);
        } else { // hasTopPanel (or has no panel)
            initWidget(topPanel);
        }
    } else { // divideToolbar == false
        // Also covers the case where they have no controls at all
        initWidget(topPanel);
    }

    setStyleName("gwt-RichTextToolbar");
    richText.addStyleName("gwt-hasRichTextToolbar");
}