/** Performs the edit VM action when the Edit... button is pressed */
 private void editVM() {
   IStructuredSelection selection = (IStructuredSelection) fVMList.getSelection();
   VMStandin vm = (VMStandin) selection.getFirstElement();
   if (vm == null) {
     return;
   }
   if (JavaRuntime.isContributedVMInstall(vm.getId())) {
     VMDetailsDialog dialog = new VMDetailsDialog(getShell(), vm);
     dialog.open();
   } else {
     EditVMInstallWizard wizard =
         new EditVMInstallWizard(vm, fVMs.toArray(new IVMInstall[fVMs.size()]));
     WizardDialog dialog = new WizardDialog(getShell(), wizard);
     if (dialog.open() == Window.OK) {
       VMStandin result = wizard.getResult();
       if (result != null) {
         // replace with the edited VM
         int index = fVMs.indexOf(vm);
         fVMs.remove(index);
         fVMs.add(index, result);
         fVMList.setSelection(new StructuredSelection(result));
         fVMList.refresh(true);
       }
     }
   }
 }
  /**
   * Adds a duplicate of the selected VM to the block
   *
   * @since 3.2
   */
  protected void copyVM() {
    IStructuredSelection selection = (IStructuredSelection) fVMList.getSelection();
    Iterator<IVMInstall> it = selection.iterator();

    ArrayList<VMStandin> newEntries = new ArrayList<VMStandin>();
    while (it.hasNext()) {
      IVMInstall selectedVM = it.next();
      // duplicate & add VM
      VMStandin standin = new VMStandin(selectedVM, createUniqueId(selectedVM.getVMInstallType()));
      standin.setName(generateName(selectedVM.getName()));
      EditVMInstallWizard wizard =
          new EditVMInstallWizard(standin, fVMs.toArray(new IVMInstall[fVMs.size()]));
      WizardDialog dialog = new WizardDialog(getShell(), wizard);
      int dialogResult = dialog.open();
      if (dialogResult == Window.OK) {
        VMStandin result = wizard.getResult();
        if (result != null) {
          newEntries.add(result);
        }
      } else if (dialogResult == Window.CANCEL) {
        // Canceling one wizard should cancel all subsequent wizards
        break;
      }
    }
    if (newEntries.size() > 0) {
      fVMs.addAll(newEntries);
      fVMList.refresh();
      fVMList.setSelection(new StructuredSelection(newEntries.toArray()));
    } else {
      fVMList.setSelection(selection);
    }
    fVMList.refresh(true);
  }