private void renderNotebookv2WithDialog(final DocUpdateSentinel sourceDoc) {
    // default format
    String format = sourceDoc.getProperty(NOTEBOOK_FORMAT);
    if (StringUtil.isNullOrEmpty(format)) {
      format = prefs_.compileNotebookv2Options().getValue().getFormat();
      if (StringUtil.isNullOrEmpty(format)) format = CompileNotebookv2Options.FORMAT_DEFAULT;
    }

    CompileNotebookv2OptionsDialog dialog =
        new CompileNotebookv2OptionsDialog(
            format,
            new OperationWithInput<CompileNotebookv2Options>() {
              @Override
              public void execute(CompileNotebookv2Options input) {
                renderNotebookv2(sourceDoc, input.getFormat());

                // save options for this document
                HashMap<String, String> changedProperties = new HashMap<String, String>();
                changedProperties.put(NOTEBOOK_FORMAT, input.getFormat());
                sourceDoc.modifyProperties(changedProperties, null);

                // save global prefs
                CompileNotebookv2Prefs prefs = CompileNotebookv2Prefs.create(input.getFormat());
                if (!CompileNotebookv2Prefs.areEqual(
                    prefs, prefs_.compileNotebookv2Options().getValue())) {
                  prefs_.compileNotebookv2Options().setGlobalValue(prefs);
                  prefs_.writeUIPrefs();
                }
              }
            });
    dialog.showModal();
  }
 private void renderNotebookv2(final DocUpdateSentinel sourceDoc, String format) {
   eventBus_.fireEvent(
       new RenderRmdEvent(
           sourceDoc.getPath(), 1, format, sourceDoc.getEncoding(), null, false, false));
 }