コード例 #1
0
ファイル: WriteXMPAction.java プロジェクト: GeorgLink/Desktop
  public void update() {
    if (!goOn) return;

    panel.output(
        Globals.lang(
            "Finished writing XMP for %0 file (%1 skipped, %2 errors).",
            String.valueOf(entriesChanged), String.valueOf(skipped), String.valueOf(errors)));
  }
コード例 #2
0
ファイル: WriteXMPAction.java プロジェクト: GeorgLink/Desktop
  public void init() {

    // Get entries and check if it makes sense to perform this operation
    entries = panel.getSelectedEntries();

    if (entries.length == 0) {

      database = panel.getDatabase();
      entries = database.getEntries().toArray(new BibtexEntry[] {});

      if (entries.length == 0) {

        JOptionPane.showMessageDialog(
            panel,
            Globals.lang("This operation requires at least one entry."),
            Globals.lang("Write XMP-metadata"),
            JOptionPane.ERROR_MESSAGE);
        goOn = false;
        return;

      } else {

        int response =
            JOptionPane.showConfirmDialog(
                panel,
                Globals.lang("Write XMP-metadata for all PDFs in current database?"),
                Globals.lang("Write XMP-metadata"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if (response != JOptionPane.YES_OPTION) {
          goOn = false;
          return;
        }
      }
    }

    errors = entriesChanged = skipped = 0;

    if (optDiag == null) {
      optDiag = new OptionsDialog(panel.frame().getFrame());
    }
    optDiag.open();

    panel.output(Globals.lang("Writing XMP metadata..."));
  }
コード例 #3
0
ファイル: PdfImporter.java プロジェクト: kifetew/SWAT
  private BibtexEntry createNewEntry() {

    // Find out what type is wanted.
    EntryTypeDialog etd = new EntryTypeDialog(frame);
    // We want to center the dialog, to make it look nicer.
    Util.placeDialog(etd, frame);
    etd.setVisible(true);
    BibtexEntryType type = etd.getChoice();

    if (type != null) { // Only if the dialog was not cancelled.
      String id = Util.createNeutralId();
      final BibtexEntry be = new BibtexEntry(id, type);
      try {
        panel.database().insertEntry(be);

        // Set owner/timestamp if options are enabled:
        ArrayList<BibtexEntry> list = new ArrayList<BibtexEntry>();
        list.add(be);
        Util.setAutomaticFields(list, true, true, false);

        // Create an UndoableInsertEntry object.
        panel.undoManager.addEdit(new UndoableInsertEntry(panel.database(), be, panel));
        panel.output(
            Globals.lang("Added new")
                + " '"
                + type.getName().toLowerCase()
                + "' "
                + Globals.lang("entry")
                + ".");

        // We are going to select the new entry. Before that, make sure that we are in
        // show-entry mode. If we aren't already in that mode, enter the WILL_SHOW_EDITOR
        // mode which makes sure the selection will trigger display of the entry editor
        // and adjustment of the splitter.
        if (panel.getMode() != panel.SHOWING_EDITOR) {
          panel.setMode(panel.WILL_SHOW_EDITOR);
        }

        /*int row = entryTable.findEntry(be);
        if (row >= 0)
            // Selects the entry. The selection listener will open the editor.
             if (row >= 0) {
                try{
                    entryTable.setRowSelectionInterval(row, row);
                }catch(IllegalArgumentException e){
                    System.out.println("RowCount: " + entryTable.getRowCount());
                }

                //entryTable.setActiveRow(row);
                entryTable.ensureVisible(row);
             }
        else {
            // The entry is not visible in the table, perhaps due to a filtering search
            // or group selection. Show the entry editor anyway:
            panel.showEntry(be);
        }   */
        panel.showEntry(be);
        panel.markBaseChanged(); // The database just changed.
        new FocusRequester(panel.getEntryEditor(be));
        return be;
      } catch (KeyCollisionException ex) {
        Util.pr(ex.getMessage());
      }
    }
    return null;
  }
コード例 #4
0
 public void update() {
   // pdfURL = new URL("http://geog-www.sbs.ohio-state.edu/faculty/bmark/abbott_etal_ppp03.pdf");
   if (result.url != null) {
     // System.out.println("PDF URL: "+result.url);
     String bibtexKey = entry.getCiteKey();
     String fileDir = basePanel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
     if (fileDir == null) {
       // TODO: error message if file dir not defined
       // JOptionPane.showMessageDialog(frame, Globals.lang);
       return;
     }
     DownloadExternalFile def =
         new DownloadExternalFile(basePanel.frame(), basePanel.metaData(), bibtexKey);
     try {
       def.download(
           result.url,
           new DownloadExternalFile.DownloadCallback() {
             public void downloadComplete(FileListEntry file) {
               System.out.println("finished");
               FileListTableModel tm = new FileListTableModel();
               String oldValue = entry.getField(GUIGlobals.FILE_FIELD);
               tm.setContent(oldValue);
               tm.addEntry(tm.getRowCount(), file);
               String newValue = tm.getStringRepresentation();
               UndoableFieldChange edit =
                   new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue);
               entry.setField(GUIGlobals.FILE_FIELD, newValue);
               basePanel.undoManager.addEdit(edit);
               basePanel.markBaseChanged();
             }
           });
     } catch (IOException e) {
       e.printStackTrace();
     }
     basePanel.output(Globals.lang("Finished downloading full text document"));
   } else {
     String message = null;
     switch (result.status) {
       case FindFullText.UNKNOWN_DOMAIN:
         message =
             Globals.lang(
                 "Unable to find full text article. No search algorithm "
                     + "defined for the '%0' web site.",
                 result.host);
         break;
       case FindFullText.WRONG_MIME_TYPE:
         message =
             Globals.lang(
                 "Found pdf link, but received the wrong MIME type. "
                     + "This could indicate that you don't have access to the fulltext article.");
         break;
       case FindFullText.LINK_NOT_FOUND:
         message = Globals.lang("Unable to find full text document in the linked web page.");
         break;
       case FindFullText.IO_EXCEPTION:
         message = Globals.lang("Connection error when trying to find full text document.");
         break;
       case FindFullText.NO_URLS_DEFINED:
         message = Globals.lang("This entry provides no URL or DOI links.");
         break;
     }
     basePanel.output(Globals.lang("Full text article download failed"));
     JOptionPane.showMessageDialog(
         basePanel.frame(),
         message,
         Globals.lang("Full text article download failed"),
         JOptionPane.ERROR_MESSAGE);
   }
 }
コード例 #5
0
 public void init() throws Throwable {
   basePanel.output(Globals.lang("Looking for full text document..."));
 }