Extending Existing Eclipse Editors - java

Is this possible?
Here is the problem I am trying to solve:
I have 3 configuration files one .ini, one .config, and one .json
Then I have a bunch of SQL files that have sort-of a customized version of sql in them.
I need to do some syntax validation on these files, and I also added syntax highlighting. In the performSave function I made a call to the validator.
It would be nice to have this update dynamically as you typed, but I couldn't figure that part out just yet.
My problem is this: most of these config files and sql files have our own special brand of syntax, but the JSON file is just a regular old json file so it seems silly to create my own editor and re implement syntax coloring for something so widely in use. I was hoping that I could just extend a current existing editor already in eclipse then just add my hooks where I need them.
Heres what I have done so far:
I created some Eclipse plugins for work ing with these files. Most notably I have created a .sql editor, a .config editor, and a .ini editor. So for the most part I know how to create an editor and do my syntax coloring and problem marking etc. I would just like to ride the coat tails of someone who has already created a JSON editor so that all I need to add is my validation calls.
If you have any insight into extending an existing editor that would be great.
Also any help with where to put my validator call to mark up files while they are being created except on a save would be awesome too.
-Best,
Jeff

Have you considered using Xtext to get a feature rich editor (on the fly syntax correction, code completion etc..) rather than implementing from scratch ?
For JSON, the grammar fits in a few lines :
https://gist.github.com/nightscape/629651
Just build a "New->Xtext Project", then stick this grammar into it and run as "Generate Xtext artifacts", you'll get an extensible editor in no time.
There is a feature to add validation rules checked on the fly easily using Java or Xtend.

Related

Java UML editable component/lib

I have a task where we need to generate UML(or similar) from XML and will be able to edit text, property type and drag dependency row. But I can't find any Java lib or component wich will allow me to do such.
For example PlantText is a good lib but it does not allow to make edit.
If someone known such lib/compoment please share.
Thanks
EDIT:
Sorry, maybe I wasn't wrote clear. Actually, I need library which I can implement into my project, and after I will be able to generate UML from my project, then edit it and save into XML.
draw.io is very good site where you can create (not only) UML's and save them to XML file so in future you can edit it. The drawback is it is not automatic and must be drawn from scratch.

Is the org.eclipse.ui.editors.templates extension point meant to be used for code templates?

I've created a new project wizard and it creates a blank file. I want the file to contain some sample code. I don't want to put the sample code there via a static String. Should I be looking to add the org.eclipse.ui.editors.templates extension point to my plug-in project or is this not its intended purpose? Based on what I've read, it sounds like it's perhaps only intended for code completion templates?
Well the JavaDoc for the org.eclipse.jface.text.templates package that provides this support says:
Templates are shortcuts for frequently used fragments of text such as
code patterns or complex text entities. They may contain variables
which are only resolved at the time when the template is inserted
within a context. Together with linked mode, inserting a template can
create a on-the-fly edit mask within a text viewer.
Templates are specified as text, variables are defined using the
${variable} notation known from Ant, for example.
So I think they can be used to insert any text.

Properties editor Ui to use in swt/jface application

I am currently working on a project where i have a need to integrate/build a properties editor (like Jboss tools properties editor open in eclipse for editing hibernate configuration files) in my desktop application. I was looking for some good ready to use UI plugin to just integrate in my application or with small changes in the source code of the plugin to make that working according to my needs. Can someone please redirect me to the right way.
Thanks
Take a look at http://www.eclipse.org/sapphire/
In the past, I was using Eclipse Structured Source Editing framework. It gives you extensible XML source editor (e.g. you get most source editor features like syntax highlight, code completion - but you can extend and customize those features) - and you can create an Eclipse Forms-based visual editor that would use the SSE XML DOM as a model (e.g. you may add listeners to DOM nodes - to keep your visual editor in sync with the modifications user makes to the source code.
I found a good SWT wrapper, which has provided some ready to use widgets, PropertyTable is one of them.
https://code.google.com/a/eclipselabs.org/p/opal/wiki/PropertyTable
Hope this will help others.
Hibernate configuration files are xml so you should be able to edit them with the standalone Eclipse IDE. When creating a Hibernate Configuration file you would just save it as configuration.cfg.xml and for hibernate class mapping files you would do className.hbm.xml.
I wouldn't say you would need a plugin to create and edit hibernate configuration files. Hibernate will know what to do with the file when it runs as long as they are in the correct build path.
I hope this helps or at least points you in the right direction.

Applying a new code template to existing java file

We have lot of java files which were developed using a code formatter ,code style (has copyright info) templates. Now we decided to update the formatter and style template. Is it possible to update all the java files based on the new code formatter and code style templates?
It is a tedious process to manually go and edit all copy right statements in the java files. So if we could do it quickly, it will be very helpful for us.
We are using eclipse v3.4 for our development.
Eclipse 3.4 is quite old, so I'm not 100% sure this feature is available...
Right-click on the project or package you want to format, and select Source > Format.
That will only apply the format settings selected in Preferences/Java/ Code Style/Formatter. It will not add or alter code or comments. You choose a template when you create a new class/file.
yes, manually this works with Ctrl-Shift-f, which autoformats the current code / class, with the formatting rules.
For full automatic reformatting via batch you need further answers. But beware sometimes the rukles can destroy the readability of some special classes.
I would prefer manually go throug all classes, and apply Ctrl-Shift-f.
During this you might see, than some formatting rules should be adapted.

Is there a tool for non-developers (translators!) to edit resource bundles?

What we do in our company to let our software be translated by external translators is ... well .. how to put it...
cvs co someModule
ant translation.export (behind this target there is a self-made ant task, exporting all resource bundles together as one big tab-seperated text file, columns: the different languages, each row all languages for one key)
Some VB tool does something with the file (you don't wanna know)
Translators work in Excel on their column
Someone collects and merges the translations
VB tool
ant translation.import
cvs commit
...
Best case: 2 weeks between 1. and 8., development goes on...
First question: How do you handle this?
My idea was to build a tool with a web-gui that allows translators to work directly on cvs module (checkout in background and commit on "save", maybe tagging in background). We started with implementation by trainees and got something like a proof of concept. Before we go on with development I'd like to know
Second question: Do you know of a comparable tool?
and/or
Third question: Would you use such a tool?
java also provides its own resource bundle editor.
You should use gettext and Poedit. Translations are kept in separate files.
We use Sisulizer to localize our applications (.NET), for what I see in the documentacion of the application, it also supports Java, maybe this can help you.
With Sisulizer you can generate a translation project that you send to translators and when they return you it translated you can import the translation directly into the project.

Categories

Resources