Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphical compare of two text files

 
beda meda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a task of creating GUI comparator of two text files, something like WinMerge or the function in Total Commander. And what I'm looking for here is not any source code or anything like that, but some hints where to look for inspiration, some starting tips, etc. I never did anything like this before and I'm little confussed about where to start, if you can understand what I mean. I'll appreciate anything, hints, links, whatever you can think of.

Thanks.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NetBeans RCP (Rich Client Platform) has a Diff API and a DiffView which shows the difference graphically. But, this is part of the NetBeans platform and you would have to create a NetBeans platform application to use it.

Nevertheless, as you were looking for inspiration, I wanted to post this.

Also, the whole NetBeans platform is built on top of standard Swing components. So, that is itself an inspiration.

And the API is logically divided into 2 parts. First is the actual Diff API - this basically calculates the differences between 2 streams and stores the differences (in a class named, well, Difference). So, the diff calculating method returns an array of Difference (one Difference object for each difference). The difference here is calculated comparing lines. This can be used from a normal program without any GUI - say if you want to print the differences textually - like when we work with some version control systems. So, you will first have to develop something like that.

The DiffView is separate. This is a JPanel which then takes in the needed stuff (like the Difference[]) and then show the differences using colors. Same way, you can build the GUI separately which will then use the initial API you developed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic