Examples of YProgressWindowRepeat


Examples of de.yaams.maker.helper.gui.YProgressWindowRepeat

   * @author http://www.wsoftware.de/practices/file-io.html
   * @param zip
   * @param goal
   */
  public static void packZip(final File dir, final File goal) {
    YProgressWindowRepeat y = new YProgressWindowRepeat(I18N.t("Packe {0} nach {1}", dir, goal.getName()), "archive_setup");
    try {
      int prefixLength;
      ZipOutputStream zipOut;
      prefixLength = dir.getAbsolutePath().length() + 1;
      zipOut = new ZipOutputStream(new FileOutputStream(goal.getAbsolutePath()));
      try {
        createZipFrom(y, zipOut, prefixLength, dir);
      } finally {
        zipOut.close();
      }
    } catch (final Throwable t) {
      YEx.warn("Can not pack zip from " + dir + " to " + goal, t);
    }
    y.close();
  }
View Full Code Here

Examples of de.yaams.maker.helper.gui.YProgressWindowRepeat

   * @throws NoSuchAlgorithmException
   * @throws NoSuchPaddingException
   */
  public static void encryptFile(File originalFile, File encryptedFile, String password, String type) throws NoSuchAlgorithmException, NoSuchPaddingException {

    YProgressWindowRepeat y = new YProgressWindowRepeat(I18N.t("Verschlüssle " + originalFile.getName()), "lock");

    FileInputStream in = null;
    CipherOutputStream out = null;
    try {
      // set basics
      Cipher cipher = Cipher.getInstance(type);
      SecretKey key = new SecretKeySpec(password.getBytes(), type);
      cipher.init(Cipher.ENCRYPT_MODE, key);

      // do it
      in = new FileInputStream(originalFile);
      out = new CipherOutputStream(new FileOutputStream(encryptedFile), cipher);
      byte[] byteBuffer = new byte[1024];
      for (int n; (n = in.read(byteBuffer)) != -1; out.write(byteBuffer, 0, n)) {
        ;
      }
      in.close();
      out.close();
      // new File(originalFile).delete();
    } catch (Throwable t) {
      YEx.warn("Can not encrypt File " + originalFile + " to " + encryptedFile, t);
    } finally {
      // close it
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
      }
      // close it
      try {
        if (out != null) {
          out.close();
        }
      } catch (IOException e) {
      }
    }

    y.close();
  }
View Full Code Here

Examples of de.yaams.maker.helper.gui.YProgressWindowRepeat

   * @throws NoSuchPaddingException
   */
  public static void decryptFile(File encryptedFile, File decryptedFile, String password, String type) throws NoSuchAlgorithmException,
      NoSuchPaddingException {

    YProgressWindowRepeat y = new YProgressWindowRepeat(I18N.t("Entschlüssle " + encryptedFile.getName()), "unlock");

    CipherInputStream in = null;
    OutputStream out = null;
    try {
      // set basics
      Cipher cipher = Cipher.getInstance(type);
      SecretKey key = new SecretKeySpec(password.getBytes(), type);
      cipher.init(Cipher.DECRYPT_MODE, key);
      // do it
      in = new CipherInputStream(new FileInputStream(encryptedFile), cipher);
      out = new FileOutputStream(decryptedFile);
      byte[] byteBuffer = new byte[1024];
      for (int n; (n = in.read(byteBuffer)) != -1; out.write(byteBuffer, 0, n)) {
        ;
      }
      in.close();
      out.close();
      // new File(encryptedFile).delete();
    } catch (Throwable t) {
      YEx.warn("Can not decrypt File " + encryptedFile + " to " + decryptedFile, t);
    } finally {
      // close it
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
      }
      // close it
      try {
        if (out != null) {
          out.close();
        }
      } catch (IOException e) {
      }

    }

    y.close();
  }
View Full Code Here

Examples of de.yaams.maker.helper.gui.YProgressWindowRepeat

        }

        // imageeditor exist?
        final File f = new File(YAamsCore.programPath, "imageeditor.jar");

        YProgressWindowRepeat y = new YProgressWindowRepeat("Starting " + f.getAbsolutePath(), "imageeditor");
        if (!f.exists()) {
          // dl it
          NetHelper.downloadFile(f, "http://www.yaams.de/file/plugins/ImageEditor.jar");
        }

        // check file
        if (RessRess.endWithExtention(file, new String[] { "ie", "jpg", "jpeg", "jpe", "gif", "png", "psd", "bmp", "pict", "tga",
            "ras", "pcx" })
            || !RessRess.endWithExtention(file, new String[] { "ie", "jpg", "jpeg", "jpe", "gif", "png", "psd", "bmp", "pict",
                "tga", "ras", "pcx" })
            && YDialog.askUser(I18N.t("Bild {0} wird nicht unterstützt.", file.getName()), "ress.imageeditor",
                "imageeditor_warn",
                I18N.t("Wahrscheinlich kann ImageEditor die Datei nicht öffnen. Soll Sie dennoch geöffnet werden?"),
                I18N.t("Trotzdem öffnen"), I18N.CANCEL, "imageeditor_ok", "cancel")) {
          // run it
          SystemHelper.runExternal(
              new String[] { "java", "-jar", "-Xms128m", "-Xmx512M", f.getAbsolutePath(), file.getAbsolutePath() }, true);
        }

        y.close();
      }
    }));

    imagepanel.add(bar, BorderLayout.NORTH);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.