use of org.jboss.tools.openshift.internal.ui.wizard.applicationexplorer.LinkComponentWizard 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);
}
}
Aggregations