use of com.openshift.restclient.model.route.IRoute 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 com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class SelectedRoutePreference method getSelectedRoute.
public IRoute getSelectedRoute(List<IRoute> routes) {
String key = getKey(routes);
if (choices.containsKey(key)) {
String selectedRoute = choices.get(key);
for (IRoute route : routes) {
if (selectedRoute.equals(getKey(route))) {
// move item to most recent
history.remove(key);
history.add(key);
return route;
}
}
}
return null;
}
use of com.openshift.restclient.model.route.IRoute 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;
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method serviceAndRouteWithSameNameShouldBeRelated.
public void serviceAndRouteWithSameNameShouldBeRelated() {
// given
IRoute route = mock(IRoute.class);
when(route.getServiceName()).thenReturn("42");
IService service = mock(IService.class);
when(service.getName()).thenReturn("42");
// when
// then
assertThat(areRelated(route, service)).isTrue();
}
Aggregations