コード例 #1
0
ファイル: CleanupAction.java プロジェクト: GeorgLink/jabref
 @Override
 public void update() {
   if (cancelled) {
     frame.unblock();
     return;
   }
   if (unsuccessfulRenames > 0) { // Rename failed for at least one entry
     JOptionPane.showMessageDialog(
         frame,
         Localization.lang(
             "File rename failed for %0 entries.", Integer.toString(unsuccessfulRenames)),
         Localization.lang("Autogenerate PDF Names"),
         JOptionPane.INFORMATION_MESSAGE);
   }
   if (modifiedEntriesCount > 0) {
     panel.updateEntryEditorIfShowing();
     panel.markBaseChanged();
   }
   String message;
   switch (modifiedEntriesCount) {
     case 0:
       message = Localization.lang("No entry needed a clean up");
       break;
     case 1:
       message = Localization.lang("One entry needed a clean up");
       break;
     default:
       message =
           Localization.lang(
               "%0 entries needed a clean up", Integer.toString(modifiedEntriesCount));
       break;
   }
   panel.output(message);
   frame.unblock();
 }
コード例 #2
0
ファイル: BibtexParser.java プロジェクト: boceckts/jabref
  private void parseAndAddEntry(String type) {
    /**
     * Morten Alver 13 Aug 2006: Trying to make the parser more robust. If an exception is thrown
     * when parsing an entry, drop the entry and try to resume parsing. Add a warning for the user.
     */
    try {
      BibEntry entry = parseEntry(type);

      boolean duplicateKey = database.insertEntry(entry);
      entry.setParsedSerialization(dumpTextReadSoFarToString());
      if (duplicateKey) {
        parserResult.addDuplicateKey(entry.getCiteKey());
      } else if ((entry.getCiteKey() == null) || entry.getCiteKey().isEmpty()) {
        parserResult.addWarning(
            Localization.lang("Empty BibTeX key")
                + ": "
                + entry.getAuthorTitleYear(40)
                + " ("
                + Localization.lang("Grouping may not work for this entry.")
                + ")");
      }
    } catch (IOException ex) {
      LOGGER.warn("Could not parse entry", ex);
      parserResult.addWarning(
          Localization.lang("Error occurred when parsing entry")
              + ": '"
              + ex.getMessage()
              + "'. "
              + Localization.lang("Skipped entry."));
    }
  }
コード例 #3
0
  /**
   * Generates a Citation based on the given entry, style, and output format WARNING: the citation
   * is generated with JavaScript which may take some time, better call it in outside the main
   * Thread
   */
  protected static String generateCitation(
      BibEntry entry, String style, CitationStyleOutputFormat outputFormat) {
    try {
      String citeKey = entry.getCiteKeyOptional().orElse("");
      BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(entry.getType()), new Key(citeKey));
      for (Map.Entry<String, String> field : entry.getFieldMap().entrySet()) {
        String value = UNICODE_TO_LATEX_FORMATTER.format(field.getValue());
        bibTeXEntry.addField(new Key(field.getKey()), new DigitStringValue(value));
      }

      CSLItemData cslItemData = BIBTEX_CONVERTER.toItemData(bibTeXEntry);
      Bibliography bibliography =
          CSL.makeAdhocBibliography(style, outputFormat.getFormat(), cslItemData);
      return bibliography.getEntries()[0];

    } catch (IOException | ArrayIndexOutOfBoundsException e) {
      LOGGER.error("Could not generate BibEntry citation", e);
      return Localization.lang("Cannot generate preview based on selected citation style.");
    } catch (TokenMgrException e) {
      LOGGER.error("Bad character inside BibEntry", e);
      // sadly one cannot easily retrieve the bad char from the TokenMgrError
      return new StringBuilder()
          .append(Localization.lang("Cannot generate preview based on selected citation style."))
          .append(outputFormat == CitationStyleOutputFormat.HTML ? "<br>" : "\n")
          .append(Localization.lang("Bad character inside entry"))
          .append(outputFormat == CitationStyleOutputFormat.HTML ? "<br>" : "\n")
          .append(e.getLocalizedMessage())
          .toString();
    }
  }
コード例 #4
0
ファイル: CleanUpAction.java プロジェクト: jkulesza/jabref
  private int showCleanUpDialog() {
    String dialogTitle = Localization.lang("Cleanup entries");

    Object[] messages = {Localization.lang("What would you like to clean up?"), optionsPanel};
    return JOptionPane.showConfirmDialog(
        frame, messages, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
  }
コード例 #5
0
 @Override
 public void actionPerformed(ActionEvent e) {
   String chosen;
   chosen = JOptionPane.showInputDialog(Localization.lang("Choose the URL to download."), "");
   if (chosen == null) {
     return;
   }
   File toFile;
   try {
     String toName =
         FileDialogs.getNewFile(
             frame,
             new File(System.getProperty("user.home")),
             null,
             JFileChooser.SAVE_DIALOG,
             false);
     if (toName == null) {
       return;
     } else {
       toFile = new File(toName);
     }
     URL url = new URL(chosen);
     MonitoredURLDownload.buildMonitoredDownload(comp, url).downloadToFile(toFile);
     comp.setText(toFile.getPath());
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         null,
         Localization.lang("Error downloading file '%0'", chosen),
         Localization.lang("Download failed"),
         JOptionPane.ERROR_MESSAGE);
   }
 }
コード例 #6
0
 private boolean readyToClose() {
   File f;
   if (newFile.isSelected()) {
     if (newNameTf.getText().isEmpty()) {
       if (tableModel.getRowCount() > 0) {
         JOptionPane.showMessageDialog(
             this,
             Localization.lang("You must choose a filename to store journal abbreviations"),
             Localization.lang("Store journal abbreviations"),
             JOptionPane.ERROR_MESSAGE);
         return false;
       } else {
         return true;
       }
     } else {
       f = new File(newNameTf.getText());
       return !f.exists()
           || (JOptionPane.showConfirmDialog(
                   this,
                   Localization.lang("'%0' exists. Overwrite file?", f.getName()),
                   Localization.lang("Store journal abbreviations"),
                   JOptionPane.OK_CANCEL_OPTION)
               == JOptionPane.OK_OPTION);
     }
   }
   return true;
 }
コード例 #7
0
ファイル: MetaDataChange.java プロジェクト: Siedlerchr/jabref
  public MetaDataChange(MetaData originalMetaData, MetaData newMetaData) {
    super(Localization.lang("Metadata change"));
    this.originalMetaData = originalMetaData;
    this.newMetaData = newMetaData;

    infoPane.setText("<html>" + Localization.lang("Metadata change") + "</html>");
  }
コード例 #8
0
ファイル: INSPIREFetcher.java プロジェクト: valhallasw/jabref
  /**
   * Import an entry from an OAI2 archive. The BibtexEntry provided has to have the field
   * OAI2_IDENTIFIER_FIELD set to the search string.
   *
   * @param key The OAI2 key to fetch from ArXiv.
   * @return The imnported BibtexEntry or null if none.
   */
  private BibtexDatabase importInspireEntries(String key, OutputPrinter frame) {
    String url = constructUrl(key);
    try {
      HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
      conn.setRequestProperty("User-Agent", "Jabref");
      InputStream inputStream = conn.getInputStream();

      INSPIREBibtexFilterReader reader =
          new INSPIREBibtexFilterReader(new InputStreamReader(inputStream));

      ParserResult pr = BibtexParser.parse(reader);

      return pr.getDatabase();
    } catch (IOException e) {
      frame.showMessage(
          Localization.lang("An Exception ocurred while accessing '%0'", url) + "\n\n" + e,
          Localization.lang(getKeyName()),
          JOptionPane.ERROR_MESSAGE);
    } catch (RuntimeException e) {
      frame.showMessage(
          Localization.lang(
                  "An Error occurred while fetching from INSPIRE source (%0):", new String[] {url})
              + "\n\n"
              + e.getMessage(),
          Localization.lang(getKeyName()),
          JOptionPane.ERROR_MESSAGE);
    }
    return null;
  }
コード例 #9
0
ファイル: PreviewPanel.java プロジェクト: chochreiner/jabref
    public PrintAction() {
      super(Localization.lang("Print entry preview"), IconTheme.JabRefIcon.PRINTED.getIcon());

      putValue(Action.SHORT_DESCRIPTION, Localization.lang("Print entry preview"));
      putValue(
          Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.PRINT_ENTRY_PREVIEW));
    }
コード例 #10
0
ファイル: AddToGroupAction.java プロジェクト: motokito/jabref
 public AddToGroupAction(boolean move) {
   super(
       move
           ? Localization.lang("Assign entry selection exclusively to this group")
           : Localization.lang("Add entry selection to this group"));
   this.move = move;
 }
コード例 #11
0
 /** Creates a new instance of SaveAllAction */
 public SaveAllAction(JabRefFrame frame) {
   super(IconTheme.getImage("saveAll"));
   this.frame = frame;
   putValue(Action.ACCELERATOR_KEY, Globals.prefs.getKey("Save all"));
   putValue(Action.SHORT_DESCRIPTION, Localization.lang("Save all open databases"));
   putValue(Action.NAME, Localization.menuTitle("Save all"));
 }
コード例 #12
0
ファイル: PushToEmacs.java プロジェクト: Rabbisaur/jabref
 @Override
 public void operationCompleted(BasePanel panel) {
   if (couldNotConnect) {
     JOptionPane.showMessageDialog(
         panel.frame(),
         "<HTML>"
             + Localization.lang(
                 "Could not connect to a running gnuserv process. Make sure that "
                     + "Emacs or XEmacs is running,<BR>and that the server has been started "
                     + "(by running the command 'server-start'/'gnuserv-start').")
             + "</HTML>",
         Localization.lang("Error"),
         JOptionPane.ERROR_MESSAGE);
   } else if (couldNotCall) {
     JOptionPane.showMessageDialog(
         panel.frame(),
         Localization.lang(
             "Could not run the gnuclient/emacsclient program. Make sure you have "
                 + "the emacsclient/gnuclient program installed and available in the PATH."),
         Localization.lang("Error"),
         JOptionPane.ERROR_MESSAGE);
   } else {
     super.operationCompleted(panel);
   }
 }
コード例 #13
0
 @Override
 public void action() {
   try {
     NamedCompound ce = new NamedCompound(undoText);
     BibtexEntry[] bes = frame.basePanel().getSelectedEntries();
     if (bes == null) {
       return;
     }
     for (BibtexEntry be : bes) {
       // if (value==null) and then call nullField has been ommited as updatefield also handles
       // value==null
       SpecialFieldsUtils.updateField(c, value, be, ce, nullFieldIfValueIsTheSame);
     }
     ce.end();
     if (ce.hasEdits()) {
       frame.basePanel().undoManager.addEdit(ce);
       frame.basePanel().markBaseChanged();
       frame.basePanel().updateEntryEditorIfShowing();
       String outText;
       if (nullFieldIfValueIsTheSame) {
         outText = Localization.lang(doneTextPattern, Integer.toString(bes.length));
       } else {
         outText = Localization.lang(doneTextPattern, value, Integer.toString(bes.length));
       }
       frame.output(outText);
     } else {
       // if user does not change anything with his action, we do not do anything either
       // even no output message
     }
   } catch (Throwable ex) {
     ex.printStackTrace();
   }
 }
コード例 #14
0
  public MetaDataChange(MetaData md, MetaData mdSecondary) {
    super(Localization.lang("Metadata change"));
    this.md = md;
    this.mdSecondary = mdSecondary;

    tp.setText("<html>" + Localization.lang("Metadata change") + "</html>");
  }
コード例 #15
0
 @Override
 public String getPresentationName() {
   return Localization.lang(
       "change field %0 of entry %1 from %2 to %3",
       StringUtil.boldHTML(field),
       StringUtil.boldHTML(entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))),
       StringUtil.boldHTML(oldValue, Localization.lang("undefined")),
       StringUtil.boldHTML(newValue, Localization.lang("undefined")));
 }
コード例 #16
0
  public boolean openLink() {
    frame.output(Localization.lang("External viewer called") + ".");
    try {
      ExternalFileType type = fileType;
      if (this.fileType == null) {
        if (this.fieldName == null) {
          // We don't already know the file type, so we try to deduce it from the extension:
          File file = new File(link);
          // We try to check the extension for the file:
          String name = file.getName();
          int pos = name.indexOf('.');
          String extension =
              (pos >= 0) && (pos < (name.length() - 1))
                  ? name.substring(pos + 1).trim().toLowerCase()
                  : null;
          // Now we know the extension, check if it is one we know about:
          type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(extension);
          fileType = type;
        } else {
          JabRefDesktop.openExternalViewer(
              frame.getCurrentBasePanel().getBibDatabaseContext().getMetaData(), link, fieldName);
          return true;
        }
      }

      if (type instanceof UnknownExternalFileType) {
        return JabRefDesktop.openExternalFileUnknown(
            frame, entry, metaData, link, (UnknownExternalFileType) type);
      } else {
        return JabRefDesktop.openExternalFileAnyFormat(metaData, link, type);
      }

    } catch (IOException e1) {
      // See if we should show an error message concerning the application to open the
      // link with. We check if the file type is set, and if the file type has a non-empty
      // application link. If that link is referred by the error message, we can assume
      // that the problem is in the open-with-application setting:
      if ((fileType != null)
          && (fileType.getOpenWith() != null)
          && !fileType.getOpenWith().isEmpty()
          && e1.getMessage().contains(fileType.getOpenWith())) {

        JOptionPane.showMessageDialog(
            frame,
            Localization.lang(
                "Unable to open link. "
                    + "The application '%0' associated with the file type '%1' could not be called.",
                fileType.getOpenWith(), fileType.getName()),
            Localization.lang("Could not open link"),
            JOptionPane.ERROR_MESSAGE);
        return false;
      }

      LOGGER.warn("Unable to open link", e1);
    }
    return false;
  }
コード例 #17
0
 @Override
 public void actionPerformed(ActionEvent e) {
   databases = frame.getTabbedPane().getTabCount();
   saved = 0;
   frame.output(Localization.lang("Saving all databases..."));
   Spin.off(this);
   run();
   frame.output(Localization.lang("Save all finished."));
 }
コード例 #18
0
ファイル: PushToEmacs.java プロジェクト: Rabbisaur/jabref
 @Override
 protected void initSettingsPanel() {
   super.initSettingsPanel();
   builder.appendRows("2dlu, p, 2dlu, p");
   builder.add(Localization.lang("Additional parameters") + ":").xy(1, 3);
   builder.add(additionalParams).xy(3, 3);
   builder.add(Localization.lang("Use EMACS 23 insertion string") + ":").xy(1, 5);
   builder.add(useEmacs23).xy(3, 5);
   settings = builder.build();
 }
コード例 #19
0
 public WriteXMPEntryEditorAction(BasePanel panel, EntryEditor editor) {
   this.panel = panel;
   this.editor = editor;
   // normally, the next call should be without "Localization.lang". However, the string "Write
   // XMP" is also used in non-menu places and therefore, the translation must be also available at
   // Localization.lang
   putValue(Action.NAME, Localization.lang("Write XMP"));
   putValue(Action.SMALL_ICON, IconTheme.JabRefIcon.WRITE_XMP.getIcon());
   putValue(
       Action.SHORT_DESCRIPTION, Localization.lang("Write BibTeXEntry as XMP-metadata to PDF."));
 }
コード例 #20
0
ファイル: FileSortTab.java プロジェクト: ayanai1/jabref
  public FileSortTab(JabRefPreferences prefs) {
    this.prefs = prefs;
    FormLayout layout = new FormLayout("4dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.leadingColumnOffset(1);

    // EXPORT SORT ORDER
    // create Components
    exportInOriginalOrder =
        new JRadioButton(Localization.lang("Export entries in their original order"));
    exportInTableOrder = new JRadioButton(Localization.lang("Export in current table sort order"));
    exportInSpecifiedOrder =
        new JRadioButton(Localization.lang("Export entries ordered as specified"));

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(exportInOriginalOrder);
    buttonGroup.add(exportInTableOrder);
    buttonGroup.add(exportInSpecifiedOrder);

    ActionListener listener =
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            boolean selected = e.getSource() == exportInSpecifiedOrder;
            exportOrderPanel.setEnabled(selected);
          }
        };
    exportInOriginalOrder.addActionListener(listener);
    exportInTableOrder.addActionListener(listener);
    exportInSpecifiedOrder.addActionListener(listener);

    // create GUI
    builder.appendSeparator(Localization.lang("Export sort order"));
    builder.append(exportInOriginalOrder, 1);
    builder.nextLine();
    builder.append(exportInTableOrder, 1);
    builder.nextLine();
    builder.append(exportInSpecifiedOrder, 1);
    builder.nextLine();

    exportOrderPanel = new SaveOrderConfigDisplay();
    builder.append(exportOrderPanel.getPanel());
    builder.nextLine();

    // COMBINE EVERYTHING
    JPanel pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new BorderLayout());
    add(pan, BorderLayout.CENTER);
  }
コード例 #21
0
ファイル: PdfImporter.java プロジェクト: Siedlerchr/jabref
  private Optional<BibEntry> createNewEntry() {
    // Find out what type is desired
    EntryTypeDialog etd = new EntryTypeDialog(frame);
    // We want to center the dialog, to make it look nicer.
    etd.setLocationRelativeTo(frame);
    etd.setVisible(true);
    EntryType type = etd.getChoice();

    if (type != null) { // Only if the dialog was not canceled.
      String id = IdGenerator.next();
      final BibEntry bibEntry = new BibEntry(id, type.getName());
      try {
        panel.getDatabase().insertEntry(bibEntry);

        // Set owner/timestamp if options are enabled:
        List<BibEntry> list = new ArrayList<>();
        list.add(bibEntry);
        UpdateField.setAutomaticFields(list, true, true, Globals.prefs.getUpdateFieldPreferences());

        // Create an UndoableInsertEntry object.
        panel
            .getUndoManager()
            .addEdit(new UndoableInsertEntry(panel.getDatabase(), bibEntry, panel));
        panel.output(
            Localization.lang("Added new")
                + " '"
                + type.getName().toLowerCase()
                + "' "
                + Localization.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() != BasePanelMode.SHOWING_EDITOR) {
          panel.setMode(BasePanelMode.WILL_SHOW_EDITOR);
        }

        SwingUtilities.invokeLater(() -> panel.showEntry(bibEntry));

        // The database just changed.
        panel.markBaseChanged();

        return Optional.of(bibEntry);
      } catch (KeyCollisionException ex) {
        LOGGER.info("Key collision occurred", ex);
      }
    }
    return Optional.empty();
  }
コード例 #22
0
ファイル: Printed.java プロジェクト: fanofprogram/myjabref3.2
 private Printed() {
   ArrayList<SpecialFieldValue> values = new ArrayList<>();
   // DO NOT TRANSLATE "printed" as this makes the produced .bib files non portable
   values.add(
       new SpecialFieldValue(
           this,
           "printed",
           "togglePrinted",
           Localization.lang("Toggle print status"),
           IconTheme.JabRefIcon.PRINTED.getSmallIcon(),
           Localization.lang("Toggle print status")));
   this.setValues(values);
   TEXT_DONE_PATTERN = "Toggled print status for %0 entries";
 }
コード例 #23
0
 @Override
 public void actionPerformed(ActionEvent e) {
   try {
     JabRefDesktop.openBrowser("https://github.com/JabRef/jabref");
   } catch (IOException ex) {
     ex.printStackTrace();
     JabRef.jrf
         .basePanel()
         .output(
             Localization.lang("Could not open browser.")
                 + " "
                 + Localization.lang("Please open http://github.com/JabRef/jabref manually."));
   }
 }
コード例 #24
0
  /**
   * Set up a mouse listener for opening an external viewer for with with EXTRA_EXTERNAL
   *
   * @param fieldEditor
   * @param panel
   * @return
   */
  public static Optional<JComponent> getExternalExtraComponent(
      BasePanel panel, FieldEditor fieldEditor) {
    JPanel controls = new JPanel();
    controls.setLayout(new BorderLayout());
    JButton button = new JButton(Localization.lang("Open"));
    button.setEnabled(false);
    button.addActionListener(
        actionEvent -> {
          try {
            JabRefDesktop.openExternalViewer(
                panel.getBibDatabaseContext(), fieldEditor.getText(), fieldEditor.getFieldName());
          } catch (IOException ex) {
            panel.output(Localization.lang("Unable to open link."));
          }
        });

    controls.add(button, BorderLayout.SOUTH);

    // enable/disable button
    JTextComponent url = (JTextComponent) fieldEditor;

    url.getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void changedUpdate(DocumentEvent documentEvent) {
                checkUrl();
              }

              @Override
              public void insertUpdate(DocumentEvent documentEvent) {
                checkUrl();
              }

              @Override
              public void removeUpdate(DocumentEvent documentEvent) {
                checkUrl();
              }

              private void checkUrl() {
                if (URLUtil.isURL(url.getText())) {
                  button.setEnabled(true);
                } else {
                  button.setEnabled(false);
                }
              }
            });

    return Optional.of(controls);
  }
コード例 #25
0
  private void init() {
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(labelPatternPanel, BorderLayout.CENTER);

    JButton ok = new JButton(Localization.lang("Ok"));
    JButton cancel =
        new JButton(); // label of "cancel" is set later as the label is overwritten by assigning an
                       // action to the button

    JPanel lower = new JPanel();
    lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    ButtonBarBuilder bb = new ButtonBarBuilder(lower);
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();

    getContentPane().add(lower, BorderLayout.SOUTH);

    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    getContentPane().setPreferredSize(new Dimension(500, 600));
    pack();

    ok.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            metaData.setLabelPattern(labelPatternPanel.getLabelPatternAsDatabaseLabelPattern());
            panel.markNonUndoableBaseChanged();
            dispose();
          }
        });

    final JDialog dialog = this;

    Action cancelAction =
        new AbstractAction() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
          }
        };
    cancel.setAction(cancelAction);
    cancel.setText(Localization.lang("Cancel"));

    Util.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction);
  }
コード例 #26
0
 @Override
 public String getColumnName(int column) {
   switch (column) {
     case 0:
       return " ";
     case 1:
       return Localization.lang("Name");
     case 2:
       return Localization.lang("Extension");
     case 3:
       return Localization.lang("MIME type");
     default: // Five columns
       return Localization.lang("Application");
   }
 }
コード例 #27
0
  /** Table model for the custom importer table. */
  private class ImportTableModel extends AbstractTableModel {

    private final String[] columnNames =
        new String[] {
          Localization.lang("Import name"),
          Localization.lang("Command line id"),
          Localization.lang("Importer class"),
          Localization.lang("Contained in")
        };

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
      Object value = null;
      CustomImporter importer = getImporter(rowIndex);
      if (columnIndex == 0) {
        value = importer.getName();
      } else if (columnIndex == 1) {
        value = importer.getName();
      } else if (columnIndex == 2) {
        value = importer.getClassName();
      } else if (columnIndex == 3) {
        value = importer.getBasePath();
      }
      return value;
    }

    @Override
    public int getColumnCount() {
      return columnNames.length;
    }

    @Override
    public int getRowCount() {
      return Globals.prefs.customImports.size();
    }

    @Override
    public String getColumnName(int col) {
      return columnNames[col];
    }

    public CustomImporter getImporter(int rowIndex) {
      CustomImporter[] importers =
          Globals.prefs.customImports.toArray(
              new CustomImporter[Globals.prefs.customImports.size()]);
      return importers[rowIndex];
    }
  }
コード例 #28
0
 /**
  * Return a dropdown list with the month names for fields with EXTRA_MONTH
  *
  * @param fieldEditor
  * @param entryEditor
  * @param type
  * @return
  */
 public static Optional<JComponent> getMonthExtraComponent(
     FieldEditor fieldEditor, EntryEditor entryEditor, BibDatabaseMode type) {
   final String[] options = new String[13];
   options[0] = Localization.lang("Select");
   for (int i = 1; i <= 12; i++) {
     options[i] = MonthUtil.getMonthByNumber(i).fullName;
   }
   JComboBox<String> month = new JComboBox<>(options);
   month.addActionListener(
       actionEvent -> {
         int monthnumber = month.getSelectedIndex();
         if (monthnumber >= 1) {
           if (type == BibDatabaseMode.BIBLATEX) {
             fieldEditor.setText(String.valueOf(monthnumber));
           } else {
             fieldEditor.setText(MonthUtil.getMonthByNumber(monthnumber).bibtexFormat);
           }
         } else {
           fieldEditor.setText("");
         }
         entryEditor.updateField(fieldEditor);
         month.setSelectedIndex(0);
       });
   return Optional.of(month);
 }
コード例 #29
0
  /**
   * @param owner the parent Window (Dialog or Frame)
   * @param frame the JabRef Frame
   * @param panel the currently selected BasePanel
   * @param modal should this dialog be modal?
   * @param metaData The metadata of the current database
   * @param fieldName the field this selector is initialized for. May be null.
   */
  public ContentSelectorDialog2(
      Window owner,
      JabRefFrame frame,
      BasePanel panel,
      boolean modal,
      MetaData metaData,
      String fieldName) {
    super(owner, Localization.lang("Setup selectors"));
    this.setModal(modal);
    this.metaData = metaData;
    this.frame = frame;
    this.panel = panel;
    this.currentField = fieldName;

    initLayout();

    setupFieldSelector();
    setupWordSelector();
    setupActions();
    Util.bindCloseDialogKeyToCancelAction(this.rootPane, cancel.getAction());
    int fieldInd = fieldListModel.indexOf(currentField);
    if (fieldInd >= 0) {
      fieldList.setSelectedIndex(fieldInd);
    }

    pack();
  }
コード例 #30
0
 @Override
 JComponent description() {
   StringBuilder sb =
       new StringBuilder(
           "<html>"
               + Localization.lang("Changes have been made to the following metadata elements")
               + ":<p>");
   for (MetaDataChangeUnit unit : changes) {
     sb.append("<br>&nbsp;&nbsp;");
     sb.append(unit.key);
     /*switch (unit.type) {
         case ADD:
             sb.append("<p>Added: "+unit.key);
             break;
         case REMOVE:
             sb.append("<p>Removed: "+unit.key);
             break;
         case MODIFY:
             sb.append("<p>Modified: "+unit.key);
             break;
     }*/
   }
   sb.append("</html>");
   tp.setText(sb.toString());
   return sp;
 }