Displaying an XML string with formatting and syntax highlighting in an Eclipse RCP view - eclipse

I am currently stuck on what I feel like should be an easy solution, but I am not really getting anywhere with this. I am new to Eclipse RCP. I am trying to implement a view in which, all it does, is display a string, which has been formatted to XML. As in, my application does what it is meant to do, and when the user clicks Save, it saves all the info as an xml. I can get this xml as one long, unformatted string. I want a pane where the user can see (only see, not edit) the XML code that is going to be saved.
The reason I want a view is because this view is a multi-instance view, dependent on the perspective it is in. And I want it to display in XML format, with syntax highlighting. It would be nice for it to look like in an editor with line numbers and such, but with good formatting I am satisfied.
Does anyone know the best (any) way to implement this? Even some 3rd party widget is perfect for me.
Thanks!!

IIRC, the Plug-In editor example does basic syntax coloring and you can use the javax.transform packages to go from a stream to a DOM and back to a (formatted) stream.

just make your editor inherit from StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor.StructuredTextEditor)
For further details here:
FAQ How do I provide syntax coloring in an editor?
Platform Plug-in Developer Guide > Programmer's Guide > Editors

Related

Which eclipse listener should I use to add annotations to a text editor

I am an eclipse newbie. I have a long term goal which is to add my own annotations to the java editor: a bit like FindBugs. I want my own static code analysers, and to be able to add markers/annotations to resources.
So I have read a lot of excellent documentation, and undertaken a load of tutorials. The most helpful was probably http://www.ibm.com/developerworks/opensource/tutorials/os-ecl-commplgin2/section9.html. A lot of the Lars Vogel documents have been useful too. I can now make TextEditors with syntax highlighters. I am however struggling with the best approach for adding annotations.
I understand roughly how to do this: the text editor has a DocumentProvider. The DocumentProvider has an AnnotationModel. It is possible to add annotations to the annotation model.
My question is "where do I put this code" specifically the code that scans the text in the editor and updates the annotation model. It seems clear that this should be in response to a listener...but which one?
I have tried a ResourceChangeListener. This seems to only fire on a save option, rather than when text is typed. In addition I don't know how to get the editor from the resource. ("The" editor is probably a misnomer as presumably the resource can be open in multiple editors). I can find the current editor via IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(), but this seems the wrong approach, as I want to update all relevant annotation models.
I have tried adding an ElementStateListener to the text editor. None of the events seem to be the one I want.
I've looked at DamageRepairers...these seem to nearly be what I want, except that long term I want to tie into the JavaEditor, so I don't want to change the default DamageRepair.
Thanks for all the help
I found that this question can be answered, by mentioning the following resource: www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide/index.html
The question author also mentions here:
I add the annotations to the resource, and the annotations are
auto-magically added to the editor.
So when my plugin starts I run through the active resources, add
annotations to them if needed, then add a resource changed listener
which adds them as the resource is opened.

Integrate Text Editor With IPad App - Objective C

I have an app for a text editor developed by OMNI Group. I need to integrate this text editor with one of my other apps. I have no idea as to how should I do it. Can someone provide me any directions as to how should I begin with it. I googled a lot but could not find much help. Thanks and regards.
1: Assuming that your text editor is an online editor living in a browser, simply implement a UIWebView and it should just work. For example, an editable <textarea> is rendered without problems in a UIWebView.
If you need other special features you have implemented with javascript and the like you need to test if they work in the UIWebView.
2: If, however, the text editor is already working in another iOS app, simply copy the classes that you are using to implement the editor into your new project and use them in an equivalent way, tweaking where necessary. If you followed the programming principle of incapsulation this should be a breeze.

how to create an editable components for GEF Eclipse

I want to create a component kind of Text Box for GEF Eclipse.
I am able to create component but not able to make it editable. How to achieve the desired.
In GEF there is direct edit mechanism that can be used for these for these kind of purposes.
When you double click the editpart, it should create direct edit request. I believe this request is then by default send to the request to EditParts editpolicies.
So you should probably install this direct edit editpolicy and that returns cell editor.
It might be that actually installing the direct edit editpolicy provides you the text editor when double clicked, and all of this parts can be modified if the outlook of default implementation is not good.
I checked that it seems that there isn't easy examples about the subject, but there was some talks that "logical" example contains direct edit support.

TinyMCE writes terrible HTML!

I've currently got TinyMCE incorporated into the backend editor of a simple blogging/page-editing app, but I'm extremely unhappy with the HTML code it creates. It does all sorts of messy things like:
Adding inline style information to span tags that you can't ever find to get rid of without editing the HTML directly.
Nesting tags in nonsense ways (e.g. <p><strong><p><span>some text</span></p><strong></p> just to make something bold.)
Adding empty <p> </p> lines where they don't belong and I'm not trying to create blank lines.
EDIT: I've looked at lists of the other editors out there (including on SO), but I want to know if people firsthand have had better luck getting clean code out of their wysiwyg editors.
Any recommendations for one that outputs better code behind the scenes?
How about a rather drastic alternative, and using a WYMIWYG (What You Mean is What You Get) editor rather that another WYSIWYG editor. That way the author is in full control of the schematic markup as well as the content he/she is entering.
Unfortunately I haven't found one that is as feature rich and usable as tinyMCE, but it seems to have come a long way - see http://www.wymeditor.org/demo/
Use HTML purifier before saving the content into the database.
HTML Purifier
I found JoomlaFCK to be a very good alternative to Tiny MCE.
Hope you like it.
bye
BTW I know it is an old thread but someone might use it. ;)

Developing a GUI Builder Application

I am looking for a nice framework for developing a GUI builder Application. We have an application where 100Os of custom data entry forms and their print formats are required and each client will need some modifications on these. We have a developed a product using java based open source templatnig frameworks so that the layout and field definition are stored in database and rendered dynamically to the user. We also have an appication to design these forms but cannot do visual design.
Now I am trying to make a Visual Form Designer application for generating these forms. Can any one suggest some open source frameworks than can be used? Can I use Eclipse Visual Editor? Or is it better to develop some kind of parser for HTML using AntLR and then parse the HTML output from already existing GUI builders like Dreamweaver to get the desired output?
Thanks and Regards,
-- Kannan
Oooh, great question!
I wouldn't know any readily availble framework that you can use. Depending on your needs however, I think rolling your own shouldn't be too hard.
First of all, you probably wouldn't want to give the users too much freedom. Freedom only gives them the opportunity to mess things up and make the resultant forms hard to use. I think from your description that the fields are pre-defined, so that the user only needs to customize which fields appear on a given form, and in what order. Order can be a simple thing like top-to-bottom. Some semi-intelligent automatic layouting could be used to conserve screen space. Adding a feature to group fields together would probably also be useful, and grouping would lead to some kind of standard "group" widget.
Accepting simplified functionality like this, you don't really need the flexibility of a full gui editor. A couple of listviews, maybe a property sheet and a preview window will be enough to give your users the functionality they need.
Of course, this only holds for screen forms. Print forms may be trickier to layout, as people may want to cram as many fields as possible into very little space so the entire form can fit on a single page or something. I really don't have any suggestions for you there, but maybe a similar "simplified" approach with some intelligent auto-layouting could work.
Overall, my advice would be: Keep It Simple! (S... ;)