use of org.jboss.tools.openshift.internal.ui.models.IServiceWrapper in project jbosstools-openshift by jbosstools.
the class ManageEnvironmentVariablesWizard method findReplicationController.
/**
* If a replication controller is selected, method returns it.
* If a deployment config is selected, method returns it.
* If a deployment is selected, method finds a deployment config and returns it.
* @param event
* @return
*/
IReplicationController findReplicationController(ExecutionEvent event) {
ISelection selection = UIUtils.getCurrentSelection(event);
IDeploymentConfig dc = UIUtils.getFirstElement(selection, IDeploymentConfig.class);
if (dc != null) {
return dc;
}
IReplicationController rc = UIUtils.getFirstElement(selection, IReplicationController.class);
if (rc != null) {
return rc;
}
IServiceWrapper deployment = UIUtils.getFirstElement(selection, IServiceWrapper.class);
Collection<IResourceWrapper<?, ?>> dcs = deployment.getResourcesOfKind(ResourceKind.DEPLOYMENT_CONFIG);
if (!dcs.isEmpty()) {
dc = (IDeploymentConfig) dcs.iterator().next().getWrapped();
if (dc != null) {
return dc;
}
}
return null;
}
use of org.jboss.tools.openshift.internal.ui.models.IServiceWrapper in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method getDeploymentConfig.
private IDeploymentConfig getDeploymentConfig(IPod pod, IResourceWrapper<?, ?> wrapper) {
IDeploymentConfig dc = null;
if (!ResourceUtils.isBuildPod(pod)) {
IServiceWrapper service = ResourceWrapperUtils.getServiceWrapperFor(wrapper, serviceWrapper -> ResourceUtils.areRelated(pod, (IService) serviceWrapper.getWrapped()));
dc = getDeploymentConfig(service);
}
return dc;
}
use of org.jboss.tools.openshift.internal.ui.models.IServiceWrapper in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method getDeploymentConfig.
private IDeploymentConfig getDeploymentConfig(IReplicationController rc, IResourceWrapper<?, ?> wrapper) {
IDeploymentConfig dc = null;
IServiceWrapper service = ResourceWrapperUtils.getServiceWrapperFor(wrapper, serviceWrapper -> ResourceUtils.areRelated(rc, (IService) serviceWrapper.getWrapped()));
if (service != null) {
dc = ResourceUtils.getDeploymentConfigFor(rc, ResourceWrapperUtils.getResources(service.getResourcesOfKind(ResourceKind.DEPLOYMENT_CONFIG)));
}
return dc;
}
use of org.jboss.tools.openshift.internal.ui.models.IServiceWrapper in project jbosstools-openshift by jbosstools.
the class SelectedRoutePreference method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Shell shell = HandlerUtil.getActiveShell(event);
ISelection currentSelection = UIUtils.getCurrentSelection(event);
final IRoute route = UIUtils.getFirstElement(currentSelection, IRoute.class);
// Open route
if (route != null) {
return openBrowser(shell, route);
}
IServiceWrapper service = UIUtils.getFirstElement(currentSelection, IServiceWrapper.class);
if (service != null) {
new RouteOpenerJob(service.getWrapped().getNamespaceName(), shell) {
@Override
protected IStatus run(IProgressMonitor monitor) {
this.routes = service.getResourcesOfKind(ResourceKind.ROUTE).stream().map(r -> (IRoute) r.getWrapped()).collect(Collectors.toList());
return Status.OK_STATUS;
}
}.schedule();
return Status.OK_STATUS;
}
// Open Project
final IProject project = UIUtils.getFirstElement(currentSelection, IProject.class);
if (project != null) {
new RouteOpenerJob(project.getName(), shell) {
@Override
protected IStatus run(IProgressMonitor monitor) {
this.routes = project.getResources(ResourceKind.ROUTE);
return Status.OK_STATUS;
}
}.schedule();
return Status.OK_STATUS;
}
// Open Connection
final IConnection connection = UIUtils.getFirstElement(currentSelection, IConnection.class);
if (connection != null) {
return openBrowser(shell, connection.getHost());
}
return nothingToOpenDialog(shell);
}
use of org.jboss.tools.openshift.internal.ui.models.IServiceWrapper in project jbosstools-openshift by jbosstools.
the class EditDefaultRouteHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Shell shell = HandlerUtil.getActiveShell(event);
ISelection currentSelection = UIUtils.getCurrentSelection(event);
IServiceWrapper service = UIUtils.getFirstElement(currentSelection, IServiceWrapper.class);
if (service != null) {
new RouteOpenerJob(service.getWrapped().getNamespaceName(), shell) {
@Override
protected IStatus run(IProgressMonitor monitor) {
this.routes = service.getResourcesOfKind(ResourceKind.ROUTE).stream().map(r -> (IRoute) r.getWrapped()).collect(Collectors.toList());
return Status.OK_STATUS;
}
}.schedule();
return Status.OK_STATUS;
}
final IProject project = UIUtils.getFirstElement(currentSelection, IProject.class);
if (project != null) {
new RouteOpenerJob(project.getName(), shell) {
@Override
protected IStatus run(IProgressMonitor monitor) {
this.routes = project.getResources(ResourceKind.ROUTE);
return Status.OK_STATUS;
}
}.schedule();
return Status.OK_STATUS;
}
return Status.OK_STATUS;
}
Aggregations