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

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

Introduction

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

Prototype

public String getHTML() 

Source Link

Usage

From source file:com.phideltcmu.recruiter.client.ui.popup.NotesAdder.java

License:Creative Commons License

public NotesAdder(final Person p, final StringCallback callback) {
    super();/*www  . j  ava  2s  .  c  o  m*/
    title.setText("Notes For " + p.getFullName());
    title.setStyleName("oldenburg150");
    final RichTextArea area = new RichTextArea();
    area.setSize("100%", "14em");
    String notes = p.getNotes();
    area.setHTML(notes == null ? "" : notes);

    // Add the components to a panel
    Grid grid = new Grid(4, 1);
    grid.setWidget(0, 0, title);
    grid.setWidget(1, 0, area);
    grid.setWidget(2, 0, saveButton);

    saveButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            DynamicRecruiter.RECRUIT_SERVICE.saveNotes(p.getAndrewID(), area.getHTML(),
                    DynamicRecruiter.authUser.getAuthToken(), new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable throwable) {
                            throwable.printStackTrace();
                        }

                        @Override
                        public void onSuccess(Void aVoid) {
                            notesAdder.hide();
                            Window.alert("Notes Saved!");
                            if (area.getText().length() == 0) {
                                callback.onStringReturned(null);
                            } else {
                                callback.onStringReturned(area.getHTML());
                            }
                        }
                    });
        }
    });
    this.bindWidget(grid);
}

From source file:org.bonitasoft.forms.client.view.widget.RichTextWidget.java

License:Open Source License

protected void createWidget() {
    richTextContainer = new FlowPanel();
    richTextArea = new RichTextArea();
    richTextArea.addBlurHandler(new BlurHandler() {
        public void onBlur(final BlurEvent event) {
            final RichTextArea source = (RichTextArea) event.getSource();
            value = source.getHTML();
        }//w w  w. j  a v a  2s  .  c  o m
    });
    richTextArea.setStyleName("bonita_richTextArea");
    richTextToolbar = new RichTextToolbar(richTextArea);
    richTextContainer.add(richTextToolbar);
    richTextContainer.add(richTextArea);
    richTextContainer.setStyleName("bonita_rich_text");
    flowPanel.add(richTextContainer);
}

From source file:org.fao.fenix.web.modules.text.client.view.editor.TextEditor.java

License:Open Source License

public TextEditor(RichTextArea textArea) {
    setTextViewId(null);//  www  . j  a  va2 s.  c o  m
    setTitle(null);
    setTextContent(textArea.getHTML());
    setReferenceDate(null);
    setLastUpdated(null);
    setTextViewId(null);
    setRptDesign("NoBirt");
    setTextModel(null);
}

From source file:org.fao.fenix.web.modules.text.client.view.editor.TextEditor.java

License:Open Source License

public TextEditor(RichTextArea text, String type) {
    setTextViewId(null);//from  w ww  .j  a  v  a  2  s  . c  o  m
    setTextTitle(null);
    setTextContent(text.getHTML());
    setReferenceDate(null);
    setLastUpdated(null);
    setTextViewId(null);
    setRptDesign(type);
    setTextModel(null);
}

From source file:org.pentaho.pat.client.ui.panels.windows.ConnectMondrianPanel.java

License:Open Source License

/**
 * Run on panel initialize.// w  w w.  j a  v  a 2  s  . c  o  m
 */
private void init() {

    final FormPanel formPanel = new FormPanel();
    formPanel.setAction(FORM_ACTION);
    formPanel.setMethod(FORM_METHOD);
    formPanel.setEncoding(FORM_ENCODING);
    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(final SubmitCompleteEvent arg0) {
            if (arg0 != null && arg0.getResults() != null && arg0.getResults().length() > 0) {
                if (arg0.getResults().contains(VALIDATION_START)) {
                    final String tmp = arg0.getResults().substring(
                            arg0.getResults().indexOf(VALIDATION_START) + VALIDATION_START.length(),
                            arg0.getResults().indexOf(VALIDATION_END));
                    if (tmp != null && tmp.length() > 0) {
                        if (schemaValCheckbox.getValue()) {
                            MessageBox.info(Pat.CONSTANTS.warning(),
                                    MessageFactory.getInstance().schemaFileInvalid() + "<br>" + tmp); //$NON-NLS-1$
                        }
                    }
                }
                if (arg0.getResults().contains(SCHEMA_START)) {
                    final String tmp = arg0.getResults().substring(
                            arg0.getResults().indexOf(SCHEMA_START) + SCHEMA_START.length(),
                            arg0.getResults().indexOf(SCHEMA_END));
                    schemaData = decode(tmp);
                    saveButton.setEnabled(true);
                    viewSchemaButton.setEnabled(true);
                    viewSchemaButton.setText(Pat.CONSTANTS.viewSchema());
                    // TODO remove this later

                    Application.INSTANCE.showInfoPanel(Pat.CONSTANTS.fileUpload(), Pat.CONSTANTS.success());
                } else {
                    MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.fileUploadFailed());
                }
            } else {
                MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.checkErrorLog());
            }
        }
    });
    final FormLayout layout = new FormLayout("right:[40dlu,pref], 3dlu, 70dlu, 7dlu, " //$NON-NLS-1$
            + "right:[40dlu,pref], 3dlu, 70dlu", //$NON-NLS-1$
            "p, 3dlu, p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p"); //$NON-NLS-1$
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.addLabel(Pat.CONSTANTS.name() + LABEL_SUFFIX, CellConstraints.xy(1, 1));
    builder.add(nameTextBox, CellConstraints.xyw(3, 1, 5));
    builder.addLabel(Pat.CONSTANTS.jdbcDriver() + LABEL_SUFFIX, CellConstraints.xy(1, 3));
    builder.add(driverListBox, CellConstraints.xyw(3, 3, 5));
    builder.addLabel(Pat.CONSTANTS.jdbcUrl() + LABEL_SUFFIX, CellConstraints.xy(1, 5));
    builder.add(urlTextBox, CellConstraints.xyw(3, 5, 5));
    builder.addLabel(Pat.CONSTANTS.username() + LABEL_SUFFIX, CellConstraints.xy(1, 7));
    builder.add(userTextBox, CellConstraints.xy(3, 7));
    builder.addLabel(Pat.CONSTANTS.password() + LABEL_SUFFIX, CellConstraints.xy(5, 7));
    builder.add(passwordTextBox, CellConstraints.xy(7, 7));
    builder.addLabel(Pat.CONSTANTS.schemaFile() + LABEL_SUFFIX, CellConstraints.xy(1, 9));
    fileUpload.setName(FORM_NAME_FILE);
    builder.add(fileUpload, CellConstraints.xyw(3, 9, 5));
    builder.add(schemaValCheckbox, CellConstraints.xyw(3, 11, 5));
    uploadButton.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            final String filename = fileUpload.getFilename();
            if (filename == null || filename.length() == 0) {
                MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.fileUploadNoFile());
            } else {
                formPanel.submit();
            }
        }
    });

    builder.add(uploadButton, CellConstraints.xy(3, 13));

    viewSchemaButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {

            final WindowPanel winPanel = new WindowPanel(Pat.CONSTANTS.schemaFile());
            final LayoutPanel wpLayoutPanel = new LayoutPanel(new BoxLayout(Orientation.VERTICAL));
            wpLayoutPanel.setSize("450px", "200px"); //$NON-NLS-1$ //$NON-NLS-2$
            final RichTextArea schemaArea = new RichTextArea();
            String newStr = schemaData + "";
            newStr = newStr.replaceAll("\\<", "&lt;").replaceAll("\\>", "&gt;").replaceAll(" ", "&nbsp;");
            newStr = newStr.replaceAll("\t", "&nbsp;&nbsp;&nbsp;");
            newStr = newStr.replaceAll("(\r\n)", "<br>"); //$NON-NLS-1$ //$NON-NLS-2$
            //                newStr = newStr.replaceAll("[\r\n\t\f]", "<br>"); //$NON-NLS-1$ //$NON-NLS-2$
            schemaArea.setHTML(newStr + "");

            wpLayoutPanel.add(schemaArea, new BoxLayoutData(1, 0.9));
            final ToolButton saveBtn = new ToolButton(Pat.CONSTANTS.save());
            saveBtn.addClickHandler(new ClickHandler() {
                public void onClick(final ClickEvent arg0) {
                    String newStr = schemaArea.getHTML();
                    newStr = newStr.replaceAll("&lt;", "\\<").replaceAll("&gt;", "\\>").replaceAll("&nbsp;",
                            " ");
                    newStr = newStr.replaceAll("&nbsp;&nbsp;&nbsp;", "\t");
                    newStr = newStr.replaceAll("<br>", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
                    schemaData = newStr;
                    winPanel.hide();
                    ConnectionManagerWindow.display(false);
                }

            });

            final ToolButton closeBtn = new ToolButton(Pat.CONSTANTS.close());
            closeBtn.addClickHandler(new ClickHandler() {
                public void onClick(final ClickEvent arg0) {
                    winPanel.hide();
                    ConnectionManagerWindow.display(false);
                }

            });
            final LayoutPanel wpButtonPanel = new LayoutPanel(new BoxLayout(Orientation.HORIZONTAL));

            wpButtonPanel.add(saveBtn);
            wpButtonPanel.add(closeBtn);
            wpLayoutPanel.add(wpButtonPanel);
            wpLayoutPanel.layout();
            winPanel.add(wpLayoutPanel);
            winPanel.layout();
            winPanel.pack();
            winPanel.setSize("700px", "520px"); //$NON-NLS-1$ //$NON-NLS-2$

            ConnectionManagerWindow.close();
            winPanel.center();

        }
    });
    viewSchemaButton.setEnabled(false);
    viewSchemaButton.setText(Pat.CONSTANTS.noSchema());
    builder.add(viewSchemaButton, CellConstraints.xy(7, 13));

    builder.addLabel(Pat.CONSTANTS.role() + LABEL_SUFFIX, CellConstraints.xy(1, 15));
    builder.add(roleTextBox, CellConstraints.xyw(3, 15, 5));

    builder.add(startupCheckbox, CellConstraints.xy(3, 17));

    saveButton.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            final CubeConnection cc = getCubeConnection();
            if (validateConnection(cc)) {

                saveButton.setEnabled(false);
                ServiceFactory.getSessionInstance().saveConnection(Pat.getSessionID(), cc,
                        new AsyncCallback<String>() {
                            public void onFailure(final Throwable arg0) {
                                MessageBox.error(Pat.CONSTANTS.error(), MessageFactory.getInstance()
                                        .failedLoadConnection(arg0.getLocalizedMessage()));
                                saveButton.setEnabled(true);
                            }

                            public void onSuccess(final String id) {
                                if (cc.isConnectOnStartup()) {
                                    ConnectionManagerPanel.connectEvent(id, cc.isConnected(), true);
                                }
                                ConnectionManagerWindow.closeTabs();
                            }
                        });

            }
        }
    });

    saveButton.setEnabled(false);

    builder.add(saveButton, CellConstraints.xy(3, 19));

    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            ConnectionManagerWindow.closeTabs();
        }
    });
    builder.add(cancelButton, CellConstraints.xy(7, 19));
    final LayoutPanel layoutPanel = builder.getPanel();
    layoutPanel.setPadding(15);
    formPanel.add(layoutPanel);
    this.getLayoutPanel().add(formPanel);
}

From source file:org.sigmah.client.page.orgunit.reports.KeyQuestionDialog.java

License:Open Source License

public static Dialog getDialog(final KeyQuestionDTO keyQuestion, final RichTextArea textArea,
        final FoldPanel panel, final int toolButtonIndex, final KeyQuestionState keyQuestionState,
        boolean enabled) {
    final Dialog dialog = getDialog();
    dialog.setHeading(I18N.MESSAGES.reportKeyQuestionDialogTitle(Integer.toString(keyQuestion.getNumber())));

    // Question label
    final Label question = (Label) dialog.getWidget(0);
    question.setText(keyQuestion.getLabel());

    // Rich text editor
    final RichTextArea dialogTextArea = (RichTextArea) dialog.getWidget(1);
    dialogTextArea.setHTML(textArea.getHTML());

    final boolean wasValid = !"".equals(textArea.getText());

    // OK Button/*from   w w  w.j  a  va  2 s .c o m*/
    final Button okButton = dialog.getButtonById(Dialog.OK);

    okButton.removeAllListeners();

    if (enabled) {

        dialog.getTopComponent().enable();
        dialogTextArea.setEnabled(true);

        okButton.setVisible(true);
        okButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
                dialog.hide();
                textArea.setHTML(dialogTextArea.getHTML());

                final boolean isValid = !"".equals(dialogTextArea.getText());

                final ToolbarImages images = GWT.create(ToolbarImages.class);
                if (isValid) {
                    panel.setToolButtonImage(toolButtonIndex, images.compasGreen());

                    if (!wasValid)
                        keyQuestionState.increaseValids();

                } else {
                    panel.setToolButtonImage(toolButtonIndex, images.compasRed());

                    if (wasValid)
                        keyQuestionState.decreaseValids();
                }
            }
        });

    } else {

        okButton.setVisible(false);

        dialog.getTopComponent().disable();
        dialogTextArea.setEnabled(false);
    }

    return dialog;
}

From source file:org.sigmah.client.ui.view.reports.KeyQuestionDialog.java

License:Open Source License

public static Dialog getDialog(final KeyQuestionDTO keyQuestion, final RichTextArea textArea,
        final FoldPanel panel, final int toolButtonIndex, final KeyQuestionState keyQuestionState,
        boolean enabled) {
    final Dialog dialog = getDialog();
    dialog.setHeadingHtml(/*from   w  ww  . j av  a  2 s.  c  o  m*/
            I18N.MESSAGES.reportKeyQuestionDialogTitle(Integer.toString(keyQuestion.getNumber())));

    // Question label
    final Label question = (Label) dialog.getWidget(0);
    question.setTitle(keyQuestion.getLabel());

    // Rich text editor
    final RichTextArea dialogTextArea = (RichTextArea) dialog.getWidget(1);
    dialogTextArea.setHTML(textArea.getHTML());

    final boolean wasValid = !"".equals(textArea.getText());

    // OK Button
    final Button okButton = dialog.getButtonById(Dialog.OK);

    okButton.removeAllListeners();

    if (enabled) {

        dialog.getTopComponent().enable();
        dialogTextArea.setEnabled(true);

        okButton.setVisible(true);
        okButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
                dialog.hide();
                textArea.setHTML(dialogTextArea.getHTML());

                final boolean isValid = !"".equals(dialogTextArea.getText());

                final ToolbarImages images = GWT.create(ToolbarImages.class);
                if (isValid) {
                    panel.setToolButtonImage(toolButtonIndex, images.compasGreen());

                    if (!wasValid)
                        keyQuestionState.increaseValids();

                } else {
                    panel.setToolButtonImage(toolButtonIndex, images.compasRed());

                    if (wasValid)
                        keyQuestionState.decreaseValids();
                }
            }
        });

    } else {

        okButton.setVisible(false);

        dialog.getTopComponent().disable();
        dialogTextArea.setEnabled(false);
    }

    return dialog;
}

From source file:sf.wicklet.gwt.site.home.client.WickletGwtSiteHome.java

License:Apache License

public void wikiEdit(final String href) {
    wikiGet(href, new WickletAjax.WickletAjaxCallback() {
        @Override// www . j a v  a2  s.co  m
        public void onResponseReceived(final Request request, final Response response) {
            CConf.debug("# getwiki");
            clearRightPanel();
            final ComplexPanel rightpanel = rightPanel.asPanel();
            final RichTextArea area = new RichTextArea();
            area.setHTML(response.getText());
            area.getElement().setAttribute("name", "richtextarea");
            final RichTextToolbar toolbar = new RichTextToolbar(area, new IToolbarHandler() {
                @Override
                public void save() {
                    wikiPut(href, area.getHTML());
                }

                @Override
                public void quit() {
                    showWiki(href);
                }

                @Override
                public void revert() {
                    wikiGet(href, new WickletAjax.WickletAjaxCallback() {
                        @Override
                        public void onResponseReceived(final Request request, final Response response) {
                            if (GwtHttp.Status.isOK(response.getStatusCode())) {
                                area.setHTML(response.getText());
                            } else {
                                showError(response.getStatusText());
                            }
                        }

                        @Override
                        public void onError(final Request request, final Throwable e) {
                            CConf.debug("ERROR: Revert failed: " + request, e);
                            showError("ERROR: Revert failed");
                        }
                    });
                }

                @Override
                public void editAsText(final String html) {
                    new TextEditDialog(60, 24, href, html) {
                        @Override
                        protected void onCancel() {
                            super.onCancel();
                            area.setHTML(html);
                        }

                        @Override
                        protected void onOK() {
                            area.setHTML(getText());
                            hide();
                        }
                    }.showAtCenter();
                }
            });
            toolbar.setWidth("100%");
            final Grid grid = new Grid(2, 1);
            grid.setWidget(0, 0, toolbar);
            grid.setWidget(1, 0, area);
            grid.setWidth("100%");
            rightpanel.add(grid);
            area.setSize("100%", String.valueOf(Window.getClientHeight() - topPanel.asPanel().getOffsetHeight()
                    - toolbar.getOffsetHeight() - 40) + "px");
        }

        @Override
        public void onError(final Request request, final Throwable e) {
            CConf.debug("ERROR: Get wiki failed: " + request, e);
            showError("ERROR: Get wiki failed: " + href);
        }
    });
}

From source file:us.softoption.gwt.proofs.client.Proofs.java

License:Open Source License

public int getSelectionEnd(RichTextArea text) {
    //This is a hack to get the selection by putting a dummy marker around it then removing it   

    int end = 0;//  w  w  w . j  av  a 2 s  .com

    if (text != null) {
        Formatter aFormatter = text.getFormatter();
        if (aFormatter != null) {

            String fakeUrl = "H1e2l3l4o";
            String tag = "<a href=\"" + fakeUrl + "\">";

            int tagLength = tag.length();

            aFormatter.createLink(fakeUrl);

            String allText = text.getHTML();

            int startSel = allText.indexOf(tag);
            int endSel = allText.indexOf("</a>", startSel);

            String selStr = allText.substring(startSel + tagLength, endSel);

            aFormatter.removeLink();

            //There is a problem, if there was no selection, the text of the link will be
            // inserted as extra text changing it.

            if (selStr.equals(fakeUrl)) { // we have a problem (and we are assuming that fakeUrl
                                          // does not actually occur in the text
                selStr = ""; //We are going to return nothing

                allText = text.getHTML(); //start again with the altered text

                String beforeStr = allText.substring(0, startSel);
                String afterStr = allText.substring(startSel + fakeUrl.length());

                if (allText.substring(startSel, startSel + fakeUrl.length()).equals(fakeUrl))
                    allText = beforeStr + afterStr; // remove insertion

                text.setHTML(allText);

                //works, but removes focus (don't worry about it)

            }

            end = startSel + selStr.length(); //it's hard to get the end but this is one way

            //   allText=richText.getHTML();

        }
    }
    return end;
}