|
|
|
|
Re: using the compare API [message #294255 is a reply to message #294229] |
Tue, 08 November 2005 10:48 |
vijaishanker Messages: 60 Registered: July 2009 |
Member |
|
|
Vijai wrote:
> hi michael,
> thanx for the reply...I am trying to implement the compare feature by
> subclassing CompareEditorInput()
> The class which extends CompareEditorInput is as follows,
> class CompareInput extends CompareEditorInput {
> public CompareInput(CompareConfiguration arg0) {
> super(arg0);
> // TODO Auto-generated constructor stub
> }
> protected Object prepareInput(IProgressMonitor arg0)
> throws InvocationTargetException, InterruptedException {
> // TODO Auto-generated method stub
> return null;
> }
> }
> When i try to create a CompareEditorInput object out of the class,
> passing a CompareConfiguration to its constructor, it throws a
> nullpointerException at the place where i create the CompareConfiguration,
> Can someone tell me what went wrong, I am still a newbie in Plugin
> development...
> private void testTextMerge() {
> try {
> -> CompareConfiguration config=new CompareConfiguration();
> CompareEditorInput compare=new CompareInput(config);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> The line indicated by the arrow throws the nullpointerexception,
> thanks
> Vijai
I guess i figured out that anything thats got to do with CompareUIPlugin
throws a NullPointerException, for example creating a new
CompareConfiguration(), gets redirected to the method, new
CompareConfiguration(CompareUIPlugin.getPreferenceStore()); and this
statement throws a null pointer exception
Are there any prerequisites that need to be done before calling the
CompareUIPlugin.getPreferenceStore() method, like for example(creating an
empty file somewhere on the file system or calling some other method
before it)
I am attaching the Stack trace of the exception
java.lang.NullPointerException
at
com.vijai.matrix.plugin.ui.Views.JPOCommitView.testTextMerge (JPOCommitView.java:268)
at
com.vijai.matrix.plugin.ui.Views.JPOCommitView.access$0(JPOC ommitView.java:265)
at
com.vijai.matrix.plugin.ui.Views.JPOCommitView$6.widgetSelec ted(JPOCommitView.java:239)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
The start of the exception points to the super() in the following code,
class CompareInput extends CompareEditorInput {
public CompareInput(CompareConfiguration arg0) {
super(new CompareConfiguration());
// TODO Auto-generated constructor stub
}
protected Object prepareInput(IProgressMonitor arg0)
throws InvocationTargetException, InterruptedException {
// TODO Auto-generated method stub
return null;
}
}
Any help or tips is appreciated,
thanks
Vijai
|
|
|
|
|
[RESOLVED finally]Re: using the compare API [message #294339 is a reply to message #294312] |
Thu, 10 November 2005 10:59 |
vijaishanker Messages: 60 Registered: July 2009 |
Member |
|
|
Michael Valenta wrote:
> You'll want to use a CompareEditorInput for that. As I mentioned in my
> previous post you should have a look at the ResourceCompareInput in the
> compare plugin. If you search for references to that class you will see
> how to open an editor as well.
> Michael
> Vijai wrote:
>> hi,
>> I have finally managed to compare 2 pieces of text and have managed to
>> diplay it on a dialog. For this I have used the TextViewMerger, but I
>> would like to open it on a editor page or the page similar to which
>> eclipse opens up "compare" results...Do i need to use some extension
>> point or is there any other way to display the result of the
>> TextMergeViewer...
>>
>> Thanq
>>
>> vijai
>>
thanks Michael,
I finally managed to get the compare editor open and show me the
differences, at first I was trying to use TextMergeViewer(subclass of
ContentMergeViewer) and it showed me differences good enough but it
wouldnt maximize and was always the size of a thumbnail,
Now I used the CompareEditorInput and it works fine now, but the colors
that were present in the TextMergeViewer are missing,but thats ok...
The code i used is as following,
class EditorInput extends CompareEditorInput {
public EditorInput(CompareConfiguration configuration) {
super(configuration);
}
protected Object prepareInput(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
Differencer d = new Differencer();
Object diff = d.findDifferences(false, new NullProgressMonitor(), null,
null, new Input("difference1"), new Input(
"difference2"));
return diff;
}
}
class Input implements ITypedElement, IStreamContentAccessor {
String fContent;
public Input(String s) {
fContent = s;
}
public String getName() {
// TODO Auto-generated method stub
return "name";
}
public Image getImage() {
// TODO Auto-generated method stub
return null;
}
public String getType() {
// TODO Auto-generated method stub
return "txt";
}
public InputStream getContents() throws CoreException {
// TODO Auto-generated method stub
return new ByteArrayInputStream(fContent.getBytes());
}
}
and the command that opens the Compare Editor,
CompareUI.openCompareDialog(new EditorInput(
new CompareConfiguration()));
thanks for the help,
Vijai
|
|
|
|
Powered by
FUDForum. Page generated in 0.03002 seconds