We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this questionI'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 usi开发者_Python百科ng a Swing component, but any other technology will be fine, too.
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.
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:
Generate formatted diff output in Java
Take a look here .
I used Diff.java
to create a JPanel
that will show the differences between two files.
Hope it will help !
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
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!
check here
and The code is all available here (via GIT or on the web):
https://github.com/albfan/jmeld
JMeld, A visual diff and merge tool.
精彩评论