Community
Participate
Working Groups
If a String with formatting (tabs, new lines) is stored into an IMemento using putString(String, String), when the String is retrieved during IViewPart#init (IViewSite, IMemento), the "control" characters have been replaced with spaces. Currently impacts the Debugger DisplayView
It seems to keep the newline characters - from my simple test of opening the debug perspective, typing the following in the Display view: int i = 0; int j = 0; i = j; Exit and restart Eclipse, and the Display view still shows the three lines but not the leading tabs. Is that what you've noticed too? Since IMemento is simply making use of xerces plug-in, I'll have to check what can be done.
We have coded a major workaround in the DisplayView...not a good place to test ;-) See DisplayView#saveState() and DisplayView#getRestoredDocument() See bug 4937.
Can you look at what it takes to get xerces plug-in to keep the tab and new line characters? I'll forward you an e-mail with links to docs for this stuff.
Build: 20020205 As a simple test, I changeded the XMLMemento#putString(String, String) method to the following: public void putString(String key, String value) { if(value==null) return; String m,n; m = value; element.setAttribute(key, value); n = element.getAttribute(key); boolean x = m.equals(n); } I tested this by writing a few lines of code including tabs and newlines in the display view and shutting down Eclipse. Since DisplayView#saveState(IMemento) calls XMLMemento#putString(String, String) without first modifying the value String (other than trmming leading and trailing whitespace), putString takes as input the original contents of the view, including the tabs and newlines (except leading and trailing tabs and newlines). It turns out that the String fed to setAttribute and the String retrieved from getAttribute are equal (x is always true). All of the tabs and newline characters which are present in the input String are retrieved, so the xerces plug-in is not eliminating tab or newline characters.
There is one missing step to your test...the element's attribute was never written to a file and read again. Your test is succeeding probably because xerces has not applied some "filter" yet and probably does not until it writes it out to a file. For a simple test, hack the workbench save state code to add an attribute to an element which has tabs and newlines. In the restore state method, read this attribute and notice the tabs and newlines are gone now.
Date: 20020228 API released to stream: Added to IMemento in package org.eclipse.ui: public String getTextData() public void putTextData(String data) These methods are used to store Text (also known as Character Data) to an IMemento. Unlike the getString/putString methods of IMemento, these methods cause white space to be persisted. Each IMemento is allowed only one Text node. When putTextData(String data) is called, data replaces the previous value of the Text node of the IMemento. For example, if the following code was executed, then getTextData would return "World" afterwards. IMemento memento = new IMemento(); memento.putTextData("Hello"); memento.putTextData("World"); To use these methods, call putTextData(String value) and getTextData() where you would previously call putString(String key, String value) and getString (String key).