use of org.jboss.tools.openshift.internal.core.job.DeleteResourceJob in project jbosstools-openshift by jbosstools.
the class ManageProjectsWizardPage method onRemove.
private SelectionListener onRemove(final DataBindingContext dbc) {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IProject project = pageModel.getSelectedProject();
if (project == null) {
return;
}
boolean confirm = MessageDialog.openConfirm(getShell(), OpenShiftUIMessages.ResourceDeletionDialogTitle, NLS.bind(OpenShiftUIMessages.ResourceDeletionConfirmation, project.getName()));
if (!confirm) {
return;
}
DeleteResourceJob job = OpenShiftJobs.createDeleteResourceJob(project);
try {
org.jboss.tools.common.ui.WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer(), dbc);
} catch (InvocationTargetException | InterruptedException ex) {
OpenShiftUIActivator.getDefault().getLogger().logError(NLS.bind("Could not delete OpenShift project {0}", project.getName()), ex);
}
}
};
}
use of org.jboss.tools.openshift.internal.core.job.DeleteResourceJob in project jbosstools-openshift by jbosstools.
the class DeleteResourcesHandler method deleteResources.
/**
* Resources are deleted with one job per resource and job are in a job group so
* that an error dialog will be displayed at the end of the job group.
*
* made protected for test purposes only
*
* @param uiResources
* the UI resources to delete
*/
protected void deleteResources(final IResourceWrapper<?, ?>[] uiResources) {
final JobGroup group = new JobGroup("Delete Openshift resources", 1, uiResources.length) {
/*
* Overridden because job group cancel job at first job error by default
*/
@Override
protected boolean shouldCancel(IStatus lastCompletedJobResult, int numberOfFailedJobs, int numberOfCanceledJobs) {
return false;
}
};
try (Stream<IResourceWrapper<?, ?>> stream = Arrays.stream(uiResources)) {
stream.forEach(uiResource -> {
DeleteResourceJob job = OpenShiftJobs.createDeleteResourceJob(uiResource.getWrapped());
job.setJobGroup(group);
job.schedule();
});
}
}
use of org.jboss.tools.openshift.internal.core.job.DeleteResourceJob in project jbosstools-openshift by jbosstools.
the class DeleteResourceHandler method deleteResources.
/**
* Resources are deleted with one job per resource and job are in a job
* group so that an error dialog will be displayed at the end of the job
* group.
*
* made protected for test purposes only
*
* @param uiResources
* the UI resources to delete
*/
protected JobGroup deleteResources(final IResourceWrapper<?, ?>[] uiResources) {
final JobGroup group = new JobGroup("Deleting OpenShift resources...", 1, uiResources.length) {
/*
* Overridden because job group cancel job at first job error by
* default
*/
@Override
protected boolean shouldCancel(IStatus lastCompletedJobResult, int numberOfFailedJobs, int numberOfCanceledJobs) {
return false;
}
};
try (Stream<IResourceWrapper<?, ?>> stream = Arrays.stream(uiResources)) {
stream.forEach(uiResource -> {
DeleteResourceJob job = OpenShiftJobs.createDeleteResourceJob(uiResource.getWrapped());
job.setJobGroup(group);
job.schedule();
});
}
return group;
}
Aggregations