edit this page - page history - about editing

Eclipse

Articles

Eclipse is a great IDE to develop Java and Android applications in. It is also the base for technologies like EMF, JET, GMF, OAW and lots more...

Also see:
  1. Increasing Eclipse Plug-in Performance
  2. Basic Eclipse Plugin Activator Structure
  3. Displaying an Eclipse MessageDialog in a Non-UI Thread
  4. Writing to a Console in Eclipse
  5. Force an IProject file system refresh in Eclipse
  6. Enabling an Eclipse Popup Menu for only Certain File Extensions
  7. Eclipse Popup Menu Subtrees
  8. Getting the last error or IStatus thrown in Eclipse
  9. Writing a String to a File in Java (really for Eclipse)
  10. Correctly using IProgressMonitors in Eclipse, and Reporting Progress in Eclipse (modal, non-modal, jobs)
  11. NoClassDefFoundError when running JUnit Plug-in Tests with JARs
  12. Launching failed. Bootstrap code cannot be found.
  13. java.lang.LinkageError in a JUnit Plug-in Test Case with a redeployed Eclipse application
  14. Converting an Eclipse General Project to a Java Project
  15. Out of Memory Errors in Eclipse
  16. Listing all files contained in an Eclipse plugin
  17. No runnable methods with JUnit and Eclipse
  18. Unable to Create EcoreEditorID Editor
  19. Automatically adding copyright/licence information to Eclipse projects
  20. Using PDE to automatically build Eclipse plugins
  21. Could not open the editor: SAXParserFactoryImpl cannot be cast to SAXParserFactory
  22. Class Not Found when running a JUnit Plugin Test
  23. No Classloader Found for Plug-in when running a JUnit Plugin Test
  24. Only one of the following can be installed at once: Core Resource Management
  25. Disabling DTD validation for Ant xmlvalidate task within Eclipse
  26. Debugging Java applications remotely with Eclipse

Null Argument with IWizardPage

If you get the following error while you are trying to implement IWizardPage/IWizard, using the provided abstract classes WizardPage/Wizard:

org.eclipse.jface.util.Assert$AssertionFailedException: null argument;
	at org.eclipse.jface.util.Assert.isNotNull(Assert.java:149)
	at org.eclipse.jface.util.Assert.isNotNull(Assert.java:125)
	at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:183)
	at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:611)
	at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:502)
	...

The solution is to add one line of code to your implementation of WizardPage#createControl(Composite):

public void createControl(Composite parent) {
	Composite page = new Composite(parent);
	'''setControl(page);'''

	... rest of code ...
}

Note that if you use parent instead of another Composite, this will give weird problems when trying to switch between different pages in the wizard (successive wizard pages will appear blank, and the back button won't work).

Source code not found when debugging plug-in applications

Even though Eclipse usually lets you attach source code to missing source locations, sometimes it won't let you attach it to imported JAR files, for example when you're developing a plug-in project. You might get this error:

The JAR of this class file belongs to container 'plug-in dependencies' which does not allow modifications to source attachments on its entries.

The problem is not that it can't add the source code; I think the problem is that it expects the source code from another, different Eclipse plugin. Try going to an Update Site and installing the source code/SDK feature plugin.

In one case I couldn't get the source code even this way; my solution was to manually download the source code/SDK and extract the plugin/org.eclipse.foo.source_1.0.101 plugin manually into the eclipse/plugins folder. Once I restarted Eclipse, it worked fine!

Get current workspace location

URL workspaceLocation = Platform.getInstanceLocation().getURL();
(also works for JUnit plugin tests)

Loading an internal browser

PlatformUI.getWorkbench().getBrowserSupport().createBrowser("myId").openURL(url);
(ref)

Displaying a message dialog box or error dialog box

MessageDialog.openWarning( PlatformUI.getWorkbench().getDisplay().getActiveShell() ,
   "Dialog box title", "Dialog box contents");

Getting an IFile from a java.net.URI

IFiles[] resolved = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(URI);
(There may be more than one file for a given URI: ref)

"The import org.eclipse cannot be resolved"

Assuming that you have all the correct .project settings (e.g. the PDE PluginNature), this can happen when you switch between different Eclipses with the same workspace settings:
  1. Close all projects in your workspace.
  2. Open all projects in your workspace.
  3. Go into the build menu and clean out all projects: Project > Clean...
  4. Rebuild all projects, this problem may be resolved.
Categories: Article | Technology
edit this page - what links to here? - page history - top
Last edited by jevon jevon 21 months ago