/**
  * Load the sample text to be displayed in the preview pane.
  *
  * @return the text loaded from {@link #SAMPLE_MARKDOWN_DOCUMENT_PATH}
  * @see #getDemoText()
  * @see #SAMPLE_MARKDOWN_DOCUMENT_PATH
  * @see #SAMPLE_MARKDOWN_DOCUMENT
  */
 protected static String loadSampleMarkdownDocument() {
   try {
     return FileUtil.loadTextAndClose(
         new InputStreamReader(
             MarkdownColorSettingsPage.class.getResourceAsStream(SAMPLE_MARKDOWN_DOCUMENT_PATH)));
   } catch (Exception e) {
     LOGGER.error("Failed loading sample Markdown document", e);
   }
   return MarkdownBundle.message("markdown.editor.colorsettingspage.sample-loading-error");
 }
Exemplo n.º 2
0
 public static String readSampleScriptFile(String pluginPath, String file) {
   try {
     String path = pluginPath + "/" + file;
     return FileUtil.loadTextAndClose(
         LivePluginAppComponent.class.getClassLoader().getResourceAsStream(path));
   } catch (IOException e) {
     LOG.error(e);
     return "";
   }
 }
Exemplo n.º 3
0
 @NotNull
 @Override
 public String getDemoText() {
   try {
     return FileUtil.loadTextAndClose(
         this.getClass()
             .getResourceAsStream("/ro/uaic/fmse/kplugin/highlighting/KColorSettingsDemo.txt"));
   } catch (IOException e) {
     Logger.getInstance(this.getClass().getName()).error(e);
     return "";
   }
 }
 @NotNull
 private static ImmutableMap<String, String> loadPackageAliases() {
   final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
   try (FileReader reader =
       new FileReader(PythonHelpersLocator.getHelperPath("/tools/packages"))) {
     final String text = FileUtil.loadTextAndClose(reader);
     final List<String> lines = StringUtil.split(text, "\n");
     for (String line : lines) {
       final List<String> split = StringUtil.split(line, " ");
       builder.put(split.get(0), split.get(1));
     }
   } catch (IOException e) {
     LOG.error("Cannot find \"packages\". " + e.getMessage());
   }
   return builder.build();
 }
 private void buildForKeyword(@NotNull final String name) {
   try {
     final FileReader reader =
         new FileReader(PythonHelpersLocator.getHelperPath("/tools/python_keywords/" + name));
     try {
       final String text = FileUtil.loadTextAndClose(reader);
       myEpilog.addItem(text);
     } catch (IOException ignored) {
     } finally {
       try {
         reader.close();
       } catch (IOException ignored) {
       }
     }
   } catch (FileNotFoundException ignored) {
   }
 }
Exemplo n.º 6
0
 public static String[] readLines(String url) throws IOException {
   return FileUtil.loadTextAndClose(
           new BufferedReader(new InputStreamReader(new URL(url).openStream())))
       .split("\n");
 }