Exemplo n.º 1
0
  public static void logAttachDetachException(AttachDetachException ade) {
    if (ade == null) return;

    for (Throwable t : ade.getCauses()) {
      if (t instanceof AttachDetachException) logAttachDetachException((AttachDetachException) t);
      else {
        Debug.devlog(t.toString());
        for (StackTraceElement ste : t.getStackTrace()) Debug.devlog(ste.toString());
      }
    }
  }
  // Return the selected template and format given the YAML front matter
  public RmdSelectedTemplate getTemplateFormat(String yaml) {
    // This is in the editor load path, so guard against exceptions and log
    // any we find without bringing down the editor. Failing to find a
    // template here just turns off the template-specific UI format editor.
    try {
      YamlTree tree = new YamlTree(yaml);
      boolean isShiny = false;

      if (tree.getKeyValue(RmdFrontMatter.KNIT_KEY).length() > 0) return null;

      // Find the template appropriate to the first output format listed.
      // If no output format is present, assume HTML document (as the
      // renderer does).
      List<String> outFormats = getOutputFormats(tree);
      String outFormat =
          outFormats == null ? RmdOutputFormat.OUTPUT_HTML_DOCUMENT : outFormats.get(0);

      RmdTemplate template = getTemplateForFormat(outFormat);
      if (template == null) return null;

      // If this format produces HTML and is marked as Shiny, treat it as
      // a Shiny format
      if (template.getFormat(outFormat).getExtension().equals("html")
          && tree.getKeyValue(RmdFrontMatter.RUNTIME_KEY).equals(RmdFrontMatter.SHINY_RUNTIME)) {
        isShiny = true;
      }

      return new RmdSelectedTemplate(template, outFormat, isShiny);
    } catch (Exception e) {
      Debug.log("Warning: Exception thrown while parsing YAML:\n" + yaml);
    }
    return null;
  }
Exemplo n.º 3
0
  public void updateWithAction(FileChange viewAction) {
    final FileSystemItem file = viewAction.getFile();
    final List<FileSystemItem> files = getFiles();
    switch (viewAction.getType()) {
      case FileChange.ADD:
        if (file.getParentPath().equalTo(containingPath_)) {
          int row = rowForFile(file);
          if (row == -1) {
            files.add(file);
            filesDataGrid_.setPageSize(files.size() + 1);
          } else {
            // since we eagerly perform renames at the client UI
            // layer then sometimes an "added" file is really just
            // a rename. in this case the file already exists due
            // to the eager rename in the client but still needs its
            // metadata updated
            files.set(row, file);
          }
        }
        break;

      case FileChange.MODIFIED:
        {
          int row = rowForFile(file);
          if (row != -1) files.set(row, file);
        }
        break;

      case FileChange.DELETE:
        {
          int row = rowForFile(file);
          if (row != -1) {
            files.remove(row);

            // if a file is deleted and then re-added within the same
            // event loop (as occurs when gedit saves a text file) the
            // table doesn't always update correctly (it has a duplicate
            // of the item deleted / re-added). the call to flush overcomes
            // this issue
            dataProvider_.flush();
          }
        }
        break;

      default:
        Debug.log("Unexpected file change type: " + viewAction.getType());

        break;
    }
  }
Exemplo n.º 4
0
  public void onModuleLoad() {
    Debug.injectDebug();

    Document.get().getBody().getStyle().setBackgroundColor("#e1e2e5");

    BrowserFence fence = GWT.create(BrowserFence.class);
    fence.go(
        new Command() {
          public void execute() {
            Command dismissProgressAnimation = showProgress();
            delayLoadApplication(dismissProgressAnimation);
          }
        });
  }
Exemplo n.º 5
0
  @Override
  public void onUiPrefsChanged(UiPrefsChangedEvent e) {
    if (e.getType().equals(UiPrefsChangedEvent.GLOBAL_TYPE)) {
      // get prefs accessor
      UIPrefsAccessor newUiPrefs = new UIPrefsAccessor(e.getUIPrefs(), JsObject.createJsObject());

      // show line numbers
      showLineNumbers().setGlobalValue(newUiPrefs.showLineNumbers().getGlobalValue());

      // highlight selected word
      highlightSelectedWord().setGlobalValue(newUiPrefs.highlightSelectedWord().getGlobalValue());

      // highlight selected line
      highlightSelectedLine().setGlobalValue(newUiPrefs.highlightSelectedLine().getGlobalValue());

      // pane config
      if (!newUiPrefs.paneConfig().getGlobalValue().isEqualTo(paneConfig().getGlobalValue())) {
        paneConfig().setGlobalValue(newUiPrefs.paneConfig().getGlobalValue());
      }

      // use spaces for tab
      useSpacesForTab().setGlobalValue(newUiPrefs.useSpacesForTab().getGlobalValue());

      // num spacers for tab
      numSpacesForTab().setGlobalValue(newUiPrefs.numSpacesForTab().getGlobalValue());

      // show margin
      showMargin().setGlobalValue(newUiPrefs.showMargin().getGlobalValue());

      // print margin column
      printMarginColumn().setGlobalValue(newUiPrefs.printMarginColumn().getGlobalValue());

      // show invisibles
      showInvisibles().setGlobalValue(newUiPrefs.showInvisibles().getGlobalValue());

      // show indent guides
      showIndentGuides().setGlobalValue(newUiPrefs.showIndentGuides().getGlobalValue());

      // insert matching
      insertMatching().setGlobalValue(newUiPrefs.insertMatching().getGlobalValue());

      // soft wrap R files
      softWrapRFiles().setGlobalValue(newUiPrefs.softWrapRFiles().getGlobalValue());

      // syntax color console
      syntaxColorConsole().setGlobalValue(newUiPrefs.syntaxColorConsole().getGlobalValue());

      // save all before build
      saveAllBeforeBuild().setGlobalValue(newUiPrefs.saveAllBeforeBuild().getGlobalValue());

      // font size
      fontSize().setGlobalValue(newUiPrefs.fontSize().getGlobalValue());

      // theme
      theme().setGlobalValue(newUiPrefs.theme().getGlobalValue());

      // default encoding
      defaultEncoding().setGlobalValue(newUiPrefs.defaultEncoding().getGlobalValue());

      // default project location
      defaultProjectLocation().setGlobalValue(newUiPrefs.defaultProjectLocation().getGlobalValue());

      // toolbar visible
      toolbarVisible().setGlobalValue(newUiPrefs.toolbarVisible().getGlobalValue());

      // source with echo
      sourceWithEcho().setGlobalValue(newUiPrefs.sourceWithEcho().getGlobalValue());

      // export plot options
      if (!ExportPlotOptions.areEqual(
          newUiPrefs.exportPlotOptions().getGlobalValue(), exportPlotOptions().getGlobalValue())) {
        exportPlotOptions().setGlobalValue(newUiPrefs.exportPlotOptions().getGlobalValue());
      }

      // save plot as pdf options
      if (!SavePlotAsPdfOptions.areEqual(
          newUiPrefs.savePlotAsPdfOptions().getGlobalValue(),
          savePlotAsPdfOptions().getGlobalValue())) {
        savePlotAsPdfOptions().setGlobalValue(newUiPrefs.savePlotAsPdfOptions().getGlobalValue());
      }

      // compile notebook options
      if (!CompileNotebookPrefs.areEqual(
          newUiPrefs.compileNotebookOptions().getGlobalValue(),
          compileNotebookOptions().getGlobalValue())) {
        compileNotebookOptions()
            .setGlobalValue(newUiPrefs.compileNotebookOptions().getGlobalValue());
      }

      // default sweave engine
      defaultSweaveEngine().setGlobalValue(newUiPrefs.defaultSweaveEngine().getGlobalValue());

      // default latex program
      defaultLatexProgram().setGlobalValue(newUiPrefs.defaultLatexProgram().getGlobalValue());

      // root document
      rootDocument().setGlobalValue(newUiPrefs.rootDocument().getGlobalValue());

      // use roxygen
      useRoxygen().setGlobalValue(newUiPrefs.useRoxygen().getGlobalValue());

      // pdf preview
      pdfPreview().setGlobalValue(newUiPrefs.pdfPreview().getGlobalValue());

      // always enable rnw concordance
      alwaysEnableRnwConcordance()
          .setGlobalValue(newUiPrefs.alwaysEnableRnwConcordance().getGlobalValue());

      // insert numbered latex sections
      insertNumberedLatexSections()
          .setGlobalValue(newUiPrefs.insertNumberedLatexSections().getGlobalValue());

      // spelling dictionary language
      spellingDictionaryLanguage()
          .setGlobalValue(newUiPrefs.spellingDictionaryLanguage().getGlobalValue());

      // spelling custom dictionaries
      if (!JsUtil.areEqual(
          spellingCustomDictionaries().getGlobalValue(),
          newUiPrefs.spellingCustomDictionaries().getGlobalValue())) {
        spellingCustomDictionaries()
            .setGlobalValue(newUiPrefs.spellingCustomDictionaries().getGlobalValue());
      }

      // ignore words in uppercase
      ignoreWordsInUppercase().setGlobalValue(newUiPrefs.ignoreWordsInUppercase().getGlobalValue());

      // ignore words with numbers
      ignoreWordsWithNumbers().setGlobalValue(newUiPrefs.ignoreWordsWithNumbers().getGlobalValue());

      // navigate to build error
      navigateToBuildError().setGlobalValue(newUiPrefs.navigateToBuildError().getGlobalValue());
    } else if (e.getType().equals(UiPrefsChangedEvent.PROJECT_TYPE)) {
      // get prefs accessor
      UIPrefsAccessor newUiPrefs = new UIPrefsAccessor(JsObject.createJsObject(), e.getUIPrefs());

      // use spaces for tab
      useSpacesForTab().setProjectValue(newUiPrefs.useSpacesForTab().getValue());

      // num spaces for tab
      numSpacesForTab().setProjectValue(newUiPrefs.numSpacesForTab().getValue());

      // default encoding
      defaultEncoding().setProjectValue(newUiPrefs.defaultEncoding().getValue());

      // default sweave engine
      defaultSweaveEngine().setProjectValue(newUiPrefs.defaultSweaveEngine().getValue());

      // default latex program
      defaultLatexProgram().setProjectValue(newUiPrefs.defaultLatexProgram().getValue());

      // root document
      rootDocument().setProjectValue(newUiPrefs.rootDocument().getValue());

      // use roxygen
      useRoxygen().setProjectValue(newUiPrefs.useRoxygen().getValue());
    } else {
      Debug.log("Unexpected uiPrefs type: " + e.getType());
    }
  }
Exemplo n.º 6
0
 public static void dump(JavaScriptObject object) {
   Debug.log(new JSONObject(object).toString());
 }
Exemplo n.º 7
0
 public static <T> T devlog(String label, T passthrough) {
   Debug.devlog(label);
   return passthrough;
 }
Exemplo n.º 8
0
 public static void logError(ServerError error) {
   Debug.log(error.toString());
 }
Exemplo n.º 9
0
 public static <T> T printValue(String label, T value) {
   Debug.log(label + '=' + value);
   return value;
 }