use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class CreateComponentHandler method openDialog.
private static void openDialog(DevfileRegistryComponentTypeElement componentType, ApplicationElement application, ProjectElement project, final Shell parent) throws IOException {
Odo odo = project != null ? project.getParent().getOdo() : componentType.getRoot().getOdo();
String projectName = project != null ? project.getWrapped() : odo.getNamespace();
IProject eclipseProject = getOpenedProject();
final CreateComponentModel model = new CreateComponentModel(odo, odo.getComponentTypes(), projectName, application == null ? null : application.getWrapped().getName(), eclipseProject);
if (componentType != null) {
model.setSelectedComponentType(componentType.getWrapped());
}
final IWizard createComponentWizard = new CreateComponentWizard(model);
if (WizardUtils.openWizardDialog(createComponentWizard, parent) == Window.OK) {
AbstractOpenshiftUIElement<?, ?, ApplicationExplorerUIModel> element = componentType != null ? componentType.getRoot() : application == null ? project : application;
executeInJob("Creating component", monitor -> execute(parent, model, element));
}
}
use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class CreateServiceHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
ApplicationElement application = null;
ProjectElement project = UIUtils.getFirstElement(selection, ProjectElement.class);
if (project == null) {
application = UIUtils.getFirstElement(selection, ApplicationElement.class);
if (application == null) {
// $NON-NLS-1$
return OpenShiftUIActivator.statusFactory().cancelStatus("No project or application selected");
}
project = application.getParent();
}
try {
Odo odo = project.getParent().getOdo();
List<ServiceTemplate> templates = odo.getServiceTemplates();
if (!templates.isEmpty()) {
final IWizard createServiceWizard = new CreateServiceWizard(templates, project.getWrapped(), application == null ? "" : application.getWrapped().getName(), odo);
if (WizardUtils.openWizardDialog(createServiceWizard, HandlerUtil.getActiveShell(event)) == Window.OK) {
if (application == null) {
project.refresh();
} else {
application.refresh();
}
}
} else {
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "Create service", "No operators installed on your cluster, can't create services");
}
return Status.OK_STATUS;
} catch (IOException e) {
String title = "Unable to create service";
String message = e.getMessage();
MessageDialog.open(MessageDialog.ERROR, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message, SWT.NONE);
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class CreateURLHandler method execute.
@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
try {
Odo odo = component.getRoot().getOdo();
String projectName = component.getParent().getParent().getWrapped();
String applicationName = component.getParent().getWrapped().getName();
final CreateURLModel model = new CreateURLModel(odo, projectName, applicationName, component.getWrapped().getName());
final IWizard createURLWizard = new CreateURLWizard(model);
if (WizardUtils.openWizardDialog(createURLWizard, shell) == Window.OK) {
executeInJob("Create url", monitor -> execute(model, component));
}
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class LinkServiceHandler method execute.
@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
try {
Odo odo = component.getRoot().getOdo();
String projectName = component.getParent().getParent().getWrapped();
String applicationName = component.getParent().getWrapped().getName();
List<Service> serviceNames = odo.getServices(projectName, applicationName);
final LinkModel<Service> model = new LinkModel<>(odo, projectName, applicationName, component.getWrapped().getName(), serviceNames);
final IWizard linkServiceWizard = new LinkServiceWizard(model);
if (WizardUtils.openWizardDialog(linkServiceWizard, shell) == Window.OK) {
executeInJob("Link service", monitor -> execute(shell, model, component));
}
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class UndeployHandler method execute.
@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
try {
Odo odo = component.getRoot().getOdo();
executeInJob("Undeploy", monitor -> execute(odo, component));
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
Aggregations