use of org.eclipse.ui.ISelectionService in project dsl-devkit by dsldevkit.
the class SpyViewPart method uninstallSelectionListeners.
/**
* Uninstall selection listeners.
*/
private void uninstallSelectionListeners() {
ISelectionService service = getSite().getService(ISelectionService.class);
service.removePostSelectionListener(selectionListener);
selectionListener.removeSelectionChangedListener(grammarView);
selectionListener.removeSelectionChangedListener(eClassTypeView);
eClassTypeView.removePostSelectionChangedListener(eObjectOutline);
selectionListener.removeSelectionChangedListener(eObjectOutline);
}
use of org.eclipse.ui.ISelectionService in project eclipse-integration-commons by spring-projects.
the class QuickSearchHandler method initializeFromSelection.
/**
* Based on the current active selection initialize the priority function and/or
* the initial contents of the search box.
*/
private static void initializeFromSelection(IWorkbenchWindow workbench, QuickSearchDialog dialog) {
if (workbench != null) {
ISelectionService selectionService = workbench.getSelectionService();
ISelection selection = selectionService.getSelection();
if (selection != null && selection instanceof ITextSelection) {
// Use text selection to set initial search pattern.
String text = ((ITextSelection) selection).getText();
if (text != null && !"".equals(text)) {
dialog.setInitialPattern(text, QuickSearchDialog.FULL_SELECTION);
}
}
}
// IEditorPart editor = HandlerUtil.getActiveEditor(event);
// if (editor!=null && editor instanceof ITextEditor) {
// ITextEditor textEditor = (ITextEditor)editor;
// ISelection selection = textEditor.getSelectionProvider().getSelection();
// if (selection!=null && selection instanceof ITextSelection) {
// String text = ((ITextSelection) selection).getText();
// if (text!=null && !"".equals(text)) {
// dialog.setInitialPattern(text, QuickSearchDialog.FULL_SELECTION);
// }
// }
// }
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class PluginUtil method getSelectedProject.
/**
* This method returns currently selected project in workspace.
* @return IProject
*/
public static IProject getSelectedProject() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
Object element = null;
IResource resource;
IProject selProject = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSel = (IStructuredSelection) selection;
element = structuredSel.getFirstElement();
}
if (element instanceof IProject) {
resource = (IResource) element;
selProject = resource.getProject();
} else if (element instanceof IJavaProject) {
IJavaProject proj = ((IJavaElement) element).getJavaProject();
selProject = proj.getProject();
} else if (element instanceof IResource) {
resource = (IResource) element;
selProject = resource.getProject();
} else {
IWorkbenchPage page = window.getActivePage();
IEditorPart editorPart = page.getActiveEditor();
if (editorPart != null) {
IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class);
if (file != null) {
selProject = file.getProject();
}
}
}
return selProject;
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class ClasspathContainerPage method getSelectedProject.
/**
* Currently selected project in workspace.
*
* @return IProject
*/
private IProject getSelectedProject() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
Object element = null;
IResource resource;
IProject selProject = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSel = (IStructuredSelection) selection;
element = structuredSel.getFirstElement();
}
if (element instanceof IProject) {
resource = (IResource) element;
selProject = resource.getProject();
} else if (element instanceof IJavaProject) {
IJavaProject proj = ((IJavaElement) element).getJavaProject();
selProject = proj.getProject();
}
return selProject;
}
use of org.eclipse.ui.ISelectionService in project hale by halestudio.
the class StyledMapExtra method partClosed.
/**
* @see IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == mapView) {
layoutController.disable();
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// remove listeners
disableScenePainterListeners(selection, instances, styles, geometries);
}
}
Aggregations