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