General Development

How do I find a class from Eclipse?

I see these $NON-NLS-1$ tags all over the place when I'm browsing Eclipse's source code? What do they mean?

They are meant to mark a string literal as not needing to be externalized (as
in, translated / localized). You will often see something like...

if(string.equals("")){//$NON-NLS-1$// do stuff}

...this would be a scenario where a string wouldn't need to be localized
because it is a string for the code to "manipulate", per se, over it being
part of a message to the user at the UI level.

I need help debugging my plug-in...

Are you getting errors like "Unhandled loop event exception" messages in your console with nothing useful after it? Make sure you have -consoleLog as a Program Argument in your launch configuration. You may also want to take a look at these runtime tools.

I'm using third party jar files and my plug-in is not working...

Did you add those jars to your project's Java Build Path? Do not use that project property page when developing plug-ins. You have two options.

Option 1: turn the jars into plug-ins
Use New > Project > Plug-in Development > Plug-in from existing JAR archive. That will turn one or more jar files into a single jar plug-in. For something like log4j you can then set up Buddy-Classloading, etc.

Prior to 3.2.1, you had to make modifications to the build.properties file. See bug 146042 (RCP export has problems with required plug-ins).

Option 2: include the jars in a plug-in

Use Import>File System to import the jar files into your plug-in project, say in the <project>/lib directory.

Use "Add..." to add the jars to the classpath section of the PDE Editor>Runtime tab.

Use "New..." to add "." library back (with no quotes, of course). Some versions of eclipse automatically do this for you.

Make sure your binary build exports the new jar files on the PDE Editor>Build tab.

Save

On the project, use the popup menu>PDE Tools>Update Classpath to correctly add the jars to the eclipse project classpath.

How do I read from a file that I've included in my bundle/plug-in?

The FileLocator class should be able to do most of the things that you want. It can open up a java.io.InputStream as well as provide a java.io.File. You should keep in mind that the java.io.File approach is not going to work if your bundle is packaged as a jar file. To get a reference to your bundle's Bundle instance, you can use Platform's getBundle(String) method.

User Interface

There's a view / editor that I want to model. How do I find out how it was designed?

Views and editors generally extend ViewPart and EditorPart respectively. Placing a breakpoint in its constructor when you show the view or editor will help you figure out what the class is composed of.

You can also invoke the "Plug-in Spy" with the Alt+Shift+F1 keybinding to retrieve information about the view or editor that your mouse is currently hovering over.

There's a preference / property page that I want to model. How do I find out how they designed it?

Put a breakpoint in the constructors of the PreferencePage / PropertyPage class. Open the preferences / properties dialog, and then select the page you are interested about. Now you can identify which class is constructing that page based on the stack trace.

You can also invoke the "Plug-in Spy" with the Alt+Shift+F1 keybinding to retrieve information about the page that your mouse is currently hovering over.

There's a window / dialog / popup that I want to model. How do I find out how it was designed?

There are two usual suspects, an SWT Shell or a JFace Window. Generally, most developers subclass's JFace's Dialog class (which is a subclass of Window) for their dialog needs. So you should first try and put a breakpoint in Window's open() method and see if the window you're trying to model stops at that breakpoint when it has been opened (shown). If not, try Shell's open() or setVisible(boolean) methods.

You can also invoke the "Plug-in Spy" with the Alt+Shift+F1 keybinding to retrieve information about the view or editor that your mouse is currently hovering over.

How can I make my editor respond to a user opening a marker?

When a marker has been opened, the Eclipse Platform tries to help the user out via the IGotoMarker interface. Your editor should either implement the interface or respond to this class by returning an implementation via the getAdapter(Class) method.

IGotoMarker's gotoMarker(IMarker) method will be called accordingly on the corresponding interface implementation and it is in that method implementation that you can react to a user opening a marker.

Why does the workbench keep opening a new editor every time I open a marker?

Are you using a custom IEditorInput implementation for your editor? You should override Object's equals(Object) method to return true if your custom implementation is equal to another IEditorInput.

Clients implementing this editor input interface should override Object.equals(Object) to answer true for two inputs that are the same. The IWorbenchPage.openEditor APIs are dependent on this to find an editor with the same input.