<commit_before>package com.eddysystems.eddy;

import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.util.PathUtil;
import com.intellij.util.ResourceUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

import static com.eddysystems.eddy.engine.Utility.log;

public class TOSDialog extends DialogWrapper {
  private JPanel contentPane;
  private JRadioButton iAcceptTheTermsRadioButton;
  private JRadioButton iDoNotAcceptRadioButton;
  private JTextPane TOSTextPane;
  private ButtonGroup acceptGroup;

  public TOSDialog() {
    super(null, false, IdeModalityType.IDE);
    init();
    setTitle("eddy - Terms Of Service");
    setCrossClosesWindow(false);
    // get TOS page our of our jar or directory
    final String pathname = PathUtil.getJarPathForClass(TOSDialog.class);
    final File path = new File(pathname);
    try {
      final URL url;
      if (path.isDirectory()) {
        url = new File(path, "terms-of-service.html").toURI().toURL();
      } else {
        url = ResourceUtil.getResource(TOSDialog.class, "", "terms-of-service.html");
      }
      TOSTextPane.setPage(url);
    } catch (MalformedURLException e) {
      throw new RuntimeException("Cannot load terms of service. Please try reinstalling.", e);
    } catch (IOException e) {
      throw new RuntimeException("Cannot load terms of service. Please try reinstalling.", e);
    }

    HyperlinkListener l = new HyperlinkListener() {
      @Override
      public void hyperlinkUpdate(HyperlinkEvent e) {
        log("got link event: " + e);
        if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
          try {
            java.awt.Desktop.getDesktop().browse(e.getURL().toURI());
          } catch (IOException e1) {
            // wtf, do nothing
            log("exception: " + e1);
          } catch (URISyntaxException e2) {
            // broken link, do nothing
            log("exception: " + e2);
          }
        }
      }
    };
    TOSTextPane.addHyperlinkListener(l);
  }

  public boolean isAccepted() {
    return acceptGroup.isSelected(iAcceptTheTermsRadioButton.getModel());
  }

  @Override
  protected ValidationInfo doValidate() {
    if (acceptGroup.getSelection() == null) {
      return new ValidationInfo("Please accept or reject the Terms Of Service (actually, please accept them).", iDoNotAcceptRadioButton);
    }
    return null;
  }

  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    return contentPane;
  }

  @NotNull
  @Override
  protected Action[] createActions() {
    return new Action[]{getOKAction()};
  }

  @Nullable
  @Override
  protected ActionListener createCancelAction() {
    return null;//Prevent closing by <Esc>
  }
}<commit_msg>TOSDialog: Fix compile for IntelliJ 13<commit_after>package com.eddysystems.eddy;

import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.util.PathUtil;
import com.intellij.util.ResourceUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

import static com.eddysystems.eddy.engine.Utility.log;

public class TOSDialog extends DialogWrapper {
  private JPanel contentPane;
  private JRadioButton iAcceptTheTermsRadioButton;
  private JRadioButton iDoNotAcceptRadioButton;
  private JTextPane TOSTextPane;
  private ButtonGroup acceptGroup;

  public TOSDialog() {
    super(null, false, IdeModalityType.IDE);
    init();
    setTitle("eddy - Terms Of Service");
    setCrossClosesWindow(false);
    // get TOS page our of our jar or directory
    final String pathname = PathUtil.getJarPathForClass(TOSDialog.class);
    final File path = new File(pathname);
    try {
      final URL url;
      if (path.isDirectory()) {
        url = new File(path, "terms-of-service.html").toURI().toURL();
      } else {
        url = ResourceUtil.getResource(TOSDialog.class, "", "terms-of-service.html");
      }
      TOSTextPane.setPage(url);
    } catch (MalformedURLException e) {
      throw new RuntimeException("Cannot load terms of service. Please try reinstalling.", e);
    } catch (IOException e) {
      throw new RuntimeException("Cannot load terms of service. Please try reinstalling.", e);
    }

    HyperlinkListener l = new HyperlinkListener() {
      @Override
      public void hyperlinkUpdate(HyperlinkEvent e) {
        log("got link event: " + e);
        if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
          try {
            java.awt.Desktop.getDesktop().browse(e.getURL().toURI());
          } catch (IOException e1) {
            // wtf, do nothing
            log("exception: " + e1);
          } catch (URISyntaxException e2) {
            // broken link, do nothing
            log("exception: " + e2);
          }
        }
      }
    };
    TOSTextPane.addHyperlinkListener(l);
  }

  public boolean isAccepted() {
    return acceptGroup.isSelected(iAcceptTheTermsRadioButton.getModel());
  }

  @Override
  protected ValidationInfo doValidate() {
    if (acceptGroup.getSelection() == null) {
      return new ValidationInfo("Please accept or reject the Terms Of Service (actually, please accept them).", iDoNotAcceptRadioButton);
    }
    return null;
  }

  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    return contentPane;
  }

  @NotNull
  @Override
  protected Action[] createActions() {
    return new Action[]{getOKAction()};
  }

  @Nullable
  protected ActionListener createCancelAction() {
    return null;//Prevent closing by <Esc>
  }
}
{'fraction_non_alphanumeric': 0.10592604553528177, 'fraction_numerical': 0.0016147263038914905, 'mean_word_length': 3.3466666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '962145', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1811, 'n_words': 438}