!7

cmodule OfferToCreateDirs > DynPrintLogAndEnabled {
  transient AutoCloseable suggestion;
  transient S lastPath;

  start {
    doEvery(1.0, r check);
  }

  void check enter {
    if (!enabled) ret;
    JComboBox cb = getFocusOwningComboBox();
    S text = gtt(cb);
    if (!eq(lastPath, text) && isAbsolutePath(text) && !fileExists(text)) {
      lastPath = text;
      dispose suggestion;
      suggestion = dm_showSuggestion(print("Create directory? " + text),
        r { mkdirs(text); infoBox("Created directory: " + text); });
    }
  }
}