SHARE
TWEET

Untitled

a guest Jun 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public IJavaProject getProject() throws NullPointerException {
  2.  
  3.     IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  4.     if (window != null)
  5.     {
  6.         IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
  7.         Object firstElement = selection.getFirstElement();
  8.         if (firstElement instanceof IAdaptable)
  9.         {
  10.             IProject project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class);
  11.          IJavaProject javaProject = JavaCore.create(project);
  12.  
  13.             return javaProject;
  14.         }
  15.     }
  16.     return null;
  17.  
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top