How to programmatically access an Eclipse JDT tooltip icon - eclipse

I'd like to use the icon "Quick Assist Available" (lightbulb) from Eclipse's JDT Icons.
However, I cannot find a way to access it.
The closest I've gotten was thanks at Ilya Shinkarenko's blog, where he uses ISharedImages to access many Eclipse logos. However, the lightbulb icon is not on his list and I can't find it's proper name anywhere (I'm not even sure if it's part of ISharedImages).
Do you know where I can get a hold of this icon within Eclipse and use it in my own tooltip?

Here is this in action using a Groovy script:
import org.eclipse.jdt.internal.ui.JavaPluginImages;
def image = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_QUICK_ASSIST)
def newView = eclipse.views.create("a button with an image");
def button = newView.add_Button().setImage(image);

You are looking for org.eclipse.jdt.internal.ui.JavaPluginImages.IMG_OBJS_QUICK_ASSIST.
A code snippet like JavaPluginImages.get(JavaPluginImages.IMG_OBJS_QUICK_ASSIST) should do the trick. (JavaPluginImages is not API hence you will get a warning in your code, but you can just ignore that)

Related

LWUIT menuBar refreshTheme not working?

I'd like to dynamically change the text of a Command depending on some state, so normally I went to Google and LWUIT blogs said that using refreshTheme() on MenuBar should do the trick.
So I used the following code, but it sadly didn't work
if (isPlaying) {
playButton.setCommandName("Pause");
}else{
playButton.setCommandName("Play");
}
this.getMenuBar().refreshTheme();
Is there something wrong with my code? Or did I misunderstand something?
It won't refresh. The text of the button is set when the command is placed so you can't do that.
You will need to use removeCommand(cmd) followed by addCommand(newCmd).
Furthermore, refreshTheme() has absolutely nothing to do with anything.

How to programmatically change help contents in Eclipse?

I have an eclipse plugin and I would like to programmatically disable help content TOC's based on a variable I define. In a nut shell, I want to prevent some help docs from showing up in the help contents if a specific type of user is accessing the plugin.
Preferably I would like to do this in the ApplicationWorkbenchAdvisor somewhere.
One thought would be to modify the "primary" value to be false if the variable were set.
Not sure if it would work, but try using the org.eclipse.ui.activities extension point. The tutorial from Vogella tells it is possible to hide only UI elements like wizards, views and so on, but it is from 2009.. Not sure if hiding TOC is now possible. If you try it out, would be nice to give a feedback ;)

How to get the screen dimension of a eclipse view and IJavaElement

I writed an eclipse plugin that visualize some Java classes as UML in a view part. You choose a package in the Package Explorer and after rigth click on the package you can visualized it by clicking on a self created command menuitem in the menu. The visualization is created with the prefuse library.
My next goal was to make it possible to use it for multitouch. I use the Multitouch Library from PQLabs multitouch SDK. Now, on a multitouch screen, I can move my UML model, resize it etc.
But I was not able to get the informations from the Package Explorer. I tried to find out the location of the Package Explorer and IJavaElements on the screen but failed. My idea was to compare the x and y points from my finger (which I get from the PQL Labs SDK) with the x and y coordinates from the IJavaElements. I failed from the start, I could not be able that a touch point recognizes if it is in the border of the Package Explorer view or not. The only thing I got was the bounds of the whole Display. I searched the internet and stackoverflow but did not find something that was useful.
I do not know if it is possible or not but I will appreciate when somebody can give me information or directed me to good links.
I don't know much about the Package Explorer, but with the Project Explorer (Common Navigator) (which you should also address), there is a TreeViewer associated with it (in this case the class is CommonViewer). You can get that by doing CommonNavigator.getCommonViewer(). Once you have the TreeViewer, you can then get to the underlying SWT Tree and from there use the standard SWT methods to get the position of the tree relative to the enclosing window. There are also methods where you can get the bounds of a tree cell. Have a look at the SWT Snippets (Google it) to help you work with the Tree.
For the Package Explorer it will be similar; you will have to look at the source code.
As described in Francis' answer you should be able to get the TreeViewer, and TreeViewer#getControl() would provide the underlying control.
When you fetch the position and size of a control via control.getBounds(), those would be relative to the coordinates of the shell/window. If you need the absolute display/screen coordinates, see control.toDisplay(some_x, some_y)
I want to share my steps on how I solved my problem. After the advices I digged deeper into the jdt Java infrastructure of the Java IDE. To get the TreeViewer of the Package Explorer I had to cast the "PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.jdt.ui.PackageExplorer")" into a "PackageExplorerPart" which is in the "org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart". The further steps I did were:
treeViewer = packageExplorerPart.getTreeViewer();
tree = (Tree) treeViewer.getControl();
After that I created a "Point" with the coordinates x and y, which were passed by touching the screen. But, the point location were representing the whole screen and to get the correct coordinates for the Package Explorer I converted the point with the method tree.toControl(...). At last, I checked if an item was given with method tree.getItem(....).

disable back button on in ltk wizardinputpage

I'm doing a plugin in Eclipse IDE in order to do a refactoring. I'm using LTK, the point is: I don't know how I can disabled the back button after the preview. I've tried to create the RefactoringWizard using some flags like 'NO_BACK_BUTTON_ON_STATUS_DIALOG', but I think it is not the rigth way to do it.
The poblem I have in the background is that when I push preview and then push back, and preview again, the preview box shows the change related with the refactoring twice!.
I think the best solution is disabling the back button after the preview because this is the solution I have seen in others plugins.
Sorry because of my English and thanks beforehand.
The method org.eclipse.jface.wizard.WizardDialog#updateButtons disables the back button when currentPage.getPreviousPage() returns null. So, I suggest you to override the method org.eclipse.ltk.ui.refactoring.RefactoringWizard#getPreviousPage to return null.

Select and copy text from dialog in wxPython

I have a wxPython app, and in this app, I can select and copy text from various frames, but I can't do so from dialogs. Is there a way to do this?
I understand I could probably do this by putting some kind of TextCtrl in the dialog, but I'd like to be able to do this from a standard looking dialog.
EDIT:
Sorry, I should have been more specific. I can't select text from a wx.MessageBox under Windows Vista or Mac (don't have access to Linux to try that). Here is one example of the call to create the message box:
wx.MessageBox(str(msg), "Could not load ballots", wx.OK|wx.ICON_ERROR)
I am unable to select the text of the message box.
If you make a custom MessageBox like so, it will appear to be static text until you click on the text:
class MessageBox(wx.Dialog):
def __init__(self, parent, title):
wx.Dialog.__init__(self, parent, title=title)
text = wx.TextCtrl(self, style=wx.TE_READONLY|wx.BORDER_NONE)
text.SetValue("Hi hi hi")
text.SetBackgroundColour(wx.SystemSettings.GetColour(4))
self.ShowModal()
self.Destroy()
I've only tested this on windows, you might have to adjust the color for your OS.