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;
}
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);
}
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);
}
}
}
}
Aggregations