Search in sources :

Example 11 with ISelectionService

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);
}
Also used : ISelectionService(org.eclipse.ui.ISelectionService)

Example 12 with ISelectionService

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);
// }
// }
// }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 13 with ISelectionService

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;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 14 with ISelectionService

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;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IJavaProject(org.eclipse.jdt.core.IJavaProject) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 15 with ISelectionService

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);
    }
}
Also used : StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)

Aggregations

ISelectionService (org.eclipse.ui.ISelectionService)38 ISelection (org.eclipse.jface.viewers.ISelection)19 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 IResource (org.eclipse.core.resources.IResource)15 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 IProject (org.eclipse.core.resources.IProject)9 IWorkbench (org.eclipse.ui.IWorkbench)8 IJavaProject (org.eclipse.jdt.core.IJavaProject)7 IEditorPart (org.eclipse.ui.IEditorPart)7 IFile (org.eclipse.core.resources.IFile)6 ExecutionException (org.eclipse.core.commands.ExecutionException)3 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)3 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)3 Repository (org.eclipse.jgit.lib.Repository)3 SWT (org.eclipse.swt.SWT)3 ISelectionListener (org.eclipse.ui.ISelectionListener)3 PlatformUI (org.eclipse.ui.PlatformUI)3 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)2 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)2 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)2