Search in sources :

Example 1 with CreateVMWizard

use of org.eclipse.linuxtools.internal.vagrant.ui.wizards.CreateVMWizard in project linuxtools by eclipse.

the class CreateVmCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    if (VagrantConnection.findVagrantPath() == null) {
        Display.getDefault().syncExec(() -> MessageDialog.openError(Display.getCurrent().getActiveShell(), // $NON-NLS-1$
        WizardMessages.getString("VagrantCommandNotFound.title"), // $NON-NLS-1$
        WizardMessages.getString("VagrantCommandNotFound.msg")));
    } else {
        final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
        final List<IVagrantBox> selectedBoxes = CommandUtils.getSelectedImages(activePart);
        if (selectedBoxes.size() <= 1) {
            IVagrantBox selectedBox = selectedBoxes.isEmpty() ? null : selectedBoxes.get(0);
            final CreateVMWizard wizard = new CreateVMWizard(selectedBox);
            final boolean finished = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
            if (finished) {
                performCreateVM(wizard.getVMName(), wizard.getBoxReference(), wizard.getVMFile(), wizard.getVMEnvironment());
            }
        }
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IVagrantBox(org.eclipse.linuxtools.vagrant.core.IVagrantBox) CreateVMWizard(org.eclipse.linuxtools.internal.vagrant.ui.wizards.CreateVMWizard)

Aggregations

CreateVMWizard (org.eclipse.linuxtools.internal.vagrant.ui.wizards.CreateVMWizard)1 IVagrantBox (org.eclipse.linuxtools.vagrant.core.IVagrantBox)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1