Exemplo n.º 1
0
 @Override
 protected final Boolean doGet(JsObject group, String name) {
   return group.getBoolean(name);
 }
Exemplo n.º 2
0
 private void applyProperties(JsObject properties, HashMap<String, String> newProperties) {
   for (Map.Entry<String, String> entry : newProperties.entrySet()) {
     if (entry.getValue() == null) properties.unset(entry.getKey());
     else properties.setString(entry.getKey(), entry.getValue());
   }
 }
Exemplo n.º 3
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.º 4
0
 public String getProperty(String propertyName) {
   JsObject properties = sourceDoc_.getProperties();
   return properties.getString(propertyName);
 }