// Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
//   private final Project myProject;
// 
//   public CheckoutUtil(final Project project) {
//     myProject = project;
//   }
// 
//   public void cloneRepo(final String url, final String localPath) throws VcsException {
//     final File file = new File(localPath);
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
//     command.addParameters(url, localPath);
//     final String result = command.run();
//   }
// 
//   public void checkout(final File repo, final File target, final String hash) throws VcsException {
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
//     command.addParameters(repo.getAbsolutePath());
//     if (hash != null) {
//       command.addParameters(hash);
//     }
//     command.run();
//   }
// 
//   public void initRepository(final File repo) throws VcsException {
//     final File parentFile = repo.getParentFile();
//     if (parentFile.exists() && ! parentFile.isDirectory()) {
//       throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
//     }
//     if (! parentFile.exists() && ! parentFile.mkdirs()) {
//       throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
//     }
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
//     command.addParameters(repo.getName());
//     command.run();
//   }
// }


import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.util.Consumer;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.io.File;
package org.github.irengrig.fossil4idea.actions;



public class OpenAction extends AnAction {
  @Override
  public void actionPerformed(AnActionEvent anActionEvent) {
    final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
    if (project == null) return;

    final CheckoutUIWorker uiWorker = new CheckoutUIWorker();
    uiWorker.showDialog(project, new Runnable() {
      @Override
      public void run() {
        ProgressManager.getInstance().run(new Task.Backgroundable(project, "Open Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
          @Override
          public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
// Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
//   private final Project myProject;
// 
//   public CheckoutUtil(final Project project) {
//     myProject = project;
//   }
// 
//   public void cloneRepo(final String url, final String localPath) throws VcsException {
//     final File file = new File(localPath);
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
//     command.addParameters(url, localPath);
//     final String result = command.run();
//   }
// 
//   public void checkout(final File repo, final File target, final String hash) throws VcsException {
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
//     command.addParameters(repo.getAbsolutePath());
//     if (hash != null) {
//       command.addParameters(hash);
//     }
//     command.run();
//   }
// 
//   public void initRepository(final File repo) throws VcsException {
//     final File parentFile = repo.getParentFile();
//     if (parentFile.exists() && ! parentFile.isDirectory()) {
//       throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
//     }
//     if (! parentFile.exists() && ! parentFile.mkdirs()) {
//       throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
//     }
//     final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
//     command.addParameters(repo.getName());
//     command.run();
//   }
// }


// Path: src/org/github/irengrig/fossil4idea/actions/OpenAction.java
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.util.Consumer;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.io.File;

package org.github.irengrig.fossil4idea.actions;



public class OpenAction extends AnAction {
  @Override
  public void actionPerformed(AnActionEvent anActionEvent) {
    final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
    if (project == null) return;

    final CheckoutUIWorker uiWorker = new CheckoutUIWorker();
    uiWorker.showDialog(project, new Runnable() {
      @Override
      public void run() {
        ProgressManager.getInstance().run(new Task.Backgroundable(project, "Open Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
          @Override
          public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
              new CheckoutUtil(project).checkout(new File(uiWorker.getRepo()), new File(uiWorker.getLocalPath()), null);