本文整理汇总了Java中com.google.gwt.user.client.ui.RichTextArea类的典型用法代码示例。如果您正苦于以下问题:Java RichTextArea类的具体用法?Java RichTextArea怎么用?Java RichTextArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RichTextArea类属于com.google.gwt.user.client.ui包,在下文中一共展示了RichTextArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInitialize
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* Initialize this example.
*/
@ShowcaseSource
@Override
public Widget onInitialize() {
// Create the text area and toolbar
RichTextArea area = new RichTextArea();
area.ensureDebugId("cwRichText-area");
area.setSize("100%", "14em");
RichTextToolbar toolbar = new RichTextToolbar(area);
toolbar.ensureDebugId("cwRichText-toolbar");
toolbar.setWidth("100%");
// Add the components to a panel
Grid grid = new Grid(2, 1);
grid.setStyleName("cw-RichText");
grid.setWidget(0, 0, toolbar);
grid.setWidget(1, 0, area);
return grid;
}
示例2: onRender
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
final RichTextArea area = new RichTextArea();
area.setSize("1000", "600");
new OrderService().getOrderTemplate(new OrderService.Listener() {
public void onSuccess(String content) {
area.setHTML(content);
}
});
RichTextToolbar toolbar = new RichTextToolbar(area);
// toolbar.setWidth("100%");
// Add the components to a panel
Grid grid = new Grid(2, 1);
grid.setStyleName("cw-RichText");
grid.setWidget(0, 0, toolbar);
grid.setWidget(1, 0, area);
// grid.setSize("100%", "100%");
add(grid);
Button button = new Button("Save");
add(button);
}
示例3: setFont
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
public void setFont(final String fontName, final RichTextArea.FontSize fontSize) {
Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { // Need a delay for Firefox browser
@Override
public boolean execute() {
rta.getFormatter().setFontName(fontName);
if (fontSize != null) {
rta.getFormatter().setFontSize(fontSize);
}
return false;
}
}, 100);
}
示例4: addTextArea
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public HasHTML addTextArea(final RichTextElementDTO richTextElement, final FoldPanel sectionPanel, final boolean draftMode) {
if (draftMode) {
final RichTextArea textArea = new RichTextArea();
textArea.setHTML(richTextElement.getText());
textArea.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
globalFormatterArray[0] = textArea.getFormatter();
}
});
sectionPanel.add(textArea);
return textArea;
} else {
final HTML html = new HTML();
final String value = richTextElement.getText();
if (ClientUtils.isBlank(value)) {
html.setText(I18N.CONSTANTS.reportEmptySection());
html.addStyleName(STYLE_PROJECT_REPORT_FIELD_EMPTY);
} else {
html.setHTML(value);
html.addStyleName(STYLE_PROJECT_REPORT_FIELD);
}
sectionPanel.add(html);
return null;
}
}
示例5: addKeyQuestion
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public HasHTML addKeyQuestion(final KeyQuestionDTO keyQuestion, final FoldPanel sectionPanel, final boolean draftMode) {
keyQuestionState.increaseCount();
keyQuestion.setNumber(keyQuestionState.getCount());
// Rich text field.
final RichTextArea textArea = new RichTextArea();
final RichTextElementDTO richTextElementDTO = keyQuestion.getRichTextElementDTO();
if (richTextElementDTO != null) {
textArea.setHTML(richTextElementDTO.getText());
}
// Compas icon.
final ImageResource icon;
if (ClientUtils.isBlank(textArea.getText())) {
icon = ToolbarImages.IMAGES.compasRed();
} else {
icon = ToolbarImages.IMAGES.compasGreen();
keyQuestionState.increaseValids();
}
sectionPanel.addToolButton(icon, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
KeyQuestionDialog.getDialog(keyQuestion, textArea, sectionPanel, sectionPanel.getToolButtonCount(), keyQuestionState, draftMode).show();
}
});
return textArea;
}
示例6: getDialog
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
private static Dialog getDialog() {
if (keyQuestionDialog == null) {
final Dialog dialog = new Dialog();
dialog.setButtons(Dialog.OKCANCEL);
dialog.setModal(true);
dialog.setWidth("640px");
dialog.setResizable(false);
dialog.setLayout(new RowLayout(Orientation.VERTICAL));
// Question label
final Label questionLabel = new Label("key-question");
questionLabel.addStyleName("project-report-key-question-label");
dialog.add(questionLabel);
// Text area
final RichTextArea textArea = new RichTextArea();
textArea.setStyleName("project-report-key-question");
dialog.add(textArea);
// Toolbar
final ToolBar toolBar = new ToolBar();
ReportsView.createRichTextToolbar(toolBar, new RichTextArea.Formatter[] {textArea.getFormatter()});
dialog.setTopComponent(toolBar);
// Cancel button
dialog.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
dialog.hide();
}
});
keyQuestionDialog = dialog;
}
return keyQuestionDialog;
}
示例7: initToolBar
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
public void initToolBar(RichTextArea richtext) {
if(!initiated) {
initiated = true;
//Save the reference to the RichText area we refer to and get the interfaces to the stylings
styleText = richtext;
styleTextFormatter = styleText.getFormatter();
//Add KeyUp and Click-Handler to the RichText, so that we can actualize the toolbar if neccessary
styleText.addKeyUpHandler(evHandler);
styleText.addClickHandler(evHandler);
}
}
示例8: TextAreaExample
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
public TextAreaExample() {
super("Text Area");
TextArea text = new TextArea();
text.setCharacterWidth(30);
text.setVisibleLines(5);
add(text);
RichTextArea rich = new RichTextArea();
rich.setHTML("Rich <i>text</i> <b>area</b>");
add(rich);
}
示例9: refresh
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
public void refresh() {
BeanObject article = getCurState().getArticle();
if (article != null && article.getString(IArticleCatagory.ID) != null) {
contentPanelGeneral.updateValues(article.getProperties());
RichTextArea wid = (RichTextArea)grid.getWidget(1, 0);
wid.setText(article.getString("content"));
// this.article = null;
} else {
contentPanelGeneral.clearValues();
getCurState().setEditting(false);
}
}
示例10: CubaRichTextToolbarWidget
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
public CubaRichTextToolbarWidget(RichTextArea richText) {
super(richText);
}
示例11: createRichTextToolbar
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
@Override
protected void createRichTextToolbar(RichTextArea rta) {
formatter = new CubaRichTextToolbarWidget(rta);
}
示例12: RichTextToolbar
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* Creates a new toolbar that drives the given rich text area.
*
* @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()));
}
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);
}
}
示例13: RichTextToolbar
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* Creates a new toolbar that drives the given rich text area.
*
* @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()));
}
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);
}
}
示例14: updateFromUIDL
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
@Override
public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) {
getWidget().client = client;
getWidget().id = uidl.getId();
if (uidl.hasAttribute("fontName")) {
RichTextArea.FontSize fontSize = null;
if (uidl.hasAttribute("fontSize")) {
int fontSizeValue = uidl.getIntAttribute("fontSize");
for (RichTextArea.FontSize fontSizesConstant : fontSizesConstants) {
if (fontSizesConstant.getNumber() == fontSizeValue) {
fontSize = fontSizesConstant;
}
}
}
getWidget().setFont(uidl.getStringAttribute("fontName"), fontSize);
}
if (uidl.hasAttribute("insertHtml")) {
getWidget().insertHtml(uidl.getStringAttribute("insertHtml"));
}
if (uidl.hasVariable("text")) {
String newValue = uidl.getStringVariable("text");
if (!SharedUtil.equals(newValue, cachedValue)) {
getWidget().setValue(newValue);
cachedValue = newValue;
}
}
if (!isRealUpdate(uidl)) {
return;
}
getWidget().setEnabled(isEnabled());
getWidget().setReadOnly(isReadOnly());
getWidget().immediate = getState().immediate;
int newMaxLength = uidl.hasAttribute("maxLength") ? uidl
.getIntAttribute("maxLength") : -1;
if (newMaxLength >= 0) {
if (getWidget().maxLength == -1) {
getWidget().keyPressHandler = getWidget().rta
.addKeyPressHandler(getWidget());
}
getWidget().maxLength = newMaxLength;
} else if (getWidget().maxLength != -1) {
getWidget().getElement().setAttribute("maxlength", "");
getWidget().maxLength = -1;
getWidget().keyPressHandler.removeHandler();
}
if (uidl.hasAttribute("selectAll")) {
getWidget().selectAll();
}
}
示例15: RichTextToolbar
import com.google.gwt.user.client.ui.RichTextArea; //导入依赖的package包/类
/**
* Creates a new toolbar that drives the given rich text area.
*
* @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()));
}
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);
}
}