本文整理汇总了Java中com.google.gwt.dom.client.BRElement类的典型用法代码示例。如果您正苦于以下问题:Java BRElement类的具体用法?Java BRElement怎么用?Java BRElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BRElement类属于com.google.gwt.dom.client包,在下文中一共展示了BRElement类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpacer
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* Get the spacer for the given paragraph.
* Lazily creates & registers one if not present.
* If there's one that the browser created, registers it as our own.
* If the browser put a different one in to the one that we were already
* using, replace ours with the browser's.
* @param paragraph
* @return The spacer
*/
protected BRElement getSpacer(Element paragraph) {
Node last = paragraph.getLastChild();
BRElement spacer = paragraph.getPropertyJSO(BR_REF).cast();
if (spacer == null) {
// Register our spacer, using one the browser put in if present
spacer = isSpacer(last) ? last.<BRElement>cast() : Document.get().createBRElement();
setupSpacer(paragraph, spacer);
} else if (isSpacer(last) && last != spacer) {
// The browser put a different one in by itself, so let's use that one
if (spacer.hasParentElement()) {
spacer.removeFromParent();
}
spacer = last.<BRElement>cast();
setupSpacer(paragraph, spacer);
}
return spacer;
}
示例2: ensureSpacerIfDoesntEndWithText
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
private void ensureSpacerIfDoesntEndWithText(Element paragraph) {
Node last = paragraph.getLastChild();
BRElement spacer = getSpacer(paragraph);
if (last == spacer) {
last = last.getPreviousSibling();
}
if (last == null || DomHelper.isElement(last)) {
paragraph.appendChild(spacer);
} else {
spacer.removeFromParent();
}
}
示例3: isSpacer
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* @param n Node to test, or null
* @return true if n is a spacer <br/>, WHETHER OR NOT we created it
* or the browser's native editor created it
*/
protected boolean isSpacer(Node n) {
if (n == null) {
return false;
}
if (DomHelper.isTextNode(n)) {
return false;
}
Element e = n.cast();
return e.getTagName().equalsIgnoreCase(BRElement.TAG) && !NodeManager.hasBackReference(e);
}
示例4: onRemovingChild
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onRemovingChild(Node child, Element paragraph) {
Node first = paragraph.getFirstChild();
BRElement spacer = getSpacer(paragraph);
if (first == null) {
appendSpacer(paragraph);
} else if (first != spacer) {
spacer.removeFromParent();
}
}
示例5: convertToPlainText
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* Converts the given {@code HTML} into robot compatible plaintext.
*
* @param html the {@code HTML} to convert.
* @return a plain text version of the given {@code HTML}.
*/
private static String convertToPlainText(String html) {
StringBuffer result = new StringBuffer();
Matcher matcher = MARKUP_PATTERN.matcher(html);
while (matcher.find()) {
String replacement = "";
String tag = matcher.group().substring(1, matcher.group().length() - 1).split(" ")[0];
if (ParagraphElement.TAG.equalsIgnoreCase(tag) || BRElement.TAG.equalsIgnoreCase(tag)) {
replacement = "\n";
}
matcher.appendReplacement(result, replacement);
}
matcher.appendTail(result);
return result.toString();
}
示例6: convertToPlainText
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* Converts the given {@code HTML} into robot compatible plain text.
*
* @param html the text to convert.
* @return a plain text version of the given html text.
*/
private static String convertToPlainText(String html) {
StringBuffer result = new StringBuffer();
Matcher matcher = MARKUP_PATTERN.matcher(html);
while (matcher.find()) {
String replacement = "";
String tag = matcher.group().substring(1, matcher.group().length() - 1).split(" ")[0];
if (ParagraphElement.TAG.equalsIgnoreCase(tag) || BRElement.TAG.equalsIgnoreCase(tag)) {
replacement = "\n";
}
matcher.appendReplacement(result, replacement);
}
matcher.appendTail(result);
return result.toString();
}
示例7: setupSpacer
import com.google.gwt.dom.client.BRElement; //导入依赖的package包/类
/**
* Setup the given br element as the paragraph's spacer
* @param paragraph
* @param spacer
*/
private void setupSpacer(Element paragraph, BRElement spacer) {
NodeManager.setTransparency(spacer, Skip.DEEP);
paragraph.setPropertyJSO(BR_REF, spacer);
}