blob: 308a14588061eb9c2884060d97d6b2d0dc3b8f8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*******************************************************************************
* Copyright (c) 2015 Red Hat.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat - Initial Contribution
*******************************************************************************/
package org.eclipse.linuxtools.internal.vagrant.ui.commands;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.vagrant.core.IVagrantBox;
import org.eclipse.linuxtools.vagrant.core.IVagrantConnection;
import org.eclipse.linuxtools.vagrant.core.VagrantException;
import org.eclipse.linuxtools.vagrant.core.VagrantService;
public class RemoveBoxesCommandHandler extends BaseBoxesCommandHandler {
@Override
String getJobName(List<IVagrantBox> selectedImages) {
return Messages.RemoveBoxesCommandHandler_removing_title;
}
@Override
String getTaskName(IVagrantBox image) {
return Messages.RemoveBoxesCommandHandler_removing_msg + image.getName();
}
@Override
void executeInJob(IVagrantBox image, IProgressMonitor monitor) {
IVagrantConnection connection = VagrantService.getInstance();
try {
connection.removeBox(image.getName());
} catch (VagrantException | InterruptedException e) {
final String errorMessage = Messages.RemoveBoxesCommandHandler_error + image.getName();
openError(errorMessage, e);
} finally {
// always get images as we sometimes get errors on intermediate
// images
// being removed but we will remove some top ones successfully
connection.getBoxes(true);
}
}
}
|