Thursday, October 25, 2012

Eclipse Plugin Development Notes

Some notes I am writing for myself and all the developers who are thinking  "There must be a utility for this, Where the !@#$ is it?!".

Some of the classes here are belong to the internal package which will give a "Discouraged Access" warning. You might want to recreate the code for those methods in your class itself. Its better you read this article

  1. How to know the current OS on which eclipse is running?
    Ans: Use org.eclipse.core.runtime.Platform.getOS()
  2. How do I check if my current OS is Windows (or something else) ?
    Ans: Platform.getOS.equals(Platform.OS_WIN32)
  3. How do I log some error in my eclipse plugin?
    Ans: Activator.getDefault().getLog().log(new Status(ERROR,Activator.PLUGIN_ID,e1.getMessage()));

  4. How do I get the current workspace?
    Ans: ResourcesPlugin.getWorkspace()
  5. I want to copy contents into a clipboard. Which class gives me clipboard utilities?
    Ans: org.eclipse.swt.dnd.Clipboard
  6. I want to add my own UI elements into my plugin How do I do it?
    Ans: Use org.eclipse.swt and org.eclipse.jface classes. In short learn SWT and JFace
  7. I want to validate a package name. How the heck do I do it !?
    Ans: JavaConventions.validatePackageName(nameOfPackage, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
  8. Now I want to validate a package name in a project! How ??
    Ans: JavaConventionsUtil.validatePackageName(text, project)
  9. Where can I find the java files related "Open Resource" dialog?
    Ans:  org.eclipse.ui.ide.jar
      --> org.eclipse.ui.internal.ide.dialogs.OpenResourceDialog 
  10. Who calls OpenResourcesDialog?
    Ans: org.eclipse.ui.OpenWorkspaceFile(this is an action) -->org.eclipse.ui.internal.ide.handlers.OpenResourceHandler -->
    org.eclipse.ui.internal.ide.dialogs.OpenResourceDialog. Go to plugin.xml of org.eclipse.ui.ide --> Extensions subtab --> type in 'Open' in the search field.
    The command associated with this dialog is org.eclipse.ui.navigate.openResource
  11. Give me a screenshot of  org.eclipse.jdt.debug.ui plugin.
    Ans: OK
  12. Who implements the Ctrl+1 action?
    Plugin : org.eclipse.ui.ide_3.8.100.v20120917-171812.jar
  13. Where can I get the ID of the Package Explorer View and other Views?
    Ans:See the org.eclipse.jdt.ui.JavaUI class.

No comments:

Post a Comment