Search in sources :

Example 1 with ISelectionMapper

use of org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper in project webtools.sourceediting by eclipse.

the class FindReferencesAction method getXSDNamedComponent.

protected XSDNamedComponent getXSDNamedComponent() {
    if (editor != null) {
        ISelectionProvider provider = (ISelectionProvider) editor.getAdapter(ISelectionProvider.class);
        ISelectionMapper mapper = (ISelectionMapper) editor.getAdapter(ISelectionMapper.class);
        if (provider != null) {
            ISelection selection = provider.getSelection();
            if (mapper != null) {
                selection = mapper.mapSelection(selection);
            }
            if (selection != null && selection instanceof IStructuredSelection) {
                IStructuredSelection s = (IStructuredSelection) selection;
                Object o = s.getFirstElement();
                if (o != null && o instanceof XSDNamedComponent) {
                    return (XSDNamedComponent) o;
                }
            }
        }
    }
    // our expectation
    return null;
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionMapper(org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with ISelectionMapper

use of org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper in project webtools.sourceediting by eclipse.

the class RefactoringSection method invokeRenameRefactoring.

/**
 * Invokes the refactor->rename action on the current selection.
 */
private void invokeRenameRefactoring() {
    IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    XSDSchema schema = (XSDSchema) editor.getAdapter(XSDSchema.class);
    ISelection selection = new StructuredSelection(input);
    ISelectionMapper mapper = (ISelectionMapper) editor.getAdapter(ISelectionMapper.class);
    selection = mapper != null ? mapper.mapSelection(selection) : selection;
    RenameHandler renameHandler = new RenameHandler();
    renameHandler.execute(selection, schema);
}
Also used : ISelectionMapper(org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) RenameHandler(org.eclipse.wst.xsd.ui.internal.refactor.handlers.RenameHandler) IEditorPart(org.eclipse.ui.IEditorPart) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 3 with ISelectionMapper

use of org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper in project webtools.sourceediting by eclipse.

the class XSDRefactorGroupActionDelegate method fillMenu.

/**
 * Fills the menu with applicable refactor sub-menues
 * @param menu The menu to fill
 */
protected void fillMenu(Menu menu) {
    if (fSelection == null) {
        return;
    }
    if (workbenchPart != null) {
        IWorkbenchPartSite site = workbenchPart.getSite();
        if (site == null)
            return;
        IEditorPart editor = site.getPage().getActiveEditor();
        if (editor != null) {
            XSDSchema schema = (XSDSchema) editor.getAdapter(XSDSchema.class);
            ISelectionMapper mapper = (ISelectionMapper) editor.getAdapter(ISelectionMapper.class);
            if (schema != null) {
                ISelection selection = mapper != null ? mapper.mapSelection(fSelection) : fSelection;
                RefactorActionGroup refactorMenuGroup = new XSDRefactorActionGroup(selection, schema);
                RefactorGroupSubMenu subMenu = new RefactorGroupSubMenu(refactorMenuGroup);
                subMenu.fill(menu, -1);
            }
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) RefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup) XSDRefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup) ISelectionMapper(org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) RefactorGroupSubMenu(org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupSubMenu) XSDRefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)3 ISelectionMapper (org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper)3 IEditorPart (org.eclipse.ui.IEditorPart)2 XSDSchema (org.eclipse.xsd.XSDSchema)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)1 XSDRefactorActionGroup (org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup)1 RenameHandler (org.eclipse.wst.xsd.ui.internal.refactor.handlers.RenameHandler)1 RefactorActionGroup (org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup)1 RefactorGroupSubMenu (org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupSubMenu)1 XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)1