use of org.jboss.tools.openshift.core.odo.Odo in project jbosstools-openshift by jbosstools.
the class DescribeHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
ComponentElement component = UIUtils.getFirstElement(selection, ComponentElement.class);
ServiceElement service = null;
ApplicationElement application = null;
if (component == null) {
service = UIUtils.getFirstElement(selection, ServiceElement.class);
if (service == null) {
application = UIUtils.getFirstElement(selection, ApplicationElement.class);
if (application == null) {
return OpenShiftUIActivator.statusFactory().cancelStatus(// $NON-NLS-1$
"No application, component or service selected");
}
}
}
try {
Odo odo = component != null ? component.getRoot().getOdo() : service != null ? service.getRoot().getOdo() : application.getRoot().getOdo();
final ServiceElement fService = service;
final ApplicationElement fApplication = application;
executeInJob("Describe", monitor -> execute(odo, component, fService, fApplication));
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 LinkComponentHandler 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<Component> targetComponents = odo.getComponents(projectName, applicationName).stream().filter(comp -> !comp.getName().equals(component.getWrapped().getName())).collect(Collectors.toList());
if (targetComponents.isEmpty()) {
MessageDialog.openError(shell, "Link component", "No component available to link to.");
} else {
final LinkModel<Component> model = new LinkModel<>(odo, projectName, applicationName, component.getWrapped().getName(), targetComponents);
final IWizard linkComponentWizard = new LinkComponentWizard(model);
if (WizardUtils.openWizardDialog(linkComponentWizard, shell) == Window.OK) {
executeInJob("Link component", 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 DebugHandler method execute.
@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
try {
Odo odo = component.getRoot().getOdo();
String project = component.getParent().getParent().getWrapped();
String application = component.getParent().getWrapped().getName();
ComponentInfo info = odo.getComponentInfo(project, application, component.getWrapped().getName(), component.getWrapped().getPath(), component.getWrapped().getInfo().getComponentKind());
RemoteStackDebugger remoteDebugger = RemoteStackProviderRegistry.getInstance().findBytype(info.getComponentTypeName(), info.getComponentTypeVersion());
if (remoteDebugger != null) {
DebugInfo debugInfo = odo.debugInfo(project, application, component.getWrapped().getPath(), component.getWrapped().getName());
int port = debugInfo.getStatus() == DebugStatus.RUNNING ? debugInfo.getLocalPort() : allocateLocalPort();
if (debugInfo.getStatus() != DebugStatus.RUNNING) {
executeInJob("Debug", monitor -> startDebug(odo, project, application, component, port));
}
executeInJob("Attach debugger", monitor -> createAndLaunchConfig(odo, project, application, component.getWrapped(), info, port, remoteDebugger, monitor, shell));
} else {
MessageDialog.openError(shell, "Debug", "Debugging is not supported for this type of 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 CreateStorageHandler 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 CreateStorageModel model = new CreateStorageModel(odo, projectName, applicationName, component.getWrapped().getName(), Storage.getSizes());
final IWizard createStorageWizard = new CreateStorageWizard(model);
if (WizardUtils.openWizardDialog(createStorageWizard, shell) == Window.OK) {
executeInJob("Create storage", 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 DeleteHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
AbstractOpenshiftUIElement<?, ?, ?> element = UIUtils.getFirstElement(selection, AbstractOpenshiftUIElement.class);
if (element == null) {
return OpenShiftUIActivator.statusFactory().cancelStatus(// $NON-NLS-1$
"No element selected");
}
try {
String label = getLabel(element);
if (MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), String.join(" ", "Delete", label), String.join(" ", "Are you sure to delete", label, "?"))) {
Odo odo = ((ApplicationExplorerUIModel) element.getRoot()).getOdo();
executeInJob("Delete", monitor -> execute(odo, element));
}
return Status.OK_STATUS;
} catch (IOException e) {
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
Aggregations