public void actionPerformed(ActionEvent e) {
   if (e.getSource() == discard) {
     for (ArgumentComponent a : argComp) a.discard();
     close();
   } else if (e.getSource() == save) {
     updateResource();
     close();
   }
 }
 public void commitChanges() {
   act.setAppliesTo(getApplies());
   if (relativeBox != null) act.setRelative(relativeBox.isSelected());
   if (notBox != null) act.setNot(notBox.isSelected());
   switch (act.getLibAction().interfaceKind) {
     case LibAction.INTERFACE_CODE:
       act.getArguments().get(0).setVal(code.getTextCompat());
       break;
     default:
       for (ArgumentComponent a : argComp) a.commit();
   }
 }
  @Override
  public void process(JCas aJCas) throws AnalysisEngineProcessException {
    String documentId = DocumentMetaData.get(aJCas).getDocumentId();

    Class[] types = {Claim.class, Premise.class, Backing.class, Rebuttal.class, Refutation.class};
    for (Class type : types) {
      for (Object o : JCasUtil.select(aJCas, type)) {
        ArgumentComponent argumentComponent = (ArgumentComponent) o;

        // non-implicit components
        int end = argumentComponent.getEnd();
        int begin = argumentComponent.getBegin();
        if (end > begin) {
          List<Sentence> sentences =
              JCasUtil2.selectOverlapping(Sentence.class, argumentComponent, aJCas);

          String filename =
              documentId
                  + "_s"
                  + sentences.size()
                  + "_"
                  + argumentComponent.getClass().getSimpleName()
                  + "_"
                  + begin
                  + "_"
                  + end
                  + ".txt";

          StringBuilder sb = new StringBuilder();

          for (Sentence sentence : sentences) {
            List<String> tokens = new ArrayList<>();
            for (Token token : JCasUtil.selectCovered(Token.class, sentence)) {
              tokens.add(token.getCoveredText());
            }

            sb.append(StringUtils.join(tokens, " "));
            sb.append("\n");
          }

          try {
            FileUtils.write(new File(outputFolder, filename), sb.toString().trim());
          } catch (IOException e) {
            throw new AnalysisEngineProcessException(e);
          }
        }
      }
    }
  }