org.eclipse.ui.views.contentoutline.ContentOutline Java Examples

The following examples show how to use org.eclipse.ui.views.contentoutline.ContentOutline. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void partActivated ( final IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == ChartEditor.this.contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ChartEditor.this );

            setCurrentViewer ( ChartEditor.this.contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( ChartEditor.this.propertySheetPages.contains ( ( (PropertySheet)p )
                .getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ChartEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ChartEditor.this )
    {
        handleActivate ();
    }
}
 
Example #2
Source File: AddElementtoReport.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Object getTarget( )
{
	IViewPart viewPart = UIUtil.getView( IPageLayout.ID_OUTLINE );
	if ( !( viewPart instanceof ContentOutline ) )
	{
		return null;
	}
	ContentOutline outlineView = (ContentOutline) viewPart;

	ISelection selection = outlineView.getSelection( );
	if ( selection instanceof StructuredSelection )
	{
		StructuredSelection strSelection = (StructuredSelection) selection;
		if ( strSelection.size( ) == 1 )
		{
			return strSelection.getFirstElement( );
		}
	}
	return null;
}
 
Example #3
Source File: ExtensionsEditor.java    From ifml-editor with MIT License 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
	if (p instanceof ContentOutline) {
		if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
			getActionBarContributor().setActiveEditor(ExtensionsEditor.this);

			setCurrentViewer(contentOutlineViewer);
		}
	}
	else if (p instanceof PropertySheet) {
		if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
			getActionBarContributor().setActiveEditor(ExtensionsEditor.this);
			handleActivate();
		}
	}
	else if (p == ExtensionsEditor.this) {
		handleActivate();
	}
}
 
Example #4
Source File: CoreEditor.java    From ifml-editor with MIT License 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
	if (p instanceof ContentOutline) {
		if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
			getActionBarContributor().setActiveEditor(CoreEditor.this);

			setCurrentViewer(contentOutlineViewer);
		}
	}
	else if (p instanceof PropertySheet) {
		if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
			getActionBarContributor().setActiveEditor(CoreEditor.this);
			handleActivate();
		}
	}
	else if (p == CoreEditor.this) {
		handleActivate();
	}
}
 
Example #5
Source File: ExpandLevelHandler.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	// assumes to expand to level 1 if not specified
	int level = 1;
	String levelStr = event.getParameter(LEVEL);
	if (levelStr != null)
	{
		level = Integer.parseInt(levelStr);
	}

	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			CommonOutlinePage outlinePage = (CommonOutlinePage) page;
			// we want to expand to the specified level and collapse everything below
			outlinePage.collapseAll();
			outlinePage.expandToLevel(level);
		}
	}
	return null;
}
 
Example #6
Source File: EipEditor.java    From eip-designer with Apache License 2.0 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
   if (p instanceof ContentOutline) {
      if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
         getActionBarContributor().setActiveEditor(EipEditor.this);

         setCurrentViewer(contentOutlineViewer);
      }
   }
   else if (p instanceof PropertySheet) {
      if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
         getActionBarContributor().setActiveEditor(EipEditor.this);
         handleActivate();
      }
   }
   else if (p == EipEditor.this) {
      handleActivate();
   }
}
 
Example #7
Source File: BeansEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
	if (p instanceof ContentOutline) {
		if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
			getActionBarContributor().setActiveEditor(BeansEditor.this);

			setCurrentViewer(contentOutlineViewer);
		}
	}
	else if (p instanceof PropertySheet) {
		if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
			getActionBarContributor().setActiveEditor(BeansEditor.this);
			handleActivate();
		}
	}
	else if (p == BeansEditor.this) {
		handleActivate();
	}
}
 
Example #8
Source File: GenconfEditor.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
    if (p instanceof ContentOutline) {
        if (((ContentOutline) p).getCurrentPage() == contentOutlinePage) {
            getActionBarContributor().setActiveEditor(GenconfEditor.this);

            setCurrentViewer(contentOutlineViewer);
        }
    } else if (p instanceof PropertySheet) {
        if (propertySheetPages.contains(((PropertySheet) p).getCurrentPage())) {
            getActionBarContributor().setActiveEditor(GenconfEditor.this);
            handleActivate();
        }
    } else if (p == GenconfEditor.this) {
        handleActivate();
    }
}
 
Example #9
Source File: CrossflowEditor.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void partActivated(IWorkbenchPart p) {
	if (p instanceof ContentOutline) {
		if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
			getActionBarContributor().setActiveEditor(CrossflowEditor.this);

			setCurrentViewer(contentOutlineViewer);
		}
	}
	else if (p instanceof PropertySheet) {
		if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
			getActionBarContributor().setActiveEditor(CrossflowEditor.this);
			handleActivate();
		}
	}
	else if (p == CrossflowEditor.this) {
		handleActivate();
	}
}
 
Example #10
Source File: ConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ConfigurationEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ConfigurationEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ConfigurationEditor.this )
    {
        handleActivate ();
    }
}
 
Example #11
Source File: ItemEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ItemEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ItemEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ItemEditor.this )
    {
        handleActivate ();
    }
}
 
Example #12
Source File: ComponentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ComponentEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ComponentEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ComponentEditor.this )
    {
        handleActivate ();
    }
}
 
Example #13
Source File: GlobalizeEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( GlobalizeEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( GlobalizeEditor.this );
            handleActivate ();
        }
    }
    else if ( p == GlobalizeEditor.this )
    {
        handleActivate ();
    }
}
 
Example #14
Source File: InfrastructureEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( InfrastructureEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( InfrastructureEditor.this );
            handleActivate ();
        }
    }
    else if ( p == InfrastructureEditor.this )
    {
        handleActivate ();
    }
}
 
Example #15
Source File: ProtocolEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ProtocolEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ProtocolEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ProtocolEditor.this )
    {
        handleActivate ();
    }
}
 
Example #16
Source File: DetailViewEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( DetailViewEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( DetailViewEditor.this );
            handleActivate ();
        }
    }
    else if ( p == DetailViewEditor.this )
    {
        handleActivate ();
    }
}
 
Example #17
Source File: VisualInterfaceEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( VisualInterfaceEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( VisualInterfaceEditor.this );
            handleActivate ();
        }
    }
    else if ( p == VisualInterfaceEditor.this )
    {
        handleActivate ();
    }
}
 
Example #18
Source File: DeploymentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( DeploymentEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( DeploymentEditor.this );
            handleActivate ();
        }
    }
    else if ( p == DeploymentEditor.this )
    {
        handleActivate ();
    }
}
 
Example #19
Source File: SetupEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( SetupEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( SetupEditor.this );
            handleActivate ();
        }
    }
    else if ( p == SetupEditor.this )
    {
        handleActivate ();
    }
}
 
Example #20
Source File: ProfileEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( ProfileEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( ProfileEditor.this );
            handleActivate ();
        }
    }
    else if ( p == ProfileEditor.this )
    {
        handleActivate ();
    }
}
 
Example #21
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( SecurityEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( SecurityEditor.this );
            handleActivate ();
        }
    }
    else if ( p == SecurityEditor.this )
    {
        handleActivate ();
    }
}
 
Example #22
Source File: RecipeEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( RecipeEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( RecipeEditor.this );
            handleActivate ();
        }
    }
    else if ( p == RecipeEditor.this )
    {
        handleActivate ();
    }
}
 
Example #23
Source File: MemoryEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( MemoryEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( MemoryEditor.this );
            handleActivate ();
        }
    }
    else if ( p == MemoryEditor.this )
    {
        handleActivate ();
    }
}
 
Example #24
Source File: OsgiEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( OsgiEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( OsgiEditor.this );
            handleActivate ();
        }
    }
    else if ( p == OsgiEditor.this )
    {
        handleActivate ();
    }
}
 
Example #25
Source File: WorldEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void partActivated ( IWorkbenchPart p )
{
    if ( p instanceof ContentOutline )
    {
        if ( ( (ContentOutline)p ).getCurrentPage () == contentOutlinePage )
        {
            getActionBarContributor ().setActiveEditor ( WorldEditor.this );

            setCurrentViewer ( contentOutlineViewer );
        }
    }
    else if ( p instanceof PropertySheet )
    {
        if ( propertySheetPages.contains ( ( (PropertySheet)p ).getCurrentPage () ) )
        {
            getActionBarContributor ().setActiveEditor ( WorldEditor.this );
            handleActivate ();
        }
    }
    else if ( p == WorldEditor.this )
    {
        handleActivate ();
    }
}
 
Example #26
Source File: ExpandAllHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			((CommonOutlinePage) page).expandAll();
		}
	}
	return null;
}
 
Example #27
Source File: AnnotationOutline.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
  
  boolean isForeignSelection = true;
  
  if (part instanceof ContentOutline) {
    ContentOutline contentOutline = (ContentOutline) part;
    
    IPage currentPage = contentOutline.getCurrentPage();
    
    if (currentPage instanceof OutlinePageBook) {
      OutlinePageBook pageBook = (OutlinePageBook) currentPage;
      isForeignSelection = pageBook.getCasViewPage() != this;
    }
  }

  if (isForeignSelection && getSite().getPage().getActiveEditor() == editor) {
    if (selection instanceof StructuredSelection) {
      AnnotationSelection annotations = new AnnotationSelection((StructuredSelection) selection);

      if (!annotations.isEmpty()) {
        ISelection tableSelection = new StructuredSelection(new AnnotationTreeNode(editor
                .getDocument(), annotations.getFirst()));

        mTableViewer.setSelection(tableSelection, true);
      }
    }
  }
}
 
Example #28
Source File: FieldInitializerUtil.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the Java element that corresponds to the given selection.
 *
 * @param selection the current selection.
 * @return the Java element.
 */
@SuppressWarnings("static-method")
public IJavaElement getSelectedResource(IStructuredSelection selection) {
	IJavaElement elem = null;
	if (selection != null && !selection.isEmpty()) {
		final Object object = selection.getFirstElement();
		if (object instanceof IAdaptable) {
			final IAdaptable adaptable = (IAdaptable) object;
			elem = adaptable.getAdapter(IJavaElement.class);
			if (elem == null) {
				elem = getPackage(adaptable);
			}
		}
	}
	if (elem == null) {
		final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IWorkbenchPart part = activePage.getActivePart();
		if (part instanceof ContentOutline) {
			part = activePage.getActiveEditor();
		}
		if (part instanceof XtextEditor) {
			final IXtextDocument doc = ((XtextEditor) part).getDocument();
			final IFile file = doc.getAdapter(IFile.class);
			elem = getPackage(file);
		}
	}
	if (elem == null || elem.getElementType() == IJavaElement.JAVA_MODEL) {
		try {
			final IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
			if (projects.length == 1) {
				elem = projects[0];
			}
		} catch (JavaModelException e) {
			throw new RuntimeException(e.getMessage());
		}
	}
	return elem;
}
 
Example #29
Source File: CollapseAllHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if (part instanceof ContentOutline)
	{
		IPage page = ((ContentOutline) part).getCurrentPage();
		if (page instanceof CommonOutlinePage)
		{
			((CommonOutlinePage) page).collapseAll();
		}
	}
	return null;
}
 
Example #30
Source File: FieldInitializerUtil.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public IJavaElement getSelectedResource(IStructuredSelection selection) {
	IJavaElement elem = null;
	if(selection != null && !selection.isEmpty()){
		Object o = selection.getFirstElement();
		elem = Adapters.adapt(o, IJavaElement.class);
		if(elem == null){
			elem = getPackage(o);
		}
	}
	if (elem == null) {
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IWorkbenchPart part = activePage.getActivePart();
		if (part instanceof ContentOutline) {
			part= activePage.getActiveEditor();
		}
		if (part instanceof XtextEditor) {
			IXtextDocument doc = ((XtextEditor)part).getDocument();
			IFile file = Adapters.adapt(doc, IFile.class);
			elem = getPackage(file);
		}
	}
	if (elem == null || elem.getElementType() == IJavaElement.JAVA_MODEL) {
		try {
			IJavaProject[] projects= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
			if (projects.length == 1) {
				elem= projects[0];
			}
		} catch (JavaModelException e) {
			throw new RuntimeException(e.getMessage());
		}
	}
	return elem;
}