[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Urgent Need Help

Hello,

I'm trying to write a diff program using Eclipse but I keep getting Null pointer exception from this line:

CompareConfiguration configuration = new CompareConfiguration();

Is there anything special I have to do before calling the above ?. Please be specific, if you can provide me with a fixer that would be very appreciated.

I'm attaching my code below.

TIA,

John

----------------------------------------------------------------------------
import org.eclipse.compare.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.compare.internal.*;
import org.eclipse.core.runtime.CoreException;
import java.io.*;
import org.eclipse.swt.graphics.Image;

class Input implements ITypedElement, IStreamContentAccessor {
	String fContent;

	public Input(String s) { // parameters are not complete
		fContent = s;
	}

	public String getName() {
		return "name";
	}

	public Image getImage() {
		return null;
	}

	public String getType() {
		return "txt";
	}

	public InputStream getContents() throws CoreException {
		return new ByteArrayInputStream(fContent.getBytes());
	}
}

class TestMe {
public static void main(String[] args) {
// IJavaElement cu1 = JavaCore.create("a");
// IJavaElement cu2 = JavaCore.create("b");

// IResource file1 = cu1.getUnderlyingResource();
// IResource file2 = cu2.getUnderlyingResource();


IStructuredSelection selection = new StructuredSelection(new Object[]{new Input("file.txt"), new Input("file2.txt")});
CompareConfiguration configuration = new CompareConfiguration(); <----
configuration.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false));
ResourceCompareInput input = new ResourceCompareInput(configuration);
input.setSelectionTwoWay(selection);
input.initializeCompareConfiguration();
CompareUI.openCompareEditor(input);
}
}