Search in sources :

Example 1 with DeleteResourceJob

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);
            }
        }
    };
}
Also used : DeleteResourceJob(org.jboss.tools.openshift.internal.core.job.DeleteResourceJob) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProject(com.openshift.restclient.model.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with DeleteResourceJob

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();
        });
    }
}
Also used : JobGroup(org.eclipse.core.runtime.jobs.JobGroup) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IStatus(org.eclipse.core.runtime.IStatus) DeleteResourceJob(org.jboss.tools.openshift.internal.core.job.DeleteResourceJob)

Example 3 with DeleteResourceJob

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;
}
Also used : JobGroup(org.eclipse.core.runtime.jobs.JobGroup) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IStatus(org.eclipse.core.runtime.IStatus) DeleteResourceJob(org.jboss.tools.openshift.internal.core.job.DeleteResourceJob)

Aggregations

DeleteResourceJob (org.jboss.tools.openshift.internal.core.job.DeleteResourceJob)3 IStatus (org.eclipse.core.runtime.IStatus)2 JobGroup (org.eclipse.core.runtime.jobs.JobGroup)2 IResourceWrapper (org.jboss.tools.openshift.internal.ui.models.IResourceWrapper)2 IProject (com.openshift.restclient.model.IProject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1