/**
   * 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);
  }
예제 #2
0
 /**
  * Sets the workspace default VM on the given working copy
  *
  * @param config
  * @since 3.5
  */
 @SuppressWarnings("deprecation")
 public static void setVM(ILaunchConfigurationWorkingCopy config) {
   IVMInstall vm = JavaRuntime.getDefaultVMInstall();
   String vmName = vm.getName();
   String vmTypeID = vm.getVMInstallType().getId();
   config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, vmName);
   config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, vmTypeID);
 }
 private StringBuffer appendVMAttributes(IVMInstall vmInstall, StringBuffer buf) {
   if (vmInstall != null) {
     String str = vmInstall.getName();
     buf.append('[').append(str.length()).append(']').append(str);
     str = vmInstall.getVMInstallType().getName();
     buf.append('[').append(str.length()).append(']').append(str);
     if (vmInstall.getVMArguments() != null && vmInstall.getVMArguments().length > 0) {
       buf.append('[').append(vmInstall.getVMArguments().length).append(']');
       for (int i = 0; i < vmInstall.getVMArguments().length; i++) {
         str = vmInstall.getVMArguments()[i];
         buf.append('[').append(str.length()).append(']').append(str);
       }
     }
     str = vmInstall.getInstallLocation().getAbsolutePath();
     buf.append('[').append(str.length()).append(']').append(str).append(';');
   } else {
     buf.append('[').append(']').append(';');
   }
   return buf;
 }
 /** @see ITableLabelProvider#getColumnText(Object, int) */
 @Override
 public String getColumnText(Object element, int columnIndex) {
   if (element instanceof IVMInstall) {
     IVMInstall vm = (IVMInstall) element;
     switch (columnIndex) {
       case 0:
         if (JavaRuntime.isContributedVMInstall(vm.getId())) {
           return NLS.bind(JREMessages.InstalledJREsBlock_19, new String[] {vm.getName()});
         }
         if (fVMList.getChecked(element)) {
           return NLS.bind(JREMessages.InstalledJREsBlock_7, vm.getName());
         }
         return vm.getName();
       case 1:
         return vm.getInstallLocation().getAbsolutePath();
       case 2:
         return vm.getVMInstallType().getName();
     }
   }
   return element.toString();
 }