Search in sources :

Example 16 with ISelectionService

use of org.eclipse.ui.ISelectionService in project hale by halestudio.

the class StyledMapExtra method setMapView.

/**
 * @see MapViewExtension#setMapView(MapView)
 */
@Override
public void setMapView(MapView mapView) {
    this.mapView = mapView;
    layoutController = new PainterLayoutController(mapView.getMapKit());
    /*
		 * Listen for activated/deactivated instance painters
		 * 
		 * - remove listeners for deactivated painters and clear the waypoints -
		 * update activated listeners and add the corresponding listeners
		 */
    ITileOverlayService overlayService = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
    overlayService.addListener(new SelectiveExtensionListener<TileOverlayPainter, TileOverlayFactory>() {

        @Override
        public void deactivated(TileOverlayPainter object, TileOverlayFactory definition) {
            if (object instanceof AbstractInstancePainter) {
                AbstractInstancePainter painter = (AbstractInstancePainter) object;
                // 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
                selection.removeSelectionListener(painter);
                instances.removeListener(painter);
                styles.removeListener(painter.getStyleListener());
                geometries.removeListener(painter.getGeometryListener());
                // clear way-points
                painter.clearWaypoints();
            }
        }

        @Override
        public void activated(TileOverlayPainter object, TileOverlayFactory definition) {
            if (object instanceof AbstractInstancePainter) {
                AbstractInstancePainter painter = (AbstractInstancePainter) object;
                // 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);
                // update
                painter.update(selection.getSelection());
                // add listeners
                selection.addSelectionListener(painter);
                instances.addListener(painter);
                styles.addListener(painter.getStyleListener());
                geometries.addListener(painter.getGeometryListener());
            }
        }
    });
    IPartService partService = mapView.getSite().getService(IPartService.class);
    partService.addPartListener(this);
    // map tips
    mapView.getMapTips().addMapTip(new InstanceMapTip(mapView.getMapKit()), 5);
}
Also used : PainterLayoutController(eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController) AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) IPartService(org.eclipse.ui.IPartService) TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) TileOverlayPainter(org.jdesktop.swingx.mapviewer.TileOverlayPainter)

Example 17 with ISelectionService

use of org.eclipse.ui.ISelectionService in project jbosstools-openshift by jbosstools.

the class UIUtils method getCurrentSelection.

/**
 * Use this method instead of HandlerUtil.getCurrentSelection(event)
 * when action is called on Properties View.
 *
 * @param event
 * @return
 */
public static ISelection getCurrentSelection(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    IWorkbenchPartSite site = (part != null) ? part.getSite() : null;
    IWorkbenchWindow window = (site != null) ? site.getWorkbenchWindow() : null;
    ISelectionService service = (window != null) ? window.getSelectionService() : null;
    return service != null ? service.getSelection() : null;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelectionService(org.eclipse.ui.ISelectionService)

Example 18 with ISelectionService

use of org.eclipse.ui.ISelectionService in project azure-tools-for-java by Microsoft.

the class AzureDockerHostDeployHandler method onExecute.

@Override
public Object onExecute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    ISelectionService selectionService = window.getSelectionService();
    ISelection selection = selectionService.getSelection();
    Shell shell = window.getShell();
    IProject project = null;
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof IResource) {
            project = ((IResource) element).getProject();
        }
    }
    if (project == null) {
        project = AzureDockerUIResources.getCurrentSelectedProject();
        if (project == null) {
            return null;
        }
    }
    try {
        AzureDockerUIResources.publish2DockerHostContainer(PluginUtil.getParentShell(), project, null);
    //			AzureDockerUIResources.createArtifact(shell, project);
    //			
    //			AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
    //
    //			// not signed in
    //			if (azureAuthManager == null) {
    //				System.out.println("ERROR! Not signed in!");
    //				return null;
    //			}
    //
    //			AzureDockerHostsManager dockerManager = AzureDockerHostsManager
    //					.getAzureDockerHostsManager(azureAuthManager);
    //
    //			if (!dockerManager.isInitialized()) {
    //				AzureDockerUIResources.updateAzureResourcesWithProgressDialog(shell, project);
    //				if (AzureDockerUIResources.CANCELED) {
    //					return null;
    //				}
    //				dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(null);
    //			}
    //
    //			if (dockerManager.getSubscriptionsMap().isEmpty()) {
    //				PluginUtil.displayErrorDialog(shell, "Create Docker Host", "Must select an Azure subscription first");
    //				return null;
    //			}
    //			
    //			DockerHost dockerHost = (dockerManager.getDockerPreferredSettings() != null) ? dockerManager.getDockerHostForURL(dockerManager.getDockerPreferredSettings().dockerApiName) : null;
    //			AzureDockerImageInstance dockerImageDescription = dockerManager.getDefaultDockerImageDescription(project.getName(), dockerHost);
    //			AzureSelectDockerWizard selectDockerWizard = new AzureSelectDockerWizard(project, dockerManager, dockerImageDescription);
    //			WizardDialog selectDockerHostDialog = new WizardDialog(shell, selectDockerWizard);
    //
    //			if (dockerHost != null) {
    //				selectDockerWizard.selectDefaultDockerHost(dockerHost, true);
    //			}
    //
    //			if (selectDockerHostDialog.open() == Window.OK) {
    //
    //			}
    } catch (Exception e) {
        log.log(Level.SEVERE, "execute: " + e.getMessage(), e);
        e.printStackTrace();
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 19 with ISelectionService

use of org.eclipse.ui.ISelectionService in project knime-core by knime.

the class EditMetaInfoAction method getSelection.

private Object getSelection() {
    ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
    IStructuredSelection selection = (IStructuredSelection) service.getSelection();
    if (selection == null) {
        return null;
    }
    return selection.getFirstElement();
}
Also used : ISelectionService(org.eclipse.ui.ISelectionService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 20 with ISelectionService

use of org.eclipse.ui.ISelectionService in project vorto by eclipse.

the class ModelProjectFactory method getModelElementFromSelection.

public IModelElement getModelElementFromSelection() {
    if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
        ISelectionService selectionService = activeWorkbenchWindow.getSelectionService();
        ISelection selection = null;
        selection = selectionService.getSelection();
        if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
            return null;
        }
        return getModelElementSelection((IStructuredSelection) selection);
    }
    return null;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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