Ejemplo n.º 1
0
 /** Returns preferred value for specified parameter. */
 @Override
 protected String getParamPreferred(final String param) {
   final String domainType =
       getVMSVirtualDomainInfo().getWidget(VMSXML.VM_PARAM_DOMAIN_TYPE, null).getStringValue();
   if (DiskData.DRIVER_NAME.equals(param)
       && VMSVirtualDomainInfo.DOMAIN_TYPE_KVM.equals(domainType)) {
     return DRIVER_NAME_QEMU;
   }
   return PREFERRED_MAP.get(param);
 }
Ejemplo n.º 2
0
 /** Returns combo box for parameter. */
 @Override
 protected Widget createWidget(final String param, final String prefix, final int width) {
   String prefixS;
   if (prefix == null) {
     prefixS = "";
   } else {
     prefixS = prefix;
   }
   if (DiskData.SOURCE_FILE.equals(param)) {
     final String sourceFile = getParamSaved(DiskData.SOURCE_FILE);
     final String regexp = ".*[^/]$";
     final MyButton fileChooserBtn = new MyButton("Browse...");
     fileChooserBtn.miniButton();
     final Widget paramWi =
         WidgetFactory.createInstance(
             getFieldType(param),
             sourceFile,
             getParamPossibleChoices(param),
             regexp,
             width,
             Widget.NO_ABBRV,
             new AccessMode(getAccessType(param), false), /* only adv. mode */
             fileChooserBtn);
     paramWi.setAlwaysEditable(true);
     sourceFileWi.put(prefixS, paramWi);
     if (Tools.isWindows()) {
       /* does not work on windows and I tried, ultimately because
          FilePane.usesShellFolder(fc) in BasicFileChooserUI returns
          true and it is not possible to descent into a directory.
          TODO: It may work in the future.
       */
       paramWi.setTFButtonEnabled(false);
     }
     fileChooserBtn.addActionListener(
         new ActionListener() {
           @Override
           public void actionPerformed(final ActionEvent e) {
             final Thread t =
                 new Thread(
                     new Runnable() {
                       @Override
                       public void run() {
                         String file;
                         final String oldFile = paramWi.getStringValue();
                         if (oldFile == null || "".equals(oldFile)) {
                           file = LIBVIRT_IMAGE_LOCATION;
                         } else {
                           file = oldFile;
                         }
                         startFileChooser(paramWi, file, FILECHOOSER_FILE_ONLY);
                       }
                     });
             t.start();
           }
         });
     widgetAdd(param, prefix, paramWi);
     return paramWi;
   } else {
     final Widget paramWi = super.createWidget(param, prefix, width);
     if (DiskData.TYPE.equals(param) || DiskData.TARGET_BUS_TYPE.equals(param)) {
       paramWi.setAlwaysEditable(false);
     } else if (DiskData.SOURCE_DEVICE.equals(param)) {
       paramWi.setAlwaysEditable(true);
       sourceDeviceWi.put(prefixS, paramWi);
     } else if (DiskData.SOURCE_NAME.equals(param)) {
       sourceNameWi.put(prefixS, paramWi);
     } else if (DiskData.SOURCE_PROTOCOL.equals(param)) {
       sourceProtocolWi.put(prefixS, paramWi);
     } else if (DiskData.SOURCE_HOST_NAME.equals(param)) {
       sourceHostNameWi.put(prefixS, paramWi);
     } else if (DiskData.SOURCE_HOST_PORT.equals(param)) {
       sourceHostPortWi.put(prefixS, paramWi);
     } else if (DiskData.AUTH_USERNAME.equals(param)) {
       authUsernameWi.put(prefixS, paramWi);
     } else if (DiskData.AUTH_SECRET_TYPE.equals(param)) {
       authSecretTypeWi.put(prefixS, paramWi);
     } else if (DiskData.AUTH_SECRET_UUID.equals(param)) {
       authSecretUuidWi.put(prefixS, paramWi);
     } else if (DiskData.TARGET_DEVICE.equals(param)) {
       paramWi.setAlwaysEditable(true);
       targetDeviceWi.put(prefixS, paramWi);
     } else if (DiskData.DRIVER_NAME.equals(param)) {
       driverNameWi.put(prefixS, paramWi);
     } else if (DiskData.DRIVER_TYPE.equals(param)) {
       driverTypeWi.put(prefixS, paramWi);
     } else if (DiskData.DRIVER_CACHE.equals(param)) {
       driverCacheWi.put(prefixS, paramWi);
     } else if (DiskData.READONLY.equals(param)) {
       readonlyWi.put(prefixS, paramWi);
     }
     return paramWi;
   }
 }