Eclipse Forms Editor for XML - java

I'd like to program an editor for domain specific XML files which also has a form part (much like the PDE Manifest Editor or the editors of the ADT). Problem is: I don't really understand the code of these 2 examples.
My current approach is following:
Using EMF with an ECore model created from XSD. As Editor a Multipage Editor (one XML editor, one forms part). I don't exactly use databinding between the form and the editor, instead I reload the whole file on page change to the forms page (resp. rebuild the whole file on changing to the editor page).
Currently the XML files are pretty small, so this approach could work, but they can become larger and everytime to reload/rebuild the whole file seems pretty heavy (I'm also planning to use such an editor later for ODX files which can easily become larger than 5MB)
So is there any way to avoid rebuilding/reloading the whole file and just update the changed information in the datamodel?
Also, I'd like to have some kind of content assist (something like lightweight IntelliSense and more important ProblemMarkers)
Can this be achieved directly by using EMF or how can this be done?
Despite the fact that there are some really good resources about Eclipse forms and XML binding to Java, I can't find any resources for these handy Multipage editors.
Can you point me towards some directions. Maybe if EMF also isn't the solution, the project is still in the beginning phase, so I can switch to another library. E.g. for the upper mentioned ODX files I'm already using XMLBeans(in another, pure data mining/converting context), but I assumed EMF would provide some benefits since it is directly bound to the Eclipse project.

I recommend that you take a look at the Sapphire Project. One of they key usecases it covers is bi-directional editing between a form page and an XML source page. There is support for field validation, content assist, etc.
Sapphire Project's Website
Introduction to Sapphire

Related

Create custom Eclipse editor for only one project type

While browsing through the plugin "engine" of Eclipse I was wondering if it is possible to create a custom editor (implementation of EditorPart) which is used for all files of an extension but only if they are within a custom type of project? Let me explain my use case:
I use XML files for UI development together with some scripting language. Now I would like to make a plugin that offers realtime rendering of the current XML in the editor and some kind of WYSIWYG editing behavior. But of course this should only happen if the project is one of my custom project types that has these files. Browsing through the documentation I only found ways to restrict it to file extensions but not file extensions within a project. Is there a way to do so?
Best regards and thanks for any help! Cromon
You can't restrict an editors use to a particular project.
You can bind your editor to a Content Type. You can then use a IContentDescriber to examine a particular file and determine if it is valid for the content type. So if you can identify your XML files from their content only you can do what you want.
There is already a XMLContentDescriber class that provides core code for examining XML files.

MessageResouce files in JSF

My application suppose to work with different languages. In order to provide this feature, I have created different messageResource files for each language.
Each resource files contain the same keys but values are different according to which language application is running. I load the specific language resource file on application load up.
This is working very fine.
However, as we are adding more features, the resource files for each language becoming very long, which makes it difficult to manage (edit) for non-techy person like Content editor guy.
Therefore, I would like to know, how can I redesign or remodularise in such a way that it will be easy to manage for Content Writers?
I hope I clear the scenario but please shout, if any thing needs?
I do not know a i18n standard mechanism in the Java world to split message properties in chunks. However, I have made good experiences with a standalone properties-edit-tool like jLokalize. It's pretty user-friendly even for non-programmers: hand over the properties files to the content writer and let him/her load the files in the editor.

Highlight and Edit XML in a browser

Trying to provide a user with editable XML page in a browser.
For example, the following is part of an XML.
<Employee name="John Doe" type="contract" ID="1000">
<Salary>10000</Salary>
<Email>johndoe#johndoe.com</Email>
</Employee>
When the above is presented to the user in a brower (either IE or FF), the user should be able to highlight an attribute or the value. When highlighted and the second mouse button is pressed, this would pop up a menu for editing. For attributes and tags, it could be something like ID-TEST-PRESENT or ID-TEST-OPTIONAL. Now instead of ID, the attribute should change to ID-TEST-PRESENT when selected.
Likewise, for values, a text box can be presented, where the user can enter a new value. Then this updated XML file needs to be sent to the back end and saved.
Is this doable? If yes, what would be the easiest way.
I have always written embedded applications. This is my first foray on the web browser side. Any help is appreciated.
It is doable of course, but it's not trivial. At least not for someone who is not used to Javascript and manipulating the DOM. You would have to parse the XML and create a HTML document with Javascript event listeners on each element.
You could try and use an existing component and modify it if necessary. I found a similar question here:
https://stackoverflow.com/questions/378205/web-xml-editor-with-xml-syntax-highlighting
Unless you are dealing with generic XML files, you are probably better off just reading the XML and generate a standard HTML form. The simplest way would be to base everything on a database that will export to XML to the backend processes if needed. This makes it much simpler to add/edit multiple rows of data
One way to to create an interface for editing information in a particular XML vocabulary is to use XForms. (I think it is by far the easiest and best, but YMMV.) Given an appropriate infrastructure (see below), using XForms for what you describe would involve:
Write a form, using XHTML + XForms. Specify editing widgets for the parts of the XML you want the user to be able to edit; make other parts of the XML read-only (or don't display them at all). Define how you want the edited data to be submitted. Style using CSS.
When the user opens the form, the XForms processor loads the XML document automatically and provides editing widgets as specified in the XForm you specified in step 1. The user edits.
When the user clicks on the submit button, the browser sends the data back to the server as XML, and software on the server performs the necessary validations (this is user input from the open web, you do want to check it) and processes it appropriately.
As you can see, it's a little simpler than rolling your own using AJAX (at least once you have the infrastructure set up).
What infrastructure is necessary for XForms depends in part on which XForms implementation you are using.
For client-based implementations of XForms (such as XSLTForms from AgenceXML, or Formula from EMC), you need (a) a copy of the software on your server (in the case of XSLTForms, this means one XSLT stylesheet, one Javascript library, and one CSS file), (b) possibly an appropriate link in the form itself (how this needs to be done varies with the implementation), and (c) a server willing to accept PUT requests. In some contexts, it will be (c) that is the hardest to get set up, but any server that provides a WebDAV interface will do, so SVN with auto-versioning, Apache (alone or on top of Subversion), and other tools can all be used.
For server-based implementations (such as Orbeon Forms or BetterForm), you need to install the XForms implementation and run it on your Web server; since they are typically servlets, you will need to put them in a servlet engine. In general, they will ship with some form of WebDAV server included.
Steven Pemberton of W3C and CWI has written a helpful tutorial introduction to XForms; I maintain a list of pointers to that and to other XForms-related materials that may also be helpful.
In order to do this you would need to work a lot. To do generic editing you would need the following
XML parser at back end to parse XML file to 2 formats (A) To convert to the required HTML format for front end. (B) To convert into a required backend format. This is tricky and requires some thought. A brute force method is easy but very inefficient.
Setup an AJAX connection to your script which can take and recognize parts of the XML. For this you will need some mechanism to identify the part... may be an ID passed though HTML.
The interface for AJAX should the update the Database/file and do the needful.
This is a simple layout. It needs a lot of work to be done. Do some research
item
codemirror seems to be the best one
The jquery.xmleditor might be what you are looking for. They offer a graphical UI for editing XML. For the text-based XML editor, they rely on the Cloud9 editor. Be aware that Cloud9 is GPL licensed.
LiveXMLEdit is more an explorer-like editor, but maybe it helps, too
AXEL is a library for creating XML authoring applications based on document templates.

Does it exist: context aware, autocompleting, XML editor with API for including into my app

I need an API-addressable, Java-based XML editor that is context aware. For instance, if you give the editor a schema for the XML document that is supposed to be generated, then, as the user is editing the XML, they will have access to recommendations and autocomplete for XML elements and attributes.
You haven't said what environment this should run in...
Assuming Java, the netbeans editor is very solid and it should be possible to embed it in external Java applications. Obviously, that would involve brining a large portion of netbean's code along with it though.
I haven't used it, but it looks like Jaxe might be provide a solution as well.
Something else to look at would be oXygen. The Author component can be integrated into a web application as a Java Applet.
http://www.oxygenxml.com/xml_author.html
Example:
http://www.oxygenxml.com/demo/AuthorDemoApplet/author-component-dita.html

A solution to highlight some parts of a text file in java ? How to implement a simple DSL editor?

I'm trying to find a solution to highlight part of a text file in Java.
Basically, what I'm doing is lexing and parsing a text file respecting a certain grammar, storing some information related to the various elements of this file and then logging the information to a database.
I would like to have something more visual like a representation of the text file with some parts highlighted (and an index of the various colors used) - or even better with some context-sensitive information attached to a particular token.
Is there an easy way to do so? Basically what I would like to have, in terms of features, is a really primitive Eclipse plugin for a particular language and stand-alone. Maybe there's a framework to build DSL editors, something like that.
Hope it is clear...
Thanks
I think Xtext is just what you are looking for, it generates an Eclipse editor and more from a grammar.
Although not for Eclipse, there's MPS by JetBrains (the makers of the now open source IntelliJ IDEA) which may be worth taking a look at:
http://www.jetbrains.com/mps/

Categories