コード例 #1
0
ファイル: VMSDiskInfo.java プロジェクト: rdndnl/lcmc
 /** Returns device parameters. */
 @Override
 protected Map<String, String> getHWParameters(final boolean allParams) {
   Tools.invokeAndWait(
       new Runnable() {
         @Override
         public void run() {
           getInfoPanel();
         }
       });
   final String[] params = getRealParametersFromXML();
   final Map<String, String> parameters = new LinkedHashMap<String, String>();
   for (final String param : params) {
     final String value = getComboBoxValue(param);
     if (DiskData.TYPE.equals(param)) {
       parameters.put(param, value);
     } else if (DiskData.TARGET_BUS_TYPE.equals(param)) {
       if (value == null) {
         parameters.put(DiskData.TARGET_BUS, null);
         parameters.put(DiskData.TARGET_TYPE, null);
       } else {
         final String[] values = value.split("/");
         if (values.length == 2) {
           parameters.put(DiskData.TARGET_BUS, values[0]);
           parameters.put(DiskData.TARGET_TYPE, values[1]);
         } else {
           LOG.appWarning("getHWParameters: cannot parse: " + param + " = " + value);
         }
       }
     } else if (allParams) {
       if (Tools.areEqual(getParamDefault(param), value)) {
         parameters.put(param, null);
       } else {
         parameters.put(param, value);
       }
     } else if (!Tools.areEqual(getParamSaved(param), value)
         || DiskData.SOURCE_FILE.equals(param)
         || DiskData.SOURCE_DEVICE.equals(param)
         || DiskData.SOURCE_PROTOCOL.equals(param)
         || DiskData.SOURCE_NAME.equals(param)
         || DiskData.SOURCE_HOST_NAME.equals(param)
         || DiskData.SOURCE_HOST_PORT.equals(param)
         || DiskData.AUTH_USERNAME.equals(param)
         || DiskData.AUTH_SECRET_TYPE.equals(param)
         || DiskData.AUTH_SECRET_UUID.equals(param)) {
       if (Tools.areEqual(getParamDefault(param), value)) {
         parameters.put(param, null);
       } else {
         parameters.put(param, value);
       }
     }
   }
   parameters.put(DiskData.SAVED_TARGET_DEVICE, getName());
   setName(getParamSaved(DiskData.TARGET_DEVICE));
   return parameters;
 }
コード例 #2
0
ファイル: VMSDiskInfo.java プロジェクト: rdndnl/lcmc
 /** 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;
   }
 }