title: How to get currently opened class in eclipse editor correctly?
body: <p>I have the following code, which actually works well:</p>
  
  <pre><code>IJavaElement je = null;
  IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  if (part instanceof ContentOutline)
      part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
      if (part instanceof IViewPartInputProvider)
      {
          Object elem = ((IViewPartInputProvider)part).getViewPartInput();
          if (elem instanceof IJavaElement)
              je = (IJavaElement)elem;
      }
  </code></pre>
  
  <p>But I get a warning: </p>
  
  <p><code>Discouraged access: The type IViewPartInputProvider is not accessible due to restriction on required library C:\eclipse\plugins\org.eclipse.jdt.ui_3.9.1.v20130820-1427.jar</code></p>
  
  <p>Seems that this is a dirty way because of accessing internal API. Is there a better way to do this?</p>
  
  <p><strong>update</strong></p>
  
  <p>I found out that this code works fine too but doesn't produce any warnings:</p>
  
  <pre><code>IJavaElement je = null;
  IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  if (part instanceof ContentOutline)
      part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
  je = JavaUI.getEditorInputJavaElement(((IEditorPart)part).getEditorInput());
  </code></pre>
  
  <p>Since I omitted some checks I'm worried that this code could cause runtime errors if somebody using my plugin has a different eclipse configuration. Any suggestion for improvements?</p>