Skip to content

Commit

Permalink
Merge branch 'master' into file-based-bibtex-mode
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java
#	src/main/java/net/sf/jabref/model/entry/BibEntry.java
#	src/main/java/net/sf/jabref/wizard/text/gui/TextInputDialog.java
  • Loading branch information
simonharrer committed Jan 29, 2016
2 parents b51f3ad + 9bf21b8 commit 1550252
Show file tree
Hide file tree
Showing 31 changed files with 154 additions and 209 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Improved layout for OSX: Toolbar buttons and search field
- Migrated JabRef help to markdown at https://github.com/JabRef/help.jabref.org
- BibTeX and BibLaTeX mode is now file based and can be switched at runtime. The information is stored in the .bib file, and if it is not there detected by the entry types.
- Moved all quality-related database actions inside a new quality menu

### Fixed
- Make BibTex parser more robust against missing newlines
Expand All @@ -44,7 +45,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Removed save session functionality as it just saved the last opened tabs which is done by default
- Removed CLI option -l to load a session
- Removed JabRef offline help files which are replaced by the new online documentation at https://github.com/JabRef/help.jabref.org

- Removed PDF preview functionality



Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void start(String[] args) {
Globals.prefs.setLanguageDependentDefaultValues();

// Update which fields should be treated as numeric, based on preferences:
BibtexFields.setNumericFieldsFromPrefs();
InternalBibtexFields.setNumericFieldsFromPrefs();

/* Build list of Import and Export formats */
Globals.importFormatReader.resetImportFormats();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ private JabRefPreferences() {
// default time stamp follows ISO-8601. Reason: https://xkcd.com/1179/
defaults.put(TIME_STAMP_FORMAT, "yyyy-MM-dd");

defaults.put(TIME_STAMP_FIELD, BibtexFields.TIMESTAMP);
defaults.put(TIME_STAMP_FIELD, InternalBibtexFields.TIMESTAMP);
defaults.put(UPDATE_TIMESTAMP, Boolean.FALSE);

defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/bibtex/BibEntryWriter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.sf.jabref.bibtex;

import net.sf.jabref.gui.BibtexFields;
import net.sf.jabref.gui.InternalBibtexFields;
import net.sf.jabref.Globals;
import net.sf.jabref.exporter.LatexFieldFormatter;
import net.sf.jabref.logic.util.strings.StringUtil;
Expand Down Expand Up @@ -89,8 +89,8 @@ private void writeRequiredFieldsFirstRemainingFieldsSecond(BibEntry entry, Write
// Then write remaining fields in alphabetic order.
TreeSet<String> remainingFields = new TreeSet<>();
for (String key : entry.getFieldNames()) {
boolean writeIt = write ? BibtexFields.isWriteableField(key) :
BibtexFields.isDisplayableField(key);
boolean writeIt = write ? InternalBibtexFields.isWriteableField(key) :
InternalBibtexFields.isDisplayableField(key);
if (!written.contains(key) && writeIt) {
remainingFields.add(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package net.sf.jabref.bibtex.comparator;

import net.sf.jabref.gui.BibtexFields;
import net.sf.jabref.gui.InternalBibtexFields;
import net.sf.jabref.model.entry.AuthorList;
import net.sf.jabref.model.entry.BibEntry;

Expand Down Expand Up @@ -43,15 +43,15 @@ public EntryComparator(boolean binary, boolean desc, String field, Comparator<Bi
this.sortField = field;
this.descending = desc;
this.next = next;
this.numeric = BibtexFields.isNumeric(sortField);
this.numeric = InternalBibtexFields.isNumeric(sortField);
}

public EntryComparator(boolean binary, boolean desc, String field) {
this.binary = binary;
this.sortField = field;
this.descending = desc;
this.next = null;
this.numeric = BibtexFields.isNumeric(sortField);
this.numeric = InternalBibtexFields.isNumeric(sortField);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package net.sf.jabref.bibtex.comparator;

import net.sf.jabref.gui.BibtexFields;
import net.sf.jabref.gui.InternalBibtexFields;
import net.sf.jabref.gui.maintable.MainTableFormat;
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.model.entry.AuthorList;
Expand Down Expand Up @@ -79,7 +79,7 @@ public FieldComparator(String field, boolean reversed) {
|| "editor".equals(this.field[0]);
isYearField = "year".equals(this.field[0]);
isMonthField = "month".equals(this.field[0]);
isNumeric = BibtexFields.isNumeric(this.field[0]);
isNumeric = InternalBibtexFields.isNumeric(this.field[0]);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/exporter/FileActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import java.util.regex.Pattern;

import net.sf.jabref.bibtex.EntryTypes;
import net.sf.jabref.gui.InternalBibtexFields;
import net.sf.jabref.logic.CustomEntryTypesManager;
import net.sf.jabref.model.entry.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.sf.jabref.*;
import net.sf.jabref.gui.BibtexFields;
import net.sf.jabref.bibtex.BibEntryWriter;
import net.sf.jabref.bibtex.comparator.BibtexStringComparator;
import net.sf.jabref.bibtex.comparator.CrossRefEntryComparator;
Expand Down Expand Up @@ -235,11 +235,11 @@ public static SaveSession saveDatabase(BibDatabaseContext bibDatabaseContext, Fi
// Check if the entry should be written.
boolean write = true;

if (checkSearch && !FileActions.nonZeroField(entry, BibtexFields.SEARCH)) {
if (checkSearch && !FileActions.nonZeroField(entry, InternalBibtexFields.SEARCH)) {
write = false;
}

if (checkGroup && !FileActions.nonZeroField(entry, BibtexFields.GROUPSEARCH)) {
if (checkGroup && !FileActions.nonZeroField(entry, InternalBibtexFields.GROUPSEARCH)) {
write = false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/exporter/LatexFieldFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package net.sf.jabref.exporter;

import net.sf.jabref.*;
import net.sf.jabref.gui.BibtexFields;
import net.sf.jabref.gui.InternalBibtexFields;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.importer.fileformat.FieldContentParser;
import net.sf.jabref.logic.util.strings.StringUtil;
Expand Down Expand Up @@ -183,7 +183,7 @@ private boolean shouldResolveStrings(String fieldName) {
}
} else {
// Default operation - we only resolve strings for standard fields:
resolveStrings = BibtexFields.isStandardField(fieldName)
resolveStrings = InternalBibtexFields.isStandardField(fieldName)
|| BIBTEX_STRING.equals(fieldName);
}
return resolveStrings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void actionPerformed(ActionEvent e) {
saveInOriginalOrder.addActionListener(listener);
saveInSpecifiedOrder.addActionListener(listener);

List<String> v = new ArrayList<>(BibtexFields.getAllFieldNames());
List<String> v = new ArrayList<>(InternalBibtexFields.getAllFieldNames());
v.add(BibEntry.KEY_FIELD);
Collections.sort(v);
String[] allPlusKey = v.toArray(new String[v.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class EntryCustomizationDialog extends JDialog implements ListSelectionLi
protected JButton delete;
protected JButton importTypes;
protected JButton exportTypes;
private final List<String> preset = BibtexFields.getAllFieldNames();
private final List<String> preset = InternalBibtexFields.getAllFieldNames();
private String lastSelected;
private final Map<String, List<String>> reqLists = new HashMap<>();
private final Map<String, List<String>> optLists = new HashMap<>();
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/net/sf/jabref/gui/EntryMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class EntryMarker {
public static void markEntry(BibEntry be, int markIncrement, boolean increment, NamedCompound ce) {
int prevMarkLevel;
String newValue = null;
if (be.hasField(BibtexFields.MARKED)) {
String s = be.getField(BibtexFields.MARKED);
if (be.hasField(InternalBibtexFields.MARKED)) {
String s = be.getField(InternalBibtexFields.MARKED);
int index = s.indexOf(Globals.prefs.WRAPPED_USERNAME);
if (index >= 0) {
// Already marked 1 for this user.
Expand All @@ -64,16 +64,16 @@ public static void markEntry(BibEntry be, int markIncrement, boolean increment,
newValue = Globals.prefs.WRAPPED_USERNAME.substring(0, Globals.prefs.WRAPPED_USERNAME.length() - 1) + ":" + markIncrement + "]";
}

ce.addEdit(new UndoableFieldChange(be, BibtexFields.MARKED, be.getField(BibtexFields.MARKED), newValue));
be.setField(BibtexFields.MARKED, newValue);
ce.addEdit(new UndoableFieldChange(be, InternalBibtexFields.MARKED, be.getField(InternalBibtexFields.MARKED), newValue));
be.setField(InternalBibtexFields.MARKED, newValue);
}

/**
* SIDE EFFECT: Unselects given entry
*/
public static void unmarkEntry(BibEntry be, boolean onlyMaxLevel, BibDatabase database, NamedCompound ce) {
if (be.hasField(BibtexFields.MARKED)) {
String s = be.getField(BibtexFields.MARKED);
if (be.hasField(InternalBibtexFields.MARKED)) {
String s = be.getField(InternalBibtexFields.MARKED);
if ("0".equals(s)) {
if (!onlyMaxLevel) {
unmarkOldStyle(be, database, ce);
Expand Down Expand Up @@ -125,11 +125,11 @@ public static void unmarkEntry(BibEntry be, boolean onlyMaxLevel, BibDatabase da
sb.append(s.substring(piv));
}
String newVal = sb.length() > 0 ? sb.toString() : null;*/
ce.addEdit(new UndoableFieldChange(be, BibtexFields.MARKED, be.getField(BibtexFields.MARKED), newValue));
ce.addEdit(new UndoableFieldChange(be, InternalBibtexFields.MARKED, be.getField(InternalBibtexFields.MARKED), newValue));
if (newValue == null) {
be.clearField(BibtexFields.MARKED);
be.clearField(InternalBibtexFields.MARKED);
} else {
be.setField(BibtexFields.MARKED, newValue);
be.setField(InternalBibtexFields.MARKED, newValue);
}
}
}
Expand All @@ -148,7 +148,7 @@ public static void unmarkEntry(BibEntry be, boolean onlyMaxLevel, BibDatabase da
private static void unmarkOldStyle(BibEntry be, BibDatabase database, NamedCompound ce) {
TreeSet<Object> owners = new TreeSet<>();
for (BibEntry entry : database.getEntries()) {
entry.getFieldOptional(BibtexFields.OWNER).ifPresent(owner -> owners.add(owner));
entry.getFieldOptional(InternalBibtexFields.OWNER).ifPresent(owner -> owners.add(owner));
}
owners.remove(Globals.prefs.get(JabRefPreferences.DEFAULT_OWNER));
StringBuilder sb = new StringBuilder();
Expand All @@ -159,19 +159,19 @@ private static void unmarkOldStyle(BibEntry be, BibDatabase database, NamedCompo
}
String newVal = sb.toString();
if (newVal.isEmpty()) {
ce.addEdit(new UndoableFieldChange(be, BibtexFields.MARKED, be.getField(BibtexFields.MARKED), null));
be.clearField(BibtexFields.MARKED);
ce.addEdit(new UndoableFieldChange(be, InternalBibtexFields.MARKED, be.getField(InternalBibtexFields.MARKED), null));
be.clearField(InternalBibtexFields.MARKED);
} else {
ce.addEdit(new UndoableFieldChange(be, BibtexFields.MARKED, be.getField(BibtexFields.MARKED), newVal));
be.setField(BibtexFields.MARKED, newVal);
ce.addEdit(new UndoableFieldChange(be, InternalBibtexFields.MARKED, be.getField(InternalBibtexFields.MARKED), newVal));
be.setField(InternalBibtexFields.MARKED, newVal);
}
}

public static int isMarked(BibEntry be) {
if (!be.hasField(BibtexFields.MARKED)) {
if (!be.hasField(InternalBibtexFields.MARKED)) {
return 0;
}
String s = be.getField(BibtexFields.MARKED);
String s = be.getField(InternalBibtexFields.MARKED);
if ("0".equals(s)) {
return 1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/gui/FieldWeightDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ private JPanel buildMainPanel() {
TreeSet<String> fields = new TreeSet<>();
// We use this map to remember which slider represents which field name:
sliders.clear();
for (int i = 0, len = BibtexFields.numberOfPublicFields(); i < len; i++)
for (int i = 0, len = InternalBibtexFields.numberOfPublicFields(); i < len; i++)
{
fields.add(BibtexFields.getFieldName(i));
fields.add(InternalBibtexFields.getFieldName(i));
}
fields.remove("bibtexkey"); // bibtex key doesn't need weight.
// Here is the place to add other fields:
Expand All @@ -76,7 +76,7 @@ private JPanel buildMainPanel() {

for (String field : fields) {
builder.append(field);
int weight = (int) ((100 * BibtexFields.getFieldWeight(field)) / GUIGlobals.MAX_FIELD_WEIGHT);
int weight = (int) ((100 * InternalBibtexFields.getFieldWeight(field)) / GUIGlobals.MAX_FIELD_WEIGHT);
//System.out.println(weight);
JSlider slider = new JSlider(0, 100, weight);//,);
sliders.put(slider, new SliderInfo(field, weight));
Expand Down Expand Up @@ -120,7 +120,7 @@ private void storeSettings() {
// Only list the value if it has changed:
if (sInfo.originalValue != slider.getValue()) {
double weight = (GUIGlobals.MAX_FIELD_WEIGHT * slider.getValue()) / 100d;
BibtexFields.setFieldWeight(sInfo.fieldName, weight);
InternalBibtexFields.setFieldWeight(sInfo.fieldName, weight);
}
}
frame.removeCachedEntryEditors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ private void setWidths() {
}

for (int i = 0; i < fields.length; i++) {
int width = BibtexFields.getFieldLength(fields[i]);
int width = InternalBibtexFields.getFieldLength(fields[i]);
glTable.getColumnModel().getColumn(i + PAD).setPreferredWidth(width);
}
}
Expand Down
Loading

0 comments on commit 1550252

Please sign in to comment.