Java 类com.google.gwt.dom.client.PreElement 实例源码

项目:gwt-promptly    文件:PromptlyPanel.java   
public final void appendPre(StyledBlock styledBlock, boolean withFormatting, String additionalStyle) {
   FlowPanel outerWidget = new FlowPanel(PreElement.TAG );
   styledBlock.toGwtWidget(this, outerWidget, withFormatting, getPreBlockClassName());

   if (additionalStyle != null) {
      outerWidget.getElement().setAttribute("style",additionalStyle);
   }

   appendAndScrollOrFocusAsAppropriate(outerWidget);
}
项目:che    文件:GitOutputPartViewImpl.java   
/** {@inheritDoc} */
@Override
public void print(String text) {
  PreElement pre = DOM.createElement("pre").cast();
  pre.setInnerText(text.isEmpty() ? " " : text);
  consoleLines.getElement().appendChild(pre);
}
项目:che    文件:GitOutputPartViewImpl.java   
@Override
public void print(String text, String color) {
  PreElement pre = DOM.createElement("pre").cast();
  pre.setInnerText(text.isEmpty() ? " " : text);

  try {
    pre.getStyle().setColor(SimpleHtmlSanitizer.sanitizeHtml(color).asString());
  } catch (Exception e) {
    Log.error(getClass(), "Unable to set color [" + color + "]", e);
  }

  consoleLines.getElement().appendChild(pre);
}
项目:IdleAlarm    文件:IdleAlarmMessageUtil.java   
public static void setMessageToHtml(String message, ContentMode contentMode, HTML widget) {
    if(contentMode == ContentMode.HTML) {
        widget.setHTML(message);
    } else if(contentMode == ContentMode.PREFORMATTED) {
        PreElement preElement = Document.get().createPreElement();
        preElement.setInnerText(message);
        widget.setHTML(preElement.getString());
    } else {
        widget.setText(message);
    }
}
项目:ScaleImage    文件:ScaleImageConnector.java   
@Override
public void onStateChanged(StateChangeEvent event) {
    super.onStateChanged(event);

    clickEventHandler.handleEventHandlerRegistration();

    String url = getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE);
       getWidget().setUrl(url);

       for(String property : getState().styleValues.keySet()) {
        String value = getState().styleValues.get(property);
        Style elementStyle = getWidget().getElement().getStyle();
        if(value == null || value.isEmpty()) {
            elementStyle.clearProperty(property);
        } else {
            elementStyle.setProperty(property, value);
        }
       }

       if(getState().innerContentMode == ContentMode.HTML) {
        getWidget().setInnerHtml(getState().innerContent);
    } else if(getState().innerContentMode == ContentMode.PREFORMATTED) {
        PreElement preElement = Document.get().createPreElement();
        preElement.setInnerText(getState().innerContent);
        getWidget().getElement().removeAllChildren();
        getWidget().getElement().appendChild(preElement);
    } else {
        getWidget().setInnerText(getState().innerContent);
    }

    getWidget().setAriaLabel(getState().alternateText);
}
项目:che    文件:OutputConsoleViewImpl.java   
@Override
public void print(final String text, boolean carriageReturn, String color) {

  if (consoleLines.getElement().getChildCount() > 500) {
    consoleLines.getElement().getFirstChild().removeFromParent();
  }

  if (this.carriageReturn) {
    Node lastChild = consoleLines.getElement().getLastChild();
    if (lastChild != null) {
      lastChild.removeFromParent();
    }
  }

  this.carriageReturn = carriageReturn;

  final SafeHtml colorOutput =
      new SafeHtml() {
        @Override
        public String asString() {

          if (Strings.isNullOrEmpty(text)) {
            return " ";
          }

          String encoded = SafeHtmlUtils.htmlEscape(text);
          if (delegate != null) {
            if (delegate.getCustomizer() != null) {
              if (delegate.getCustomizer().canCustomize(encoded)) {
                encoded = delegate.getCustomizer().customize(encoded);
              }
            }
          }

          for (final Pair<RegExp, String> pair : output2Color) {
            final MatchResult matcher = pair.first.exec(encoded);

            if (matcher != null) {
              return encoded.replaceAll(
                  matcher.getGroup(1),
                  "<span style=\"color: "
                      + pair.second
                      + "\">"
                      + matcher.getGroup(1)
                      + "</span>");
            }
          }

          return encoded;
        }
      };

  PreElement pre = DOM.createElement("pre").cast();
  pre.setInnerSafeHtml(colorOutput);
  if (color != null) {
    pre.getStyle().setColor(color);
  }
  consoleLines.getElement().appendChild(pre);

  followOutput();
}
项目:putnami-web-toolkit    文件:CodeOutputImpl.java   
public CodeOutputImpl() {
    this.setElement(Document.get().createElement(PreElement.TAG));
    StyleUtils.addStyle(this, CodeOutputImpl.STYLE_CODE_EDITOR);
    StyleUtils.addStyle(this, CodeOutputImpl.STYLE_PRE_SCROLLABLE);
}