How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel? - gwt

I have an HTMLPanel inside a FlowPanel which is inside a ScrollPanel like this.
<g:ScrollPanel>
<g:FlowPanel>
<g:HTMLPanel ui:field="showMessageHTMLPanel" width="600px"/>
</g:FlowPanel>
</g:ScrollPanel>
The showMessageHTMLPanel is used to hold the text that user enter a TextArea.
I want that the showMessageHTMLPanel should show exactly like how it was displayed in TextArea.
Ex,if user types in many sentences in new lines in TextArea, then the showMessageHTMLPanel should show similar like this:
This is text1
This is text2.
So here is what I did. I uses new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().
HTML showMessageHTML = new HTML(new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml());
getView().getShowMessageHTMLPanel().add(showMessageHTML);
The result is that It breaks the lines quite OK, no problem.
However, When I type a non-stop very long string ( a String that doesn't have any space on it) into a TextArea. Ex, see this non-stop string:
"Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."
As you saw, even this non-stop string has no space, but when typing in TextArea then the string will automatically fall into new lines.
Ok, now when I show that non-stop string in getView().getShowMessageHTMLPanel(), it showed the text as one straight line without any line break:
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
The user has to scroll the scrollbar to see the complete text. This is unacceptable since it is too hard to see the whole line. Also many urls are non-stop string without spaces. So the user may not be able to copy the url.
How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel?
Or
Do you know any other widget that can handle this?

I am sure, a simple css property should help.
word-wrap:break-word;
Detail here

Related

How can I balance text lines in flutter?

I am trying to achieve something similar to this in flutter.
Take the following text for example;
Some long text that should be displayed in
two lines.
I want it to be displayed like this;
Some long text that should
be displayed in two lines.
I can't simply do this by putting a 'new line character' \n to the string manually because it will be a dynamic string.
You can use RichText, or try to add "\n" operator. So it should look like "Some long text that should\nbe displayed in two lines."

String output to MS-WORD has too many new lines

This is my program window... The box in questions is the one labeled "INVESTIGATION" and "DISPOSITION".
When text is entered into the multiline textbox it is output in the DOCX file and it adds extra new lines... If a line is entered right below the original line it is a single extra new line. If it is spaced by one line it adds in two new lines. I figure it is something with the textbox properties or the output argument not playing well with the string. I have included pictures of the Form as it looks to the user. The builder code. The word document which shows the problem and the textbox properties. I want new lines in the investigation and disposition textbox to display how they are in the GUI and not have the extra new line. Any pointers?
I cant post images yet but you can view the images at the DOCX discussion board here https://docx.codeplex.com/discussions/658603
I hope its clear that I want it to display just as it is in the GUI:
A
A
A
should not look like it does in the last image where it is:
A
A
A
Thanks for all the help!

How do I get OpenOffice Writer Combo boxes to display multi-line text?

I am developing an OpenOffice Writer template that can be used to fill in reports for a child-care centre.
There are some standard outcomes, comprising long sentences, and I want the user to be able to select the appropriate sentence from a combo box. I have entered the sentences into a table in Openoffice Base database, which is then connected to a series of combo boxes in a Writer template. However, when the user choose an option that contains a very long sentence, only the text up to the length of the combo box is visible.
What I want to do is have the selected value of the combo-box wrap over several lines when selected so that all the (very long) text appears in the selected box when the user chooses a long sentence from the combo.
I have been looking through the properties of the combo box control, but have yet to identify one that will allow the selected value in the combo box to word-wrap (so that I could make the combo-box several lines in height such that the entire sentence would fit into the box).
Any pointers on how I could do this would be much appreciated.
thanks,
David.
Thanks Jim K, that was helpful. In the end, what I wound up doing was creating a textbox which I named "selectedOutcomeATextBox" immediately below my combo box which was named "OutcomeCombo".
I then attached the following macro code to the textModified event associated with the "selectedOutcomeATextBox":
Sub UpdateOutcomeA
Dim Doc As Object
Dim Form As Object
Dim Ctl As Object
Dim newCtl as Object
Doc = ThisComponent
Form = Doc.DrawPage.Forms.GetByIndex(0)
Ctl = Form.getByName("OutcomeCombo")
newCtl = Form.getByName("selectedOutcomeATextBox")
newCtl.Text = Ctl.Text
End Sub
I also set the "Printable" property of the "OutcomeCombo" to "No", so that when the document prints, the combo box itself does not appear on the printed page, but the "selectedOutcomeATextBox" textbox which has had its value set by the macro when I choose a value from the combo box does appear with the desired text. I also set the "TextType" property of the selectedOutcomeATextBox" text box to "Multi-Line", so that extra long text will wrap to the next line, thereby showing the very long strings that are stored there.
Thanks heaps Jim K.
cheers,
David Buddrige
Apparently combo boxes do not have the MultiLine attribute. The question was asked a few years ago here but was not solved.
One alternative that requires some macro programming is to use a single multi-line text field and then make a scroll bar button that changes the choice. Instead of a scroll bar, two buttons could be used to change the choice (Previous / Next), or even a list box control. Using a list box control in this way would have the advantage that they could see all the choices at once, like a combo box.
Another approach is to break up each sentence and display the parts across several lines of a list box. Then when one line is clicked, all the lines of a sentence are selected at once, using an event listener for the list box. This could be shown in addition to an ordinary editable multi-line text box, in case none of the answers in the list are wanted.
One more idea: Radio buttons can have multiple lines, so dynamically show radio buttons, one for each sentence. A dialog window could be displayed to hold the radio buttons. The result of the dialog would be used to fill the multi-line text field.
Or you could just live with the truncated sentences. Maybe it would help to make the control a little wider, or abbreviate the sentences.

tinymce removes line breaks so all text is in a continuous chunk with no paragraphs

I'm using TinyMce textarea editor and have a problem. As you probably know Tinymce transforms a standard html textarea into a rich text editor.
On our 'edit listing' page we call up some text from our db for the user to edit (previously in a standard textarea, now in the tinymce textarea.
Previously the standard textarea would preserve linebreaks and the user would get several paragraphs of text in the text area, now with tinyMCE they get a huge chunk of text with no linebreaks. (I have pasted an example of an entry in our db below - as you can see it has line breaks in it by tinymce seems to be ignoring them when it displays them in the editor).
Just to clarify my issue is now that tinymce is stripping something when I submit the form, it's that when I pull text (that contains line breaks) from the db and populate the tinymce textarea with that data (for the user to edit) in the tinymce textarea - the text appears (in the tinymce textarea) as one massive chunk of text with my paragraphs (whereas in a standard textarea it is nicely formatted with linebreaks)
Any help on how to resolve this would be greatly appreciated - do I need to use some sort of populate() type function to put the text in, or maybe I need to replace all the linebreaks with a different special character that tinyMCE will recognise as a line break and preserve?..
Thanks in advance.
Nick
example from db:
Here is line one
Here is line two
And here is line three
Which appears in tinymce as:
Here is line one Here is line two And here is line three
I faced a similar a problem, a while back and had questions just like yours. Also I finally ended up on SE just like you.
Anyway, I think I have the solution to your problem. If you are using PHP as your server side language, then you should use nl2br() PHP function.
Suppose you have stored your content fetched from the database in a php variable. Something like this:
$content = $row['content'];
Now when displaying it on to your screen, use the nl2br() function.
echo nl2br("<p>".$content."<p>");
Now, this part inside () depends on how you want to output the data. And I will leave it to you to figure that part out.
Hope this helps.

Eclipse-RCP: Hide lines of text permanently, keep correct line numbers

I have text files which contain code inside an Editor. The user can run an analysis on a certain part of his code, which will result in a set of lines which should be hidden. Next I want to present the user with only the remaining lines, but with correct linenumbers, as from the original document. Possible solutions I thought of:
Open a new Editor which does not contain the hidden lines, but *somehow* still has correct line numbers
Hide the lines in the original editor, and offer a button for the user to 'unhide'. Probably a similar solution required as in 1.
I don't really know how to go about this. Folds would be a weird solution, because they can be unfolded individually, and seem to be more semantically tied to things like methods or classes. Also, simply creating a new document without the hidden lines results in wrong linenumbers.
Use a ProjectionViewer and reflection to invoke the private method ProjectionViewer.collapse(int offset int length). This method is only used internally to hide a certain portion of the text, by manipulating the ProjectionDocument (see http://eclipse.org/articles/Article-Folding-in-Eclipse-Text-Editors/folding.html).
After this, folding text in the editor using the annotations(the little +/- icons) WILL break everything, so this solution and regular folding are mutually exclusive.