Search in sources :

Example 6 with IRoute

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));
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) Test(org.junit.Test)

Example 7 with IRoute

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;
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute)

Example 8 with IRoute

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);
    }
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute)

Example 9 with IRoute

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();
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 10 with IRoute

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];
}
Also used : SelectRouteDialog(org.jboss.tools.openshift.internal.ui.dialog.SelectRouteDialog) IRoute(com.openshift.restclient.model.route.IRoute)

Aggregations

IRoute (com.openshift.restclient.model.route.IRoute)34 Test (org.junit.Test)15 IService (com.openshift.restclient.model.IService)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 List (java.util.List)6 ResourceKind (com.openshift.restclient.ResourceKind)5 Connection (org.jboss.tools.openshift.core.connection.Connection)5 IProject (com.openshift.restclient.model.IProject)4 IResource (com.openshift.restclient.model.IResource)4 Collection (java.util.Collection)4 CoreException (org.eclipse.core.runtime.CoreException)4 NLS (org.eclipse.osgi.util.NLS)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AbstractHandler (org.eclipse.core.commands.AbstractHandler)3 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 IStatus (org.eclipse.core.runtime.IStatus)3 ISelection (org.eclipse.jface.viewers.ISelection)3