コード例 #1
0
  /**
   * Constructs a <tt>RegistryUninstallerListener</tt>.
   *
   * @param handler the handler
   * @param resources the resources
   * @param messages the messages
   */
  public RegistryUninstallerListener(
      RegistryDefaultHandler handler, Resources resources, Messages messages) {
    System.out.println("Cleaning the windows registry");

    this.handler = handler.getInstance();
    this.resources = resources;
    this.messages = messages;
  }
コード例 #2
0
  /**
   * Invoked before files are deleted.
   *
   * @param files all files which should be deleted
   * @throws IzPackException for any error
   */
  @Override
  public void beforeDelete(List<File> files) {
    if (actions == null || actions.isEmpty()) {
      return;
    }

    try {
      RegistryHandler registryHandler = handler.getInstance();
      if (registryHandler == null) {
        return;
      }
      registryHandler.activateLogging();
      registryHandler.setLoggingInfo(actions);
      registryHandler.rewind();
    } catch (NativeLibException e) {
      throw new WrappedNativeLibException(e, messages);
    }
  }
コード例 #3
0
 /**
  * Returns the path to the needed JDK if found in the registry. If there are more than one JDKs
  * registered, that one with the highest allowd version will be returned. Works only on windows.
  * On Unix an empty string returns.
  *
  * @return the path to the needed JDK if found in the windows registry
  */
 private String resolveInRegistry() {
   String retval = "";
   int oldVal = 0;
   RegistryHandler registryHandler = null;
   badRegEntries = new HashSet<String>();
   try {
     // Get the default registry handler.
     registryHandler = RegistryDefaultHandler.getInstance();
     if (registryHandler == null)
     // We are on a os which has no registry or the
     // needed dll was not bound to this installation. In
     // both cases we forget the try to get the JDK path from registry.
     {
       return (retval);
     }
     registryHandler.verify(this.installData);
     oldVal = registryHandler.getRoot(); // Only for security...
     registryHandler.setRoot(MSWinConstants.HKEY_LOCAL_MACHINE);
     String[] keys = registryHandler.getSubkeys(JDK_ROOT_KEY);
     if (keys == null || keys.length == 0) {
       return (retval);
     }
     Arrays.sort(keys);
     int i = keys.length - 1;
     String min = getMinVersion();
     String max = getMaxVersion();
     // We search for the highest allowd version, therefore retrograde
     while (i > 0) {
       if (compareVersions(
           keys[i],
           max,
           false,
           4,
           4,
           "__NO_NOT_IDENTIFIER_")) { // First allowd version found, now we have to test that the
         // min value
         // also allows this version.
         if (compareVersions(keys[i], min, true, 4, 4, "__NO_NOT_IDENTIFIER_")) {
           String cv = JDK_ROOT_KEY + "\\" + keys[i];
           String path = registryHandler.getValue(cv, JDK_VALUE_NAME).getStringData();
           // Use it only if the path is valid.
           // Set the path for method pathIsValid ...
           pathSelectionPanel.setPath(path);
           if (!pathIsValid()) {
             badRegEntries.add(keys[i]);
           } else if ("".equals(retval)) {
             retval = path;
           }
           pathSelectionPanel.setPath(retval);
         }
       }
       i--;
     }
   } catch (Exception e) { // Will only be happen if registry handler is good, but an
     // exception at performing was thrown. This is an error...
     e.printStackTrace();
   } finally {
     if (registryHandler != null && oldVal != 0) {
       try {
         registryHandler.setRoot(MSWinConstants.HKEY_LOCAL_MACHINE);
       } catch (NativeLibException e) {
         e.printStackTrace();
       }
     }
   }
   return (retval);
 }