// 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;
      panel.add(field, c);
      myFields.put(root.getIOFile(), field);
      final String preset = myCheckoutURLs.get(root.getIOFile());
      if (preset != null) {
        field.setText(preset);
      }
    }
    addWarning(panel, c);
  }

  private void addWarning(JBPanel panel, GridBagConstraints c) {
    if (myWarning != null && myWarning.length() > 0) {
      ++ c.gridy;
      c.gridx = 0;
      c.gridwidth = 2;
      c.fill = GridBagConstraints.HORIZONTAL;
      final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning));
      label.setUI(new MultiLineLabelUI());
      label.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
      panel.add(label, c);
    }
  }

  @Override
  public boolean isModified() {
    return false;
  }

  @Override
  public void apply() throws ConfigurationException {
// 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;

      panel.add(field, c);
      myFields.put(root.getIOFile(), field);
      final String preset = myCheckoutURLs.get(root.getIOFile());
      if (preset != null) {
        field.setText(preset);
      }
    }
    addWarning(panel, c);
  }

  private void addWarning(JBPanel panel, GridBagConstraints c) {
    if (myWarning != null && myWarning.length() > 0) {
      ++ c.gridy;
      c.gridx = 0;
      c.gridwidth = 2;
      c.fill = GridBagConstraints.HORIZONTAL;
      final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning));
      label.setUI(new MultiLineLabelUI());
      label.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
      panel.add(label, c);
    }
  }

  @Override
  public boolean isModified() {
    return false;
  }

  @Override
  public void apply() throws ConfigurationException {
    FossilConfiguration configuration = FossilConfiguration.getInstance(myProject);