Exemple #1
0
  /** @return true if keymap was installed or was successfully installed */
  public static boolean installKeyBoardBindings() {
    LOG.debug("Check for keyboard bindings");
    final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
    if (localFileSystem.refreshAndFindFileByPath(KEYMAPS_PATH) == null) {
      reportError("Failed to install vim keymap. Empty keymaps folder");
      return false;
    }

    LOG.debug("No vim keyboard installed found. Installing");
    try {
      final byte[] bytes = toByteArray(retrieveSourceKeymapStream());
      Files.write(bytes, new File(INSTALLED_VIM_KEYMAP_PATH));
      final Document document = StorageUtil.loadDocument(bytes);
      if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
        // Prompt user to select the parent for the Vim keyboard
        if (!configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true)) {
          return false;
        }
      }
      installKeymap(document);
    } catch (IOException e) {
      reportError("Source keymap not found", e);
      return false;
    } catch (InvalidDataException e) {
      reportError("Failed to install vim keymap. Vim.xml file is corrupted", e);
      return false;
    } catch (Exception e) {
      reportError("Failed to install vim keymap.\n", e);
      return false;
    }

    return true;
  }
 @Override
 public boolean isApplicable(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
   return myRoamingType == roamingType
       && !(roamingType == RoamingType.PER_USER && StorageUtil.isProjectOrModuleFile(fileSpec));
 }