Java: GUI component for displaying diffs? [closed]

醉酒当歌 提交于 2019-12-12 12:25:21

问题


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.


回答1:


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.




回答2:


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




回答3:


Take a look here .

I used Diff.java to create a JPanel that will show the differences between two files.

Hope it will help !




回答4:


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




回答5:


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):




回答6:


https://github.com/albfan/jmeld

JMeld, A visual diff and merge tool.



来源:https://stackoverflow.com/questions/2019089/java-gui-component-for-displaying-diffs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!