tags:

views:

261

answers:

5

Hello,

I'm writing a programm in which I need to generate a diff and display the result. Is there any GUI component out there, with which I can easily accomplish this task, or do I need to hack something for myself?

I'd prefer using a Swing component, but any other technology will be fine, too.

A: 

I know IntelliJ IDEA can do this, and they've recently released an open-source community edition, so the code is in there somewhere. It will probably taken a bit of digging to find the relevant code though!

http://www.jetbrains.com/idea/free_java_ide.html

The code is all available here (via GIT or on the web): http://www.jetbrains.org/display/IJOS/Download

Nick Fortescue
A: 

As far as i know there is no component for this. Any modern IDE does this job today, also source control plugins have this function, many of them are open source so you can get the idea by viewing them. But it would be hard.


@madlep has a solution with Difference algorithm for Java check this topic:

http://stackoverflow.com/questions/319479/generate-formatted-diff-output-in-java

JCasso
A: 

There is a diff tool available if you are building on the NetBeans platform.

If you can't use that, I don't think it would be difficult to create a basic one that uses HTML in a JEditorPane to display the results.

Chris B
Up to now, it is my preferred solution, to output HTML to a JEditorPane - as a related project I'm working on is also using HTML to generate and display the reports.As I can't use NetBeans, I decided to go with JDiff lib, mentioned in an earlier answer.Thanks for providing all the answers!
A: 

Maybe have a look at the JDiffPlugin for jEdit (it might be easier than digging Eclipse / NetBeans / IntelliJ source code).


Or have a look at the Java diff viewer Component? thread, it seems that someone had similar needs and you will find a solution based on incava.org's Diff implementation (the location of sources changed so I'm putting the new location below):

(For the Diff sources)
http://dawes.za.net/gitweb.cgi?p=rogan/webscarab/webscarab.git;a=tree;h=148dc26a7ff3ef6ff5ddc35b206

(For the DiffPanel sources)
http://dawes.za.net/gitweb.cgi?p=rogan/webscarab/webscarab.git;a=tree;h=f6b756fbe78c6f1be21a00cffbe

Pascal Thivent
A: 

If you need an industrial strength, quick-and-easy, commercial, supported solution --- checkout Guiffy. Its pure Java, Swing, and includes an API library with Frame or Panel GUI components.

http://www.guiffy.com

Bill Ritcher