[brailleblaster] Re: How can I test whether a StyledText has changed?

  • From: Chris von See <chris@xxxxxxxxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Fri, 10 Jun 2011 09:14:34 -0700

Here are some rough examples/explanations of how to implement undo/ redo on an SWT StyledText control:


http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWTUndoRedo.htm
http://java-gui.info/Apress-The.Definitive.Guide.to.SWT.and.JFace/8886final/LiB0099.html (search for the word "undo"

and a simple editor that implements undo/redo:

http://www.java2s.com/Tutorial/Java/0280__SWT/Asimpleeditor.htm


Cheers
Chris



On Jun 10, 2011, at 9:03 AM, John J. Boyer wrote:

Susan,

Lots of information and good points. BrailleBlaster will have algorithms for making an xml or utd (Universal tactile document) file from the two
views.

The lack of undo in StyledText could be a problem. I am not sure how it
could be added. I think we would have to copy the code and then modify
it. This would be a new BrailleBlaster class. I'm not sure what if any
problems there would be with doing this. We may have other reasons for
doing it, however. We might even contribute the new class back to
Eclipse.

John

On Fri, Jun 10, 2011 at 09:31:14AM -0600, Susan Jolly wrote:
I'm not sure this is the right question to be asking at this point. Based on the discussion a few days ago, it seemed that you wanted to somehow associate the text that a StyledText widget edits to what Chris called the
other day your "backing store."

With its default use, StyledText makes a copy of your input and manages it with its default Content model. Any changes are made to this copy. You can, of course, obtain this possibly changed copy via getText() and do anything you want with it.(The SWT TextEditor example shows how to save it to a file.) However, the copy, changed or not, is obviously not connected to any "backing store." Styled Text also allows you to define your own
Content model by using its setContent().

You can add various Listeners including ModifyListener so the StyledText widget will inform you when it makes changes. StyledText doesn't support undo, although you could add it. Of course, if you do allow undo then you might want to add logic to see whether there are any net changes although this would probably be too hard. In my experience, most text editors think you've changed a document if you've done any editing even if in fact you've
effectively undone all the changes.

I've found two articles that are of some help in using the StyledText
widget but it's definitely not easy to understand.
http://www.eclipse.org/articles/StyledText%201/article1.html
http://www.eclipse.org/articles/StyledText%202/article2.html

HTH,
Susan





--
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities




Other related posts: