use of org.eclipse.ui.ISelectionService in project egit by eclipse.
the class RebaseInteractiveView method removeListeners.
private void removeListeners() {
ISelectionService srv = CommonUtils.getService(getSite(), ISelectionService.class);
srv.removePostSelectionListener(RepositoriesView.VIEW_ID, selectionChangedListener);
if (currentPlan != null)
currentPlan.removeRebaseInteractivePlanChangeListener(this);
if (planIndexer != null)
planIndexer.dispose();
InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).removePreferenceChangeListener(prefListener);
Activator.getDefault().getPreferenceStore().removePropertyChangeListener(uiPrefsListener);
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class AIProjConfigWizardDialog method getSelectedProject.
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 ijavaProj = ((IJavaElement) element).getJavaProject();
selProject = ijavaProj.getProject();
}
return selProject;
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class AILibraryUtil method getSelectedProject.
/**
* 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();
}
return selProject;
}
use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.
the class ClasspathContainerPage method getSelectedProject.
/**
* returns 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 titan.EclipsePlug-ins by eclipse.
the class SelectionFinder method findSelection.
private Definition findSelection() {
// getting the active editor
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor == null || !(editor instanceof TTCN3Editor)) {
return null;
}
final TTCN3Editor targetEditor = (TTCN3Editor) editor;
// iterating through part of the module
final IResource selectedRes = extractResource(targetEditor);
if (!(selectedRes instanceof IFile)) {
ErrorReporter.logError("SelectionFinder.findSelection(): Selected resource `" + selectedRes.getName() + "' is not a file.");
return null;
}
final IFile selectedFile = (IFile) selectedRes;
sourceProj = selectedFile.getProject();
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(sourceProj);
final Module selectedModule = projectSourceParser.containedModule(selectedFile);
// getting current selection
final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final TextSelection textSelection = extractSelection(selectionService.getSelection());
// getting current selection nodes
final int selectionOffset = textSelection.getOffset() + textSelection.getLength();
final SelectionFinderVisitor selVisitor = new SelectionFinderVisitor(selectionOffset);
selectedModule.accept(selVisitor);
final Definition selectedDef = selVisitor.getSelection();
if (selectedDef == null) {
ErrorReporter.logWarning("SelectionFinder.findSelection(): Visitor did not find a definition in the selection.");
final IStatusLineManager statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
statusLineManager.setErrorMessage(ERR_MSG_NO_SELECTION);
return null;
}
return selectedDef;
}
Aggregations