use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftServerExtendedProperties method getWelcomePageUrl.
@Override
public String getWelcomePageUrl() throws GetWelcomePageURLException {
String welcomePageUrl = null;
try {
// Get connection explicitly to report failure. Try and connect right now to know if it fails.
// Do not catch OpenShiftException, let it be reported. We are more concerned of NPE.
Connection connection = OpenShiftServerUtils.getConnection(server);
if (connection == null || !connection.connect()) {
throw new GetWelcomePageURLException("Connection is not established.");
}
IResource resource = OpenShiftServerUtils.getResource(server, connection, new NullProgressMonitor());
if (resource == null) {
throw new GetWelcomePageURLException("Resource is missing.");
}
IProject project = resource.getProject();
if ((project != null) && (resource instanceof IService)) {
List<IRoute> routes = ResourceUtils.getRoutesFor((IService) resource, project.getResources(ResourceKind.ROUTE));
IRoute route = getRoute(OpenShiftServerUtils.getRouteURL(server), routes);
if (route == null) {
route = getRoute(routes);
}
// Reporting route == null is implemented in getRoute.
if (route != null) {
welcomePageUrl = route.getURL();
}
}
} catch (OpenShiftException e) {
throw new GetWelcomePageURLException(e.getMessage(), e);
}
return welcomePageUrl;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class DeleteResourcesHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IResourceWrapper<?, ?>[] wrappers = UIUtils.getElements(UIUtils.getCurrentSelection(event), IResourceWrapper.class);
if (ArrayUtils.isEmpty(wrappers) || wrappers[0].getWrapped() == null) {
return OpenShiftUIActivator.statusFactory().cancelStatus("Could not delete resources: " + "No resource selected that we can get the connection and namespace from.");
}
IResource selectedResource = wrappers[0].getWrapped();
Connection connection = ConnectionsRegistryUtil.getConnectionFor(selectedResource);
if (connection == null) {
return OpenShiftUIActivator.statusFactory().cancelStatus(NLS.bind("Could not delete resources: No connection found for selected resource {0}", selectedResource.getName()));
}
String namespace = selectedResource.getNamespaceName();
openDialog(connection, namespace, HandlerUtil.getActiveShell(event));
return null;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProvider method getAdaptedElement.
private Object getAdaptedElement(Object element) {
if (element instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) element;
IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null) {
element = resource;
}
Connection connection = adaptable.getAdapter(Connection.class);
if (connection != null) {
element = connection;
}
}
return element;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ResourceSummaryLabelProvider method getStyledText.
@Override
public StyledString getStyledText(Object arg) {
if (arg instanceof IResource) {
IResource resource = (IResource) arg;
StyledString text = new StyledString();
if (isFailedStatus(resource)) {
text.append(((IStatus) resource).getMessage());
} else {
text.append(StringUtils.humanize(resource.getKind().toString()));
text.append(resource.getName(), StyledString.QUALIFIER_STYLER);
}
return text;
}
return null;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftServerEditorModel method setResource.
public void setResource(IResource resource, boolean executeCommand) {
IResource previous = getResource();
super.setResource(resource);
// fire server command
if (executeCommand)
section.execute(new SetResourceCommand(getServer(), previous, resource));
}
Aggregations