コード例 #1
0
 void previewB_actionPerformed(ActionEvent e) {
   File f;
   try {
     f = Util.getTempFile();
     new HTMLFileExport(f, editor.document, CurrentNote.get(), "UTF-8", false, null, false);
     Util.runBrowser("file:" + f.getAbsolutePath());
   } catch (IOException ioe) {
     new ExceptionDialog(ioe, "Cannot create temporary file", null);
   }
 }
コード例 #2
0
 /** Test method for {@link net.sf.memoranda.util.PDFFileExport#createPdf()}. */
 @Test(expected = com.itextpdf.text.ExceptionConverter.class)
 public final void testCreatePdf() throws IOException, DocumentException {
   IPdfHandler testCreatePDF =
       new PDFFileExport(f, testDoc, CurrentNote.get(), enc, false, template, true);
   testCreatePDF.createPdf(f.getAbsolutePath(), XHTML);
 }
コード例 #3
0
 /** Test method for {@link net.sf.memoranda.util.PDFFileExport#XHTMLToPDF()}. */
 @Test(expected = com.itextpdf.text.ExceptionConverter.class)
 public final void testXHTMLToPDF() throws IOException, DocumentException {
   IPdfHandler testXHTMLToPDF =
       new PDFFileExport(f, testDoc, CurrentNote.get(), enc, false, template, true);
   testXHTMLToPDF.xhtmlToPdf(XHTML);
 }
コード例 #4
0
 // Dead Store bug is a false positive, testPDFExport is the test object being created
 @SuppressWarnings("unused")
 @Test
 public final void testPDFFileExport() {
   IPdfHandler testPDFExport =
       new PDFFileExport(f, testDoc, CurrentNote.get(), enc, false, template, true);
 }
コード例 #5
0
 void btn_New_Note_actionPerformed(ActionEvent e) {
   CurrentNote.set(null, true);
   setDocument(null);
   this.titleField.requestFocus();
 }
コード例 #6
0
  void exportB_actionPerformed(ActionEvent e) {
    // Fix until Sun's JVM supports more locales...
    UIManager.put("FileChooser.lookInLabelText", Local.getString("Save in:"));
    UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
    UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
    UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
    UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
    UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
    UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
    UIManager.put("FileChooser.saveButtonText", Local.getString("Save"));
    UIManager.put("FileChooser.saveButtonToolTipText", Local.getString("Save selected file"));
    UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
    UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));

    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Export note"));
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.XHTML));
    chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.HTML));
    // chooser.addChoosableFileFilter(new
    // AllFilesFilter(AllFilesFilter.RTF));
    String lastSel = (String) Context.get("LAST_SELECTED_EXPORT_FILE");
    if (lastSel != null) chooser.setCurrentDirectory(new File(lastSel));

    FileExportDialog dlg =
        new FileExportDialog(App.getFrame(), Local.getString("Export note"), chooser);
    String enc = (String) Context.get("EXPORT_FILE_ENCODING");
    if (enc != null) dlg.encCB.setSelectedItem(enc);
    String templ = (String) Context.get("EXPORT_TEMPLATE");
    if (templ != null) dlg.templF.setText(templ);
    String xhtml = (String) Context.get("EXPORT_XHTML");
    if ((xhtml != null) && (xhtml.equalsIgnoreCase("YES"))) dlg.xhtmlChB.setSelected(true);
    String num = (String) Context.get("EXPORT_NUMENT");
    if ((num != null) && (num.equalsIgnoreCase("YES"))) dlg.numentChB.setSelected(true);
    Dimension dlgSize = new Dimension(550, 475);
    dlg.setSize(dlgSize);
    Dimension frmSize = App.getFrame().getSize();
    Point loc = App.getFrame().getLocation();
    dlg.setLocation(
        (frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setVisible(true);
    if (dlg.CANCELLED) return;

    Context.put("LAST_SELECTED_EXPORT_FILE", chooser.getSelectedFile().getPath());
    Context.put("EXPORT_FILE_ENCODING", dlg.encCB.getSelectedItem());
    Context.put("EXPORT_NUMENT", dlg.numentChB.isSelected() ? "YES" : "NO");
    Context.put("EXPORT_XHTML", dlg.xhtmlChB.isSelected() ? "YES" : "NO");
    String template = null;
    if (dlg.usetemplChB.isSelected() && dlg.templF.getText().length() > 0) {
      template = dlg.templF.getText();
      Context.put("EXPORT_TEMPLATE", template);
    }
    /*
     * if (chooser.getFileFilter().getDescription().equals("Rich Text
     * Format")) new RTFFileExport(chooser.getSelectedFile(),
     * editor.document); else
     */
    int ei = dlg.encCB.getSelectedIndex();
    enc = null;
    if (ei == 1) enc = "UTF-8";
    File f = chooser.getSelectedFile();
    new HTMLFileExport(
        f,
        editor.document,
        CurrentNote.get(),
        enc,
        dlg.numentChB.isSelected(),
        template,
        dlg.xhtmlChB.isSelected());
  }