Exemplo n.º 1
0
        @Override
        public void actionPerformed(ActionEvent e) {
          final List<String> choice = list.getSelectedValues();

          if (choice == null) {
            return;
          }

          // OK name

          final String trailS = (choice.size() > 1 ? "s" : "");

          // @formatter:off
          final boolean yes =
              Alerts.askYesNo(
                  DialogManageMcPacks.this,
                  "Deleting Installed Pack" + trailS,
                  "Do you really want to delete the selected\n"
                      + "resource pack"
                      + trailS
                      + " from your Minecraft folder?");
          // @formatter:on

          if (!yes) return;

          for (final String s : choice) {
            final File f = new File(OsUtils.getMcDir("resourcepacks"), s + ".zip");
            f.delete();
          }

          reloadOptions();
        }
  public static void run(FileFsTreeNode fileNode, Runnable afterImport) {
    final String title = "Import sound file into sounds/" + fileNode.getPathRelativeToRoot();
    final FileChooser fc =
        new FileChooser(
            App.getFrame(), FilePath.IMPORT_SOUND, title, FileChooser.OGG, true, false, false);

    fc.showDialog("Open");

    if (!fc.approved()) {
      return;
    }

    fc.showDialog("Import");
    if (fc.approved()) {
      return;
    }

    final File file = fc.getSelectedFile();

    if (file == null || !file.exists()) {
      Alerts.error(App.getFrame(), "That's not a valid file.");
      return;
    }

    try {
      final File target = fileNode.getPath();
      target.mkdirs();

      FileUtils.copyFile(file, new File(target, file.getName()));

      if (afterImport != null) afterImport.run();

    } catch (final IOException e) {
      Log.e(e);
      Alerts.error(App.getFrame(), "Something went wrong during import.");
    }
  }