// Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
//     name = "FossilConfiguration",
//     storages = {
//         @Storage(file = StoragePathMacros.WORKSPACE_FILE)
//     }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
//   public String FOSSIL_PATH = "";
//   private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
// 
//   @Nullable
//   public Element getState() {
//     Element element = new Element("state");
//     element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
//     return element;
//   }
// 
//   public void loadState(Element element) {
//     final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
//     if (fossilPath != null) {
//       FOSSIL_PATH = fossilPath.getValue();
//     }
//   }
// 
//   public static FossilConfiguration getInstance(final Project project) {
//     return ServiceManager.getService(project, FossilConfiguration.class);
//   }
// 
//   public void setRemoteUrls(final Map<File, String> urls) {
//     myRemoteUrls.clear();
//     myRemoteUrls.putAll(urls);
//   }
// 
//   public Map<File, String> getRemoteUrls() {
//     return myRemoteUrls;
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
//   private final static int optimal = 100;
//   private final int myLimit;
// 
//   public TextUtil() {
//     this(-1);
//   }
// 
//   public TextUtil(int limit) {
//     this.myLimit = limit < 0 ? optimal : limit;
//   }
// 
//   public String insertLineCuts(final String s) {
//     if (s == null || s.length() <= myLimit) return s;
//     final int idx = s.substring(0, myLimit).lastIndexOf(' ');
//     if (idx > 0) {
//       return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
//     }
//     final int idx2 = s.indexOf(' ', myLimit);
//     if (idx2 == -1) return s;
//     return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
//   }
// }


import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
  private final String myWarning;
  private final Map<File, JBTextField> myFields;

  public FossilUpdateConfigurable(final Project project, final Collection<FilePath> roots, Map<File, String> checkoutURLs, String warning) {
    myProject = project;
    myRoots = roots;
    myCheckoutURLs = checkoutURLs;
    myWarning = warning;
    myFields = new HashMap<File, JBTextField>();
  }

  @Nls
  @Override
  public String getDisplayName() {
    return "Fossil Update Settings";
  }

  @Nullable
  @Override
  public String getHelpTopic() {
    return null;
  }

  @Nullable
  @Override
  public JComponent createComponent() {
    final JBPanel panel = new JBPanel(new GridBagLayout());
    if (myRoots.size() > 1) {
      buildForMultiple(panel);
    } else {
// Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
//     name = "FossilConfiguration",
//     storages = {
//         @Storage(file = StoragePathMacros.WORKSPACE_FILE)
//     }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
//   public String FOSSIL_PATH = "";
//   private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
// 
//   @Nullable
//   public Element getState() {
//     Element element = new Element("state");
//     element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
//     return element;
//   }
// 
//   public void loadState(Element element) {
//     final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
//     if (fossilPath != null) {
//       FOSSIL_PATH = fossilPath.getValue();
//     }
//   }
// 
//   public static FossilConfiguration getInstance(final Project project) {
//     return ServiceManager.getService(project, FossilConfiguration.class);
//   }
// 
//   public void setRemoteUrls(final Map<File, String> urls) {
//     myRemoteUrls.clear();
//     myRemoteUrls.putAll(urls);
//   }
// 
//   public Map<File, String> getRemoteUrls() {
//     return myRemoteUrls;
//   }
// }
// 
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
//   private final static int optimal = 100;
//   private final int myLimit;
// 
//   public TextUtil() {
//     this(-1);
//   }
// 
//   public TextUtil(int limit) {
//     this.myLimit = limit < 0 ? optimal : limit;
//   }
// 
//   public String insertLineCuts(final String s) {
//     if (s == null || s.length() <= myLimit) return s;
//     final int idx = s.substring(0, myLimit).lastIndexOf(' ');
//     if (idx > 0) {
//       return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
//     }
//     final int idx2 = s.indexOf(' ', myLimit);
//     if (idx2 == -1) return s;
//     return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
//   }
// }


// Path: src/org/github/irengrig/fossil4idea/pull/FossilUpdateConfigurable.java
import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

  private final String myWarning;
  private final Map<File, JBTextField> myFields;

  public FossilUpdateConfigurable(final Project project, final Collection<FilePath> roots, Map<File, String> checkoutURLs, String warning) {
    myProject = project;
    myRoots = roots;
    myCheckoutURLs = checkoutURLs;
    myWarning = warning;
    myFields = new HashMap<File, JBTextField>();
  }

  @Nls
  @Override
  public String getDisplayName() {
    return "Fossil Update Settings";
  }

  @Nullable
  @Override
  public String getHelpTopic() {
    return null;
  }

  @Nullable
  @Override
  public JComponent createComponent() {
    final JBPanel panel = new JBPanel(new GridBagLayout());
    if (myRoots.size() > 1) {
      buildForMultiple(panel);
    } else {
      buildForOne(panel, myRoots.iterator().next());