Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml.

Prototype

public SafeHtml toSafeHtml() 

Source Link

Document

Returns the safe HTML accumulated in the builder as a SafeHtml .

Usage

From source file:com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.java

License:sencha.com license

/**
 * Creates a border layout container with the specified appearance.
 * /*  ww w. j a v  a 2s.c  o  m*/
 * @param appearance the appearance of the border layout container
 */
public BorderLayoutContainer(BorderLayoutAppearance appearance) {
    super(true);
    this.appearance = appearance;

    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    this.appearance.render(builder);

    setElement((Element) XDOM.create(builder.toSafeHtml()));

    getElement().makePositionable();
}

From source file:com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.java

License:sencha.com license

/**
 * Creates a box layout container with the specified appearance.
 * //from  www.j  av a  2 s .co  m
 * @param appearance the box layout container appearance
 */
public BoxLayoutContainer(BoxLayoutContainerAppearance appearance) {
    this.appearance = appearance;
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    appearance.render(sb);
    setElement((Element) XDOM.create(sb.toSafeHtml()));
}

From source file:com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer.java

License:sencha.com license

/**
 * Creates a CSS float layout container with the specified appearance.
 * /*from   w  ww . j  ava 2s . c  om*/
 * @param appearance the appearance of the CSS float layout container
 */
public CssFloatLayoutContainer(CssFloatLayoutAppearance appearance) {
    this.appearance = appearance;
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    appearance.render(sb);
    setElement((Element) XDOM.create(sb.toSafeHtml()));
}

From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java

License:sencha.com license

protected void onPortletDragStart(DragStartEvent de) {
    active = (Portlet) de.getTarget();//from w ww. j a  v a 2s .  co m

    if (dummy == null) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        appearance.renderInsert(sb);
        dummy = XDOM.create(sb.toSafeHtml()).cast();
    }

    dummy.getStyle().setMarginBottom(spacing, Unit.PX);

    int h = active.getElement().getOffsetHeight() - active.getElement().getFrameWidth(Side.TOP, Side.BOTTOM);
    dummy.getFirstChildElement().<XElement>cast().setHeight(h);

    startColumns = new ArrayList<Integer>();
    for (int i = 0; i < numColumns; i++) {
        CssFloatLayoutContainer con = getWidget(i);
        int x = con.getAbsoluteLeft();
        startColumns.add(x);
    }
    startCol = getColumn(de.getX());
    startRow = getRow(startCol, de.getY());
    active.setVisible(false);
    addInsert(startCol, startRow);

    if (autoScroll) {
        getAutoScrollSupport().start();
    }
}

From source file:com.sencha.gxt.widget.core.client.container.Viewport.java

License:sencha.com license

/**
 * Creates a viewport layout container with the specified appearance.
 * //from  w ww.  java  2 s.  c  o  m
 * @param appearance the appearance of the viewport layout container
 */
public Viewport(ViewportAppearance appearance) {
    super(true);
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    appearance.render(sb);
    setElement((Element) XDOM.create(sb.toSafeHtml()));
    monitorWindowResize = true;
    getFocusSupport().setIgnore(false);
    setPixelSize(Window.getClientWidth(), Window.getClientHeight());
}

From source file:com.sencha.gxt.widget.core.client.ContentPanel.java

License:sencha.com license

/**
 * Creates a content panel with the specified appearance.
 *
 * @param appearance the appearance of the content panel.
 *///from www  .ja va2  s . c o m
public ContentPanel(ContentPanelAppearance appearance) {
    super(true);
    this.appearance = appearance;

    setDeferHeight(true);

    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    appearance.render(sb);

    setElement((Element) XDOM.create(sb.toSafeHtml()));

    header = new Header(appearance.getHeaderAppearance());
    ComponentHelper.setParent(this, header);

    XElement headerElem = appearance.getHeaderElem(getElement());
    headerElem.appendChild(header.getElement());

    buttonBar = new ButtonBar();
    buttonBar.setMinButtonWidth(75);
    buttonBar.setPack(BoxLayoutPack.END);
    buttonBar.setVisible(false);
    buttonBar.getElement().getStyle().setProperty("minHeight", "5px");
    appearance.getFooterElem(getElement()).appendChild(buttonBar.getElement());
}

From source file:com.sencha.gxt.widget.core.client.DatePicker.java

License:sencha.com license

/**
 * Creates a date picker with the specified appearance.
 *
 * @param appearance the appearance of the date picker
 *//*from ww  w. j  a va 2 s.com*/
public DatePicker(DatePickerAppearance appearance) {
    this.appearance = appearance;

    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    this.appearance.render(builder);

    setElement((Element) XDOM.create(builder.toSafeHtml()));

    setAllowTextSelection(false);

    setStartDay(dateTimeInfo.getFirstDayOfTheWeek());

    todayBtn = new TextButton(getMessages().todayText());
    todayBtn.addSelectHandler(new SelectHandler() {

        @Override
        public void onSelect(SelectEvent event) {
            selectToday();
        }
    });

    todayBtn.setToolTip(
            getMessages().todayTip(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date())));

    getElement().selectNode(appearance.todayButtonSelector()).appendChild(todayBtn.getElement());

    monthPickerOkButton = new TextButton(getMessages().okText());
    monthPickerOkButton.addSelectHandler(new SelectHandler() {
        @Override
        public void onSelect(SelectEvent event) {
            DateWrapper d = new DateWrapper(mpSelYear, mpSelMonth, 1);
            update(d);
            focus();
            hideMonthPicker();
        }
    });

    monthPickerCancelButton = new TextButton(getMessages().cancelText());
    monthPickerCancelButton.addSelectHandler(new SelectHandler() {
        @Override
        public void onSelect(SelectEvent event) {
            focus();
            hideMonthPicker();
        }
    });

    monthPicker = XElement.createElement("div");
    monthPicker.getStyle().setDisplay(Display.NONE);

    getElement().appendChild(monthPicker);

    cells = Util.toElementArray(appearance.getDateCells(getElement()));

    activeDate = value != null ? value : new DateWrapper();
    update(activeDate);

    new KeyNav(this) {
        @Override
        public void onKeyPress(NativeEvent evt) {
            handlerKeyPress(evt);
        }
    };

    getElement().makePositionable();
    getElement().setTabIndex(0);
    getElement().setAttribute("hideFocus", "true");
    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.ONFOCUS);

    XElement target = getElement().selectNode(appearance.leftMonthSelector());
    target.setTitle(messages.prevText());
    target = getElement().selectNode(appearance.rightMonthSelector());
    target.setTitle(messages.nextText());
    target = getElement().selectNode(appearance.monthButtonSelector());
    target.setTitle(messages.monthYearText());

    addGestureRecognizer(new TapGestureRecognizer() {

        @Override
        protected void onTap(TouchData touchData) {
            super.onTap(touchData);
            DatePicker.this.onTap(touchData);
        }
    });
}

From source file:com.sencha.gxt.widget.core.client.DatePicker.java

License:sencha.com license

protected void createMonthPicker() {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    appearance.renderMonthPicker(builder, messages, dateTimeInfo.getMonthsShort());

    monthPicker.removeChildren();//from  w ww . j a v  a2 s .c  o  m
    monthPicker.setInnerSafeHtml(builder.toSafeHtml());

    monthPicker.selectNode(appearance.monthPickerOkSelector()).appendChild(monthPickerOkButton.getElement());
    monthPicker.selectNode(appearance.monthPickerCancelSelector())
            .appendChild(monthPickerCancelButton.getElement());

    mpMonths = new CompositeElement(
            Util.toElementArray(monthPicker.select(appearance.monthPickerMonthSelector())));
    mpYears = new CompositeElement(
            Util.toElementArray(monthPicker.select(appearance.monthPickerYearSelector())));

    mpMonths.each(new CompositeFunction() {

        public void doFunction(Element elem, CompositeElement ce, int index) {
            index += 1;
            if (index % 2 == 0) {
                elem.setPropertyInt("xmonth", (int) (5 + (Math.round(index * .5))));
            } else {
                elem.setPropertyInt("xmonth", (int) (Math.round((index - 1) * .5)));
            }
        }

    });
}

From source file:com.sencha.gxt.widget.core.client.form.FieldLabel.java

License:sencha.com license

/**
 * Creates a field label with the specified the specified widget and
 * appearance./*  www .java  2  s. c o  m*/
 * 
 * @param widget the widget to label
 * @param appearance the appearance of the field label
 */
public FieldLabel(Widget widget, FieldLabelAppearance appearance) {
    super(true);
    this.appearance = appearance;
    String id;
    if (widget == null) {
        id = null;
    } else {
        id = ComponentHelper.getWidgetId(widget);

        if (widget instanceof ValueBaseField<?>) {
            id += "-input";
        }
    }

    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    appearance.render(sb, id, options);
    setElement((Element) XDOM.create(sb.toSafeHtml()));

    if (widget != null) {
        setWidget(widget);
    }
}

From source file:com.sencha.gxt.widget.core.client.form.FieldSet.java

License:sencha.com license

/**
 * Creates a new field set./*from   w  ww  .  j  a v a 2 s  .c  om*/
 * 
 * @param appearance the field set appearance
 */
public FieldSet(FieldSetAppearance appearance) {
    super(true);

    this.appearance = appearance;

    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    this.appearance.render(builder);

    setElement((Element) XDOM.create(builder.toSafeHtml()));
}