Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/exporter/ExportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void actionPerformed(ActionEvent e) {
final IExportFormat format = eff.getExportFormat();
Set<String> entryIds = null;
if (selectedOnly) {
BibEntry[] selected = frame.getCurrentBasePanel().getSelectedEntries();
List<BibEntry> selected = frame.getCurrentBasePanel().getSelectedEntries();
entryIds = new HashSet<>();
for (BibEntry bibtexEntry : selected) {
entryIds.add(bibtexEntry.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void run() {
if (panel == null) {
return;
}
if (panel.getSelectedEntries().length == 0) {
if (panel.getSelectedEntries().isEmpty()) {
message = Localization.lang("No entries selected.");
getCallBack().update();
return;
Expand Down Expand Up @@ -111,8 +111,8 @@ public void run() {
// file, and read the contents afterwards:
tmp = File.createTempFile("jabrefCb", ".tmp");
tmp.deleteOnExit();
BibEntry[] bes = panel.getSelectedEntries();
HashSet<String> entries = new HashSet<>(bes.length);
List<BibEntry> bes = panel.getSelectedEntries();
Set<String> entries = new HashSet<>(bes.size());
for (BibEntry be : bes) {
entries.add(be.getId());
}
Expand All @@ -135,7 +135,7 @@ public void run() {
RtfSelection rs = new RtfSelection(sb.toString());
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(rs, owner);
message = Localization.lang("Entries exported to clipboard") + ": " + bes.length;
message = Localization.lang("Entries exported to clipboard") + ": " + bes.size();

} catch (Exception e) {
LOGGER.error("Error exporting to clipboard", e); //To change body of catch statement use File | Settings | File Templates.
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/sf/jabref/exporter/FileActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private static List<Comparator<BibEntry>> getSaveComparators(boolean isSaveOpera
* @return A List containing warnings, if any.
*/
public static SaveSession savePartOfDatabase(BibDatabaseContext bibDatabaseContext, File target,
JabRefPreferences prefs, BibEntry[] bes, Charset encoding, DatabaseSaveType saveType)
JabRefPreferences prefs, List<BibEntry> bes, Charset encoding, DatabaseSaveType saveType)
throws SaveException {


Expand Down Expand Up @@ -418,8 +418,7 @@ public static SaveSession savePartOfDatabase(BibDatabaseContext bibDatabaseConte
List<Comparator<BibEntry>> comparators = FileActions.getSaveComparators(true, bibDatabaseContext.getMetaData());

// Use glazed lists to get a sorted view of the entries:
List<BibEntry> sorter = new ArrayList<>(bes.length);
Collections.addAll(sorter, bes);
List<BibEntry> sorter = new ArrayList<>(bes);
Collections.sort(sorter, new FieldComparatorStack<>(comparators));

BibEntryWriter bibtexEntryWriter = new BibEntryWriter(new LatexFieldFormatter(), true);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/external/AttachFileAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public AttachFileAction(BasePanel panel) {

@Override
public void action() {
if (panel.getSelectedEntries().length != 1) {
if (panel.getSelectedEntries().size() != 1) {
return; // TODO: display error message?
}
BibEntry entry = panel.getSelectedEntries()[0];
BibEntry entry = panel.getSelectedEntries().get(0);
FileListEntry flEntry = new FileListEntry("", "", null);
FileListEntryEditor editor = new FileListEntryEditor(panel.frame(), flEntry, false, true,
panel.getBibDatabaseContext().getMetaData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void init() throws Throwable {
@Override
public void run() {
// TODO: just download for all entries and save files without dialog
entry = basePanel.getSelectedEntries()[0];
entry = basePanel.getSelectedEntries().get(0);
FindFullText fft = new FindFullText();
result = fft.findFullTextPDF(entry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class TransferableFileLinkSelection implements Transferable {
private final List<File> fileList = new ArrayList<>();


public TransferableFileLinkSelection(BasePanel panel, BibEntry[] selection) {
public TransferableFileLinkSelection(BasePanel panel, List<BibEntry> selection) {
FileListTableModel tm = new FileListTableModel();
selection[0].getFieldOptional(Globals.FILE_FIELD).ifPresent(file -> tm.setContent(file));
selection.get(0).getFieldOptional(Globals.FILE_FIELD).ifPresent(file -> tm.setContent(file));
if (tm.getRowCount() > 0) {
// Find the default directory for this field type, if any:
List<String> dirs = panel.getBibDatabaseContext().getMetaData().getFileDirectory(Globals.FILE_FIELD);
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/net/sf/jabref/external/WriteXMPAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;

Expand Down Expand Up @@ -50,7 +49,7 @@ public class WriteXMPAction extends AbstractWorker {

private final BasePanel panel;

private BibEntry[] entries;
private List<BibEntry> entries;

private BibDatabase database;

Expand All @@ -74,12 +73,11 @@ public void init() {
// Get entries and check if it makes sense to perform this operation
entries = panel.getSelectedEntries();

if (entries.length == 0) {
if (entries.isEmpty()) {

Collection<BibEntry> var = database.getEntries();
entries = var.toArray(new BibEntry[var.size()]);
entries.addAll(database.getEntries());

if (entries.length == 0) {
if (entries.isEmpty()) {

JOptionPane.showMessageDialog(panel, Localization.lang("This operation requires at least one entry."),
Localization.lang("Write XMP-metadata"), JOptionPane.ERROR_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package net.sf.jabref.external.push;

import java.io.IOException;
import java.util.List;

import javax.swing.*;

Expand Down Expand Up @@ -61,7 +62,7 @@ public String getTooltip() {
}

@Override
public void pushEntries(BibDatabase database, BibEntry[] entries, String keyString, MetaData metaData) {
public void pushEntries(BibDatabase database, List<BibEntry> entries, String keyString, MetaData metaData) {

couldNotConnect = false;
couldNotCall = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package net.sf.jabref.external.push;

import java.util.List;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -55,12 +56,12 @@ public interface PushToApplication {
/**
* The actual operation. This method will not be called on the event dispatch thread, so it should not do GUI
* operations without utilizing invokeLater().
*
*
* @param database
* @param entries
* @param metaData
*/
void pushEntries(BibDatabase database, BibEntry[] entries, String keyString, MetaData metaData);
void pushEntries(BibDatabase database, List<BibEntry> entries, String keyString, MetaData metaData);

/**
* Reporting etc., this method is called on the event dispatch thread after pushEntries() returns.
Expand All @@ -70,7 +71,7 @@ public interface PushToApplication {
/**
* Check whether this operation requires BibTeX keys to be set for the entries. If true is returned an error message
* will be displayed if keys are missing.
*
*
* @return true if BibTeX keys are required for this operation.
*/
boolean requiresBibtexKeys();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2003-2015 JabRef contributors.
/* Copyright (C) 2003-2016 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
Expand All @@ -16,6 +16,7 @@
package net.sf.jabref.external.push;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.Action;
Expand All @@ -35,7 +36,7 @@ class PushToApplicationAction extends AbstractAction implements Runnable {
private final PushToApplication operation;
private final JabRefFrame frame;
private BasePanel panel;
private BibEntry[] entries;
private List<BibEntry> entries;


public PushToApplicationAction(JabRefFrame frame, PushToApplication operation) {
Expand All @@ -57,7 +58,7 @@ public void actionPerformed(ActionEvent e) {

// Check if any entries are selected:
entries = panel.getSelectedEntries();
if (entries.length == 0) {
if (entries.isEmpty()) {
JOptionPane.showMessageDialog(frame, Localization.lang("This operation requires one or more entries to be selected."), (String) getValue(Action.NAME), JOptionPane.ERROR_MESSAGE);
return;
}
Expand Down Expand Up @@ -91,7 +92,7 @@ public void run() {
});
}

private static String getKeyString(BibEntry[] bibentries) {
private static String getKeyString(List<BibEntry> bibentries) {
StringBuilder result = new StringBuilder();
String citeKey;
boolean first = true;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/external/push/PushToEmacs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import javax.swing.*;

Expand Down Expand Up @@ -79,7 +80,7 @@ protected void initSettingsPanel() {
}

@Override
public void pushEntries(BibDatabase database, BibEntry[] entries, String keys, MetaData metaData) {
public void pushEntries(BibDatabase database, List<BibEntry> entries, String keys, MetaData metaData) {

couldNotConnect = false;
couldNotCall = false;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/sf/jabref/external/push/PushToLyx.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import javax.swing.*;

Expand Down Expand Up @@ -69,7 +70,8 @@ protected void initSettingsPanel() {
}

@Override
public void pushEntries(BibDatabase database, final BibEntry[] entries, final String keyString, MetaData metaData) {
public void pushEntries(BibDatabase database, final List<BibEntry> entries, final String keyString,
MetaData metaData) {

couldNotConnect = false;
couldNotCall = false;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/external/push/PushToVim.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
* Created by IntelliJ IDEA. User: alver Date: Mar 7, 2007 Time: 6:55:56 PM To change this template use File | Settings
Expand Down Expand Up @@ -73,7 +74,7 @@ protected void initSettingsPanel() {
}

@Override
public void pushEntries(BibDatabase database, BibEntry[] entries, String keys, MetaData metaData) {
public void pushEntries(BibDatabase database, List<BibEntry> entries, String keys, MetaData metaData) {

couldNotConnect = false;
couldNotCall = false;
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/net/sf/jabref/groups/AddToGroupAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package net.sf.jabref.groups;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;

import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.undo.AbstractUndoableEdit;

Expand Down Expand Up @@ -64,8 +64,8 @@ public void setNode(GroupTreeNode node) {

@Override
public void actionPerformed(ActionEvent evt) {
final BibEntry[] entries = mPanel.getSelectedEntries();
final Vector<GroupTreeNode> removeGroupsNodes = new Vector<>(); // used only when moving
final List<BibEntry> entries = mPanel.getSelectedEntries();
final List<GroupTreeNode> removeGroupsNodes = new ArrayList<>(); // used only when moving

if (m_move) {
// collect warnings for removal
Expand All @@ -82,17 +82,20 @@ public void actionPerformed(ActionEvent evt) {
}
// warning for all groups from which the entries are removed, and
// for the one to which they are added! hence the magical +1
AbstractGroup[] groups = new AbstractGroup[removeGroupsNodes.size() + 1];
for (int i = 0; i < removeGroupsNodes.size(); ++i) {
groups[i] = removeGroupsNodes.elementAt(i).getGroup();
List<AbstractGroup> groups = new ArrayList<>(removeGroupsNodes.size() + 1);
for (GroupTreeNode node : removeGroupsNodes) {
groups.add(node.getGroup());
}
groups[groups.length - 1] = mNode.getGroup();
if (!Util.warnAssignmentSideEffects(groups, entries, mPanel.getDatabase(), mPanel.frame())) {
groups.set(groups.size() - 1, mNode.getGroup());
if (!Util.warnAssignmentSideEffects(groups.toArray(new AbstractGroup[groups.size()]),
entries.toArray(new BibEntry[entries.size()]),
mPanel.getDatabase(), mPanel.frame())) {
return; // user aborted operation
}
} else {
// warn if assignment has undesired side effects (modifies a field != keywords)
if (!Util.warnAssignmentSideEffects(new AbstractGroup[] {mNode.getGroup()}, entries, mPanel.getDatabase(),
if (!Util.warnAssignmentSideEffects(new AbstractGroup[] {mNode.getGroup()},
entries.toArray(new BibEntry[entries.size()]), mPanel.getDatabase(),
mPanel.frame())) {
return; // user aborted operation
}
Expand All @@ -107,8 +110,7 @@ public void actionPerformed(ActionEvent evt) {

if (m_move) {
// first remove
for (int i = 0; i < removeGroupsNodes.size(); ++i) {
GroupTreeNode node = removeGroupsNodes.elementAt(i);
for (GroupTreeNode node : removeGroupsNodes) {
if (node.getGroup().containsAny(entries)) {
AbstractUndoableEdit undoRemove = node.removeFromGroup(entries);
if (undoRemove != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2003-2015 JabRef contributors.
/* Copyright (C) 2003-2016 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/net/sf/jabref/groups/GroupDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

Expand Down Expand Up @@ -479,23 +480,23 @@ private void addPreviousEntries() {
if (i == JOptionPane.NO_OPTION) {
return;
}
Vector<BibEntry> vec = new Vector<>();
List<BibEntry> list = new ArrayList<>();
for (BibEntry entry : m_basePanel.database().getEntries()) {
if (m_editedGroup.contains(entry)) {
vec.add(entry);
list.add(entry);
}
}
if (!vec.isEmpty()) {
BibEntry[] entries = new BibEntry[vec.size()];
vec.toArray(entries);
if (!list.isEmpty()) {
BibEntry[] entries = new BibEntry[list.size()];
list.toArray(entries);
if (!Util.warnAssignmentSideEffects(new AbstractGroup[] {mResultingGroup},
entries, m_basePanel.getDatabase(), this)) {
return;
}
// the undo information for a conversion to an ExplicitGroup is
// contained completely in the UndoableModifyGroup object.
if (!(mResultingGroup instanceof ExplicitGroup)) {
mUndoAddPreviousEntires = mResultingGroup.add(entries);
mUndoAddPreviousEntires = mResultingGroup.add(list);
}
}
}
Expand Down
Loading