use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForARoute.
@Test
public void getStyledTextForARoute() {
IRoute route = givenAResource(IRoute.class, ResourceKind.ROUTE);
when(route.getHost()).thenReturn("www.example.com");
when(route.getPath()).thenReturn("");
assertEquals(String.format("%s www.example.com", route.getName()), provider.getStyledText(route).getString());
when(route.getPath()).thenReturn("/foo");
assertEquals(String.format("%s www.example.com/foo", route.getName()), provider.getStyledText(route).getString());
// test description
assertEquals(String.format("%s www.example.com/foo", route.getName()), provider.getDescription(route));
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class RouteTimeout method reset.
/**
* Removes the timeout from the route for the given resource.
* Restores the timeout that we backed up before setting our value if it exists.
* Does nothing otherwise. <br/>
* Returns the route if it was modified, {@code null} otherwise.
*
* @param timeout
* @param monitor
* @return the route that was modified or {@code null}
* @throws CoreException
*/
public IRoute reset(DebugContext context, IProgressMonitor monitor) throws CoreException {
monitor.subTask(NLS.bind("Getting route for resource {0}...", resource.getName()));
IRoute route = getRoute(resource, connection, monitor);
if (route == null) {
OpenShiftCoreActivator.pluginLog().logInfo(NLS.bind("Could not find any route for resource {0}", resource.getName()));
return null;
}
monitor.subTask(NLS.bind("Removing/restoring timeout for route {0}", route.getName()));
if (OpenShiftServerUtils.hasRouteTimeout(context.getServer())) {
setAnnotation(OpenShiftServerUtils.getRouteTimeout(context.getServer()), route);
// clear backup
OpenShiftServerUtils.setRouteTimeout(null, context.getServer());
} else {
removeAnnotation(route);
}
return route;
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class OpenShiftDebugMode method setRouteTimeout.
private void setRouteTimeout(IResource resource, Connection connection, IProgressMonitor monitor) throws CoreException {
monitor.subTask("Increasing route timeout while debugging...");
IRoute route = new RouteTimeout(resource, connection).set(context, monitor);
if (route != null) {
safeSend(route, connection, monitor);
}
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class SelectRouteDialog method createMessage.
private String createMessage(List<IRoute> routes) {
StringBuilder message = new StringBuilder();
if (!routes.isEmpty()) {
IRoute route = routes.get(0);
IConnection connection = ConnectionsRegistryUtil.safeGetConnectionFor(route);
if (connection != null) {
message.append("Server: ").append(connection.getUsername()).append(" ").append(connection.getHost()).append(StringUtils.getLineSeparator());
}
message.append("Project: ").append(route.getNamespaceName()).append(StringUtils.getLineSeparator());
// Add more space between server/project info and instruction.
message.append(StringUtils.getLineSeparator());
}
message.append("Select the route to open in a browser.");
return message.toString();
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class RouteChooser method chooseRoute.
@Override
public IRoute chooseRoute(List<IRoute> routes) {
final IRoute[] selectedRoute = new IRoute[1];
Display.getDefault().syncExec(() -> {
SelectRouteDialog routeDialog = new SelectRouteDialog(routes, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
if (Dialog.OK == routeDialog.open()) {
selectedRoute[0] = routeDialog.getSelectedRoute();
rememberChoice = routeDialog.isRememberChoice();
}
});
return selectedRoute[0];
}
Aggregations