Eclipse plugin to view image while debugging - java

Is there an Eclipse plugin that will let me view an image variable while I'm paused at a breakpoint? e.g. I would like to see the image when inspecting a BufferedImage object instead of seeing it's toString value.

The extension point org.eclipse.jdt.debug.javaLogicalStructures is used to provide the structured view of variables in the "Variables" view... and unfortunately it can only give you a string based result.
In theory, you can add a new plug-in which adds a new command to the "Variables" view (the selection is of type JDILocalVariable)...

Related

How does the search view even get rendered?

I have been digging around in the search view source code for quite sometime now trying to understand how exactly does the search view even have a user interface to be rendered. First of all here is the source code:
SearchView source code
So what I don't understand is how does the user interface element of the search view even get rendered when the search view doesn't even have any onDraw() method. All that I can see is responsible for the display element is a bunch of view at the start which are in the constructor, the SearchView gets a reference to and change the background and set the image of these view. If all that I can see was done is getting references to some views and changing the background as well as the image without having it within the proper view hierarchy then how exactly does it even get rendered?
I understand what you are probably wondering why do I even need to understand this. Well I want to understand this so I can create my own custom search view. Since I only need like 2 function on my search view I figure it would be a lot better to make one that suits my need instead of the thousand of lines of code in the source one. Plus, I want to create one that I know I will understand how to use not the complex default one.

How do I show quick fixes when I hover over an error in my custom editor

I've written an eclipse editor for my own DSL. When an editor is opened or saved I check the contents and create problem markers for any syntax errors. The markers show up in my editor as expected, and also in the Problems view.
I've got an extension point org.eclipse.ui.ide.markerResolution and provide an implementation of IMarkerResolutionGenerator which creates resolutions for problem markers. This works fine; when I right click a problem in the Problems view the Quick Fix option shows in the context menu and works fine.
My editor extends SourceViewerConfiguration and I override getQuickAssistAssistant(), returning an extension of QuickAssistAssistant. This allows me to right click a problem in the editor and see the Quick Fix option in the menu.
I'd really like to get the quick fix resolutions to appear when I hover over the problem in the editor, just like in the java editor. Currently just the problem text appears in the tooltip. Is there a seperate hook into this or should it be covered in two quick fix hooks I've already implemented?
I had the same problem and found a solution for myself: How to implement Quick Fix / Quick Assist for custom eclipse editor?
From what I've understood, Markers show up in the Problems View and Annotations show up in the editor (on the ruler and on mouse hover).
I use the org.eclipse.ui.editors.annotationTypes extension point to register my own annotation type and the org.eclipse.ui.editors.markerAnnotationSpecification extension point to specify the look and feel. In my custom SourceViewerConfiguration class I override getAnnotationHover(...) to return a DefaultAnnotationHover object and getTextHover(...) to return a DefaultTextHover object, so the annotations are shown in my source viewer.
To create annotations, you could use org.eclipse.ui.texteditor.SimpleMarkerAnnotation, you can construct a SimpleMarkerAnnotation passing a marker object to the constructor.
Then you need to add the annotation to the annotation model. You can use getAnnotationModel() on your SourceViewer and then addAnnotation(Annotation annotation, Position position) on the AnnotationModel. All annotations in the model will be shown in the editor.
You could also use org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel as your annotation model. Then you won't need to create annotation objects first, since AbstractMarkerAnnotationModel provides a method addMarkerAnnotation(IMarker marker).
Have a look at the IAnnotationModel interface.

Eclipse PDE: Custom QuickFix only available in Problems View?

i am having trouble with custom quick-fixes, which i want to provide in my Eclipse plug-in, and i'm hoping for someone more experienced than me in Eclipse PDE to have some hints for me on this issue.
As i have understood, i can provide custom so-called "quick fixes" (or "resolutions", in Eclipse inside terminology), by extending the extension point org.eclipse.ui.ide.markerResolution for a specific marker id, such as for example some default Eclipse marker, org.eclipse.core.resources.problemmarker.
This works for me for the default marker types and for custom marker types, BUT:
The QuickFixes, which my IMarkerResolutionGenerator provides, are only accessible from the "Problems"-View, not from the Editor, in which my markers show up.
What i have: I create markers in the default text editor, which causes (1) an icon with the markers tooltip message to show up on the left editor ruler at the line, which the marker is assigned to, (2) a marker on the right side of the editor, (3) some underlined characters in the editor, and (4) an entry in the "Problems"-view.
What i want: Just like in Java IDE support, i want to press Strg+1, or Context-Menu->Quick Fix, or to click at the error icon on the left-side-ruler, to see the available quick-fixes and to select one.
However: Only in the Problems-View am i able to get the Quick-Fixes, by pressing Strg+1 or from the context menu.
Is this the normal behaviour, and do i have to access another extension point, or the specific editors features, to hook my quick fixes into them? I haven't found anything much detailed about it, except that everybody seems to be pretty happy with this only extension point that i have mentioned above. What am i missing?
For completion, here is my extension point definition:
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
class="com.markers.test.MarkerResolutionGenerator"
markerType="org.eclipse.core.resources.problemmarker">
</markerResolutionGenerator>
</extension>
I have the same problem and I'm not sure, if this is the right way, but at least it works:
If you want to see your quick fixes in the source viewer you have to set an QuickAssistAssistant for it. In your class implementing SourceViewerConfiguration override getQuickAssistAssistant. You can instantiate org.eclipse.jface.text.quickassist.QuickAssistAssistant, but you have to set a QuickAssistProcessor, so implement the org.eclipse.jface.text.quickassist.IQuickAssistProcessor interface, especially computeQuickAssistProposals to return your quick fix proposals.
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
IQuickAssistAssistant quickAssist = new QuickAssistAssistant();
quickAssist.setQuickAssistProcessor(new MyQuickAssistProcessor());
quickAssist.setInformationControlCreator(getInformationControlCreator(sourceViewer));
return quickAssist;
}
Also have a look at the code in the last post here, it is a bit messy, but you will get it. And look at this code here for an example implementation of ICompletionProposal, which you will have to return in your QuickAssistProcessor.
If you simply add one line to the marker extension point:
<super type="org.eclipse.core.resources.textmarker"/>
and add attributes to the marker
marker.setAttribute(IMarker.CHAR_START, ...);
marker.setAttribute(IMarker.CHAR_END, ...);
You will be able get this:
But I still can't found how to change marker icon (to variant with bulb) a show possible quick fix also after click on the annotation icon.

passing a object to a rcp view

I want to do something like this pseudo-code
MyView v = new MyView(); //yeah, I know i can't do this
v.setObject(myObject);
v.show();
my case is: i'm using swtjasperviewer to show my reports, and i have to instantiate the report in this jasperviewer, which leave the view opened if the report has no pages...
I want to use a command to open a view, and pass the report to a view, this way, I can use a generic view.
thanks a lot
There are basically two ways to do this:
If the object is somehow related to the selection of another view or an editor, then you could use write a SelectionListener that gets the current selection, and then sets the correct object using the following method: getViewSite().getPage().addSelectionListener(mySelectionListener)
Otherwise, define an object that both your code and the view can reach (e.g. using a static attribute, an OSGi service or an Eclipse extension), and you can use that object to pass information. Your data source updates this object, and you can define a change listener/callback that the view can register himself to.

Eclipse RCP update a View after changes in the editor

i am new to Eclipse RCP and have the following Scenario:
One plugin which is the Application
Another witch is a view and does show
some Data
And a third which is the
editor.
in the view I can right click on a record and choose edit what does open the Editor and lets me change the data.
No I'd like to refresh the View when I save the Editor. I think this is a classical scenario to implement a Whiteboard pattern. Unfortunately I am not really familiar with it, may be some one could show a simple example how to implement it in Eclipse RCP.
Thanks in Advance
Johannes
Your view needs to implements IPartListener2 (http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IPartListener2.html)
you can override the method partInputChanged(IWorkbenchPartReference partRef) to refresh thw view in two ways:
1) If the plug-in with view has dependency to plugin with editor
If (partRef instanceOf YourEditorClass){
YourData yourData = editor.getInput().getxxx();
}
2) If the plug-in with view doesn't have dependency to plugin with editor
you need to use an adapter. You override the getAdapter method in the editor to return the Data that you need and the view get the data from the adapter
If (partRef instanceOf EditorPart){
YourData yourData = Platform.getAdapterManager().getAdapter(this, YourData.class);
}
Two codes are just an example to show the idea!
I hope I helped you
The view has to listen to the editor or - even better - to the edited model. If it listens to the editor, look for some "save" events. Personally I would make the model itself observable and notify listeners (like your view) of actual changes.
The view then needs some logic to extract its information from the model. So instead of a whitboard - the observer pattern should be the right choice for your design.
This is worth a try: add an IPropertyListener to the IEditorPart instance of your editor and wait for property changes. The IEditorPart.PROP_DIRTY property should change from "is dirty" to "is not dirty" after a save. Snippets/code example for eclipse rcp stuff are hard to develop and to communicate. Use the buzzwords from my answer for some searches on the eclipse help, API and on google. And: good luck ;) - btw, consider buying some good books on eclipse plugin/rcp development, they're worth every €/$ spent.

Categories

Resources