// Path: AndroidTextExtensions/common/src/main/java/digitaslbi/ext/common/Constants.java
// public interface Constants {
// 
//     String ASSETS_FOLDER = "assets";
// 
//     String RESOURCE_FOLDER = "res";
// 
//     String VALUES_FOLDER = "values";
// 
//     String BOOTSTRAP_PACKAGE_NAME = "digitaslbi.ext.fonts";
// 
//     String BOOTSTRAP_CLASS_NAME = "FontFamilies";
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/Dialogs.java
// public class Dialogs {
// 
//     public static void showInfo(Project project, String text) {
//         showDialog(project, MessageType.INFO, text);
//     }
// 
//     public static void showError(Project project, String text) {
//         showDialog(project, MessageType.ERROR, text);
//     }
// 
//     public static void showDialog(Project project, MessageType type, String text) {
//         StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
//         if (statusBar != null) {
//             JBPopupFactory.getInstance()
//                     .createHtmlTextBalloonBuilder(text, type, null)
//                     .setFadeoutTime(10000)
//                     .createBalloon()
//                     .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
//         }
//     }
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/Log.java
// public final class Log {
// 
//     private static final boolean DEBUG = true;
// 
// 
//     public static void d(Class<?> caller, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg);
//             Logger.getInstance(caller).debug(formattedMsg);
//         }
//     }
// 
//     public static void e(Class<?> caller, Throwable e, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg + "\n" + e.getMessage());
//             Logger.getInstance(caller).error(formattedMsg, e);
//         }
//     }
// 
//     public static void e(Class<?> caller, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg);
//             Logger.getInstance(caller).error(formattedMsg);
//         }
//     }
// 
//     private static String tag(Class<?> caller) {
//         return caller.isAnonymousClass() ? caller.getName() : caller.getCanonicalName();
//     }
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/CommandHelper.java
// public static void runLater(final Project project, final Runnable r) {
//     DumbService.getInstance(project).smartInvokeLater(r);
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/CommandHelper.java
// public static void runWriteCommand(Project project, Runnable cmd) {
//     //CommandProcessor.getInstance().executeCommand(project, new WriteAction(cmd), "write", "write");
//     runLater(project, new WriteAction(cmd));
// }


import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.*;
import com.intellij.util.Processor;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.update.MergingUpdateQueue;
import digitaslbi.ext.common.Constants;
import digitaslbi.ext.plugin.utils.Dialogs;
import digitaslbi.ext.plugin.utils.Log;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.List;
import static digitaslbi.ext.plugin.utils.CommandHelper.runLater;
import static digitaslbi.ext.plugin.utils.CommandHelper.runWriteCommand;
import static java.lang.String.format;
        VfsUtilCore.processFilesRecursively(event.getFile(), new Processor<VirtualFile>() {
          @Override
          public boolean process(VirtualFile virtualFile) {
            if (fileProcessor.isValidFontFile(virtualFile)) {
              deleteFile(virtualFile.getPath());
            }
            return true;
          }
        });
      } else {
        deleteFile(event.getPath());
      }
    }

    if (event instanceof VFileCopyEvent || event instanceof VFileContentChangeEvent) {
      deleteFile(event.getPath());
    } else if (event instanceof VFileMoveEvent) {
      deleteFile(((VFileMoveEvent) event).getOldPath());
    } else if (event instanceof VFilePropertyChangeEvent && ((VFilePropertyChangeEvent) event).getPropertyName().endsWith(VirtualFile.PROP_NAME)) {
      deleteFile(((VFilePropertyChangeEvent) event).getOldPath());
    }
  }

  private void processAfterEvent(final VFileEvent event) {
    runLater(project, new Runnable() {
      @Override
      public void run() {
        try {
          plugin.generate();
        } catch (PluginException e) {
// Path: AndroidTextExtensions/common/src/main/java/digitaslbi/ext/common/Constants.java
// public interface Constants {
// 
//     String ASSETS_FOLDER = "assets";
// 
//     String RESOURCE_FOLDER = "res";
// 
//     String VALUES_FOLDER = "values";
// 
//     String BOOTSTRAP_PACKAGE_NAME = "digitaslbi.ext.fonts";
// 
//     String BOOTSTRAP_CLASS_NAME = "FontFamilies";
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/Dialogs.java
// public class Dialogs {
// 
//     public static void showInfo(Project project, String text) {
//         showDialog(project, MessageType.INFO, text);
//     }
// 
//     public static void showError(Project project, String text) {
//         showDialog(project, MessageType.ERROR, text);
//     }
// 
//     public static void showDialog(Project project, MessageType type, String text) {
//         StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
//         if (statusBar != null) {
//             JBPopupFactory.getInstance()
//                     .createHtmlTextBalloonBuilder(text, type, null)
//                     .setFadeoutTime(10000)
//                     .createBalloon()
//                     .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
//         }
//     }
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/Log.java
// public final class Log {
// 
//     private static final boolean DEBUG = true;
// 
// 
//     public static void d(Class<?> caller, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg);
//             Logger.getInstance(caller).debug(formattedMsg);
//         }
//     }
// 
//     public static void e(Class<?> caller, Throwable e, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg + "\n" + e.getMessage());
//             Logger.getInstance(caller).error(formattedMsg, e);
//         }
//     }
// 
//     public static void e(Class<?> caller, String msg, Object... args) {
//         if (DEBUG) {
//             String formattedMsg = String.format(msg, args);
//             System.out.println(tag(caller) + ": " + formattedMsg);
//             Logger.getInstance(caller).error(formattedMsg);
//         }
//     }
// 
//     private static String tag(Class<?> caller) {
//         return caller.isAnonymousClass() ? caller.getName() : caller.getCanonicalName();
//     }
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/CommandHelper.java
// public static void runLater(final Project project, final Runnable r) {
//     DumbService.getInstance(project).smartInvokeLater(r);
// }
// 
// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/utils/CommandHelper.java
// public static void runWriteCommand(Project project, Runnable cmd) {
//     //CommandProcessor.getInstance().executeCommand(project, new WriteAction(cmd), "write", "write");
//     runLater(project, new WriteAction(cmd));
// }


// Path: AndroidTextExtensionsPlugin/src/digitaslbi/ext/plugin/AssetsWatcher.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.*;
import com.intellij.util.Processor;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.update.MergingUpdateQueue;
import digitaslbi.ext.common.Constants;
import digitaslbi.ext.plugin.utils.Dialogs;
import digitaslbi.ext.plugin.utils.Log;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.List;
import static digitaslbi.ext.plugin.utils.CommandHelper.runLater;
import static digitaslbi.ext.plugin.utils.CommandHelper.runWriteCommand;
import static java.lang.String.format;

        VfsUtilCore.processFilesRecursively(event.getFile(), new Processor<VirtualFile>() {
          @Override
          public boolean process(VirtualFile virtualFile) {
            if (fileProcessor.isValidFontFile(virtualFile)) {
              deleteFile(virtualFile.getPath());
            }
            return true;
          }
        });
      } else {
        deleteFile(event.getPath());
      }
    }

    if (event instanceof VFileCopyEvent || event instanceof VFileContentChangeEvent) {
      deleteFile(event.getPath());
    } else if (event instanceof VFileMoveEvent) {
      deleteFile(((VFileMoveEvent) event).getOldPath());
    } else if (event instanceof VFilePropertyChangeEvent && ((VFilePropertyChangeEvent) event).getPropertyName().endsWith(VirtualFile.PROP_NAME)) {
      deleteFile(((VFilePropertyChangeEvent) event).getOldPath());
    }
  }

  private void processAfterEvent(final VFileEvent event) {
    runLater(project, new Runnable() {
      @Override
      public void run() {
        try {
          plugin.generate();
        } catch (PluginException e) {
          Dialogs.showError(project, format("Failed to re-generate files after assets changed in %s: %s", event.getPath(), e.getMessage()));