NatTable - copy & paste cell data with line separator inside cell - nattable

My copy & paste works well for Nattables. Problem comes, if some cell contains line separator. When I paste data, line separator is taken as a row separator and structure of my table is destructed.
In CopyDataToClipboardCommand.class:
public CopyDataToClipboardCommand(String cellDelimeter,
String rowDelimeter, IConfigRegistry configRegistry) {
this.cellDelimeter = cellDelimeter;
this.rowDelimeter = rowDelimeter;
this.configRegistry = configRegistry;
}
cellDelimeter is set to \t and rowDelimeter is set to \r\n.
Inside problematic cells is new line set with \n. Any idea about this?

If you talk about pasting to Excel for example, then the issue is not in NatTable, it is in Excel. Excel treats a new line character as a row delimiter. The configuration in CopyDataToClipboardCommand is used to add that character for ADDING a new row.
If you want to be able to copy cell content that contains new line characters and paste it in Excel, you probably need to override CopyDataCommandHandler#internalDoCommand() and use a custom serializer that replaces the new line characters in the cell to something Excel can handle. Actually I don't know what character is treated as a line separater inside a cell in Excel. I probably would replace it with a simple space then.

Related

JTextArea appending and deleting problems

I have a jTextArea that displays the clicked item from a jTable. I have a running code already and I am able to display the strings into my jTextArea. However, I have an issue whenever I try to remove a string.
So far, below is my code for getting the string value from the clicked item in jTable:
c = jTable2.getModel().getValueAt(jTable2.convertRowIndexToModel(selectedRow), 1).toString(); // this will get the name of product from a table and store it into C variable
The string from above code will be displayed on my jTextArea, as shown below:
jTextArea1.append(c + "\n");
Now, whenever I click an item to my jTable this will be stored into c variable, and the new item will be appended on my jTextArea with next line.
My sample output in jTextArea of this will be:
Apple
Mango
Now, I want to delete a specific string from that jTextArea, which I am able to do so in my current code. I am using this line of code to do that:
jTextArea1.setText(jTextArea1.getText().replaceAll(c, ""));
But then, whenever I clicked my jTable once again to append a new item, it will be appended next to the empty string, sample output is like this:
// from here is the beginning of the jTextArea
Mango
Apple
Now, I got empty strings before the new text is displayed.
In conclusion, I have understood that I never deleted an item from my jTextArea, but what it did was only to replace the string into an empty one. My problem is that I want to be able to append a string, then delete it whenever I need to do so without affecting the other appended strings, and without having an empty string.
Is there any other way to achieve this in replacement of my "replaceAll" line of code?
What you are asking for is analogous to editing a line of text to delete something in the middle. Naturally, you usually do not want a gap. One way to do this would be to copy the line over character by character but with a rule that if a space was preceded by a space it will not be copied (or, if a space comes up and is copied, then only characters will be copied that are not a space in that instance).
You could copy a series of records by reading each string, checking whether it had only spaces in it, and adding that string to the second screen only if it was other than white space.

How to display Text in new line in CoDesys visualization

In CoDeSys visualization, how to display Text in newline.
I have a csv file which reads by CoDeSys and display the csv column text in CoDesys rectangle text block.
In csv file I tried giving $N, \n\r,\n, no chance
To define a new line you have to type '$N'. Example: 'Hello$NWorld'
I hope it works!
From:
http://infosys.beckhoff.de/english.php?content=../content/1033/TcPlcControl/HTML/TcPlcVisu_edit_configElement.htm&id=
one learns:
"With the key combination Crtl+Enter you can insert line breaks, with Crtl+Tab, tab stops."
So, press Crtl+Enter to start a new line and check how CoDeSys separates lines. Hope it helps.

To get the content of first two lines from UITextView without using next line object

I need to get the two lines of content from uitextview, but without using nextline.. I entered the text continuously on uitextview without press enter the line goes to second line automatically. when I print those text it is showing single line. But the content is two or more than two lines. How I can get that content from UITextView.
You need to count (roughly) number of characters that can be entered in a single line.
Then using modulo and division you can find number of lines the text consumed.

Matlab text object carriage return issue + text outside graph

I'm trying to show some text on top of a plot. Using
text(13,15200,('~ 12h'),'HorizontalAlignment','right','VerticalAlignment','middle','FontSize',10,'FontAngle','italic');
I can create the text box how I want it. But a thing I didn't manage to do is to create a carriage return within that text object. Already tried to add '\r' or '\n' but the only thing I get is the display of '\r' or '\n' with out breaking the line. Any ideas?
And i now that text object are used to put text WITHIN axes. But I am still trying to find a way to put some text outside the grap. Searching stackoverflow I found this Post about using UICONTROL. It works great but when I export to EPS the text seems to be in pixel format and NOT vector - so it looks really bad. Is there another way besides using uicontrol??
Thanks a lot for help!
In text that is not interpreted, you can specify line breaks using the carriage return character, which has the ascii code 10.
text(x,y,sprintf('break after this%snew line here',char(10)));
To allow text outside axes, you need to turn off clipping for the text object
text(x,y,.....,'clipping','off')

Multi-line button labels

Is there an easy way to have two lines of button.text where you specify each line individually? Also, there seem to be large margins on the buttons so the text font needs to be quite small to fit. Is there a way to allow the text to use more of the button area?
The way I would do a two-line text implementation is:
Dim t1,t2 As String
t1="This is line one"
t2="This is line two"
...
MyButton.Text = t1 & CRLF & t2
The CRLF performs a Carriage Return and Line feed thus splitting the text up
I can't help with the padding issue though. Have you tried changing the font size?
MyButton.TextSize=9