Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CompareEditorInput(how to compare 2 string)
CompareEditorInput [message #1065845] Thu, 27 June 2013 18:28 Go to next message
Chien-Yu Chen is currently offline Chien-Yu ChenFriend
Messages: 2
Registered: June 2013
Junior Member
I am trying to compare two text (read from a file, perform some manipulation on the text without saving it. so I store the text in two String). now I extend the compareeditorinput

public class MyCompare extends CompareEditorInput {

private DiffNode diffNode;
private String text1;
private String text2;

public MyCompare (CompareConfiguration configuraion, String orig, String current) {



protected Object prepareInput(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
// TODO Auto-generated method stub

CompareItem left = new CompareItem(text1);
CompareItem right = new CompareItem(text2);

diffNode= new DiffNode(left, right);
return diffNode;


when I call
CompareUI.openCompareDialog(new MyCompare(configuration, ((MyEditor) editorPart).originalText(), ((MyEditor) editorPart).currentConverted()) );

to show the difference, it shows the difference line by line. ie

line1 test_line
line2 line1
line3 line2

it's going to show all lines are different, not treating the lines as a block. Please let me know where I am doing wrong. thx
Re: CompareEditorInput [message #1733401 is a reply to message #1065845] Fri, 27 May 2016 02:12 Go to previous message
Mehdi Alouache is currently offline Mehdi AlouacheFriend
Messages: 9
Registered: April 2016
Location: France
Junior Member
The answer is a bit late, I agree. But in this case, the Differencer.RIGHT field should be called in the declaration of your new DiffNode(). Only the different lines will be highlighted.
Previous Topic:Create a IFolder on a project with an extra level
Next Topic:Zooming Application
Goto Forum:

Current Time: Thu Oct 27 22:46:58 GMT 2016

Powered by FUDForum. Page generated in 0.06825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software