Skip to content

Commit

Permalink
Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Aug 15, 2016
1 parent afc8d8f commit f4db19e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 63 deletions.
28 changes: 21 additions & 7 deletions src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,39 @@ public JLabel getHeaderLabel() {
}
}

/**
* Check if the value returned by getColumnValue() is the same as a simple check of the entry's field(s) would give
* The reasons for being different are (combinations may also happen):
* - The entry has a crossref where the field content is obtained from
* - The field has a string in it (which getColumnValue() resolves)
* - There are some alias fields. For example, if the entry has a date field but no year field, getResolvedField()
* will return the year value from the date field when queried for year
*
*
* @param entry the BibEntry
* @return true if the value returned by getColumnValue() is resolved as outlined above
*/
public boolean isResolved(BibEntry entry) {
if (bibtexFields.isEmpty()) {
return false;
}

Optional<String> content = Optional.empty();
Optional<String> entryContent = Optional.empty();
Optional<String> resolvedFieldContent = Optional.empty();
Optional<String> plainFieldContent = Optional.empty();
for (String field : bibtexFields) {
if (BibEntry.TYPE_HEADER.equals(field) || "bibtextype".equals(field)) {
// entry type or bibtex key will never be resolved
if (BibEntry.TYPE_HEADER.equals(field) || BibEntry.OBSOLETE_TYPE_HEADER.equals(field)
|| BibEntry.KEY_FIELD.equals(field)) {
return false;
} else {
entryContent = entry.getFieldOptional(field);
content = BibDatabase.getResolvedField(field, entry, database.orElse(null));
plainFieldContent = entry.getFieldOptional(field);
resolvedFieldContent = BibDatabase.getResolvedField(field, entry, database.orElse(null));
}

if (content.isPresent()) {
if (resolvedFieldContent.isPresent()) {
break;
}
}
return (!content.equals(entryContent));
return (!resolvedFieldContent.equals(plainFieldContent));
}
}
22 changes: 16 additions & 6 deletions src/main/java/net/sf/jabref/model/database/BibDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
import java.util.regex.Pattern;

import net.sf.jabref.event.source.EntryEventSource;
import net.sf.jabref.logic.TypedBibEntry;
import net.sf.jabref.model.EntryTypes;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.BibtexString;
import net.sf.jabref.model.entry.EntryType;
import net.sf.jabref.model.entry.EntryUtil;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.model.entry.InternalBibtexFields;
import net.sf.jabref.model.entry.MonthUtil;
Expand Down Expand Up @@ -525,8 +527,16 @@ public static Optional<String> getResolvedField(String field, BibEntry entry, Bi
Objects.requireNonNull(entry, "entry cannot be null");

if (BibEntry.TYPE_HEADER.equals(field) || BibEntry.OBSOLETE_TYPE_HEADER.equals(field)) {
TypedBibEntry typedEntry = new TypedBibEntry(entry, BibDatabaseMode.BIBLATEX);
return Optional.of(typedEntry.getTypeForDisplay());
Optional<EntryType> entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX);
if (entryType.isPresent()) {
return Optional.of(entryType.get().getName());
} else {
return Optional.of(EntryUtil.capitalizeFirst(entry.getType()));
}
}

if (BibEntry.KEY_FIELD.equals(field)) {
return entry.getCiteKeyOptional();
}

// TODO: Changed this to also consider alias fields, which is the expected
Expand All @@ -536,14 +546,14 @@ public static Optional<String> getResolvedField(String field, BibEntry entry, Bi

// If this field is not set, and the entry has a crossref, try to look up the
// field in the referred entry: Do not do this for the bibtex key.
if (!result.isPresent() && (database != null) && !field.equals(BibEntry.KEY_FIELD)) {
if (!result.isPresent() && (database != null)) {
Optional<String> crossrefKey = entry.getFieldOptional(FieldName.CROSSREF);
if (crossrefKey.isPresent()) {
if (crossrefKey.isPresent() && !crossrefKey.get().isEmpty()) {
Optional<BibEntry> referred = database.getEntryByKey(crossrefKey.get());
if (referred.isPresent()) {
// Ok, we found the referred entry. Get the field value from that
// entry. If it is unset there, too, stop looking:
result = referred.get().getFieldOptional(field);
result = referred.get().getFieldOrAlias(field);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2462,6 +2462,5 @@ You_must_enter_at_least_one_field_name=Sie_müssen_mindestens_einen_Feldnamen_an


Non-ASCII_encoded_character_found=Nicht_ASCII-kodiertes_Zeichen_gefunden
Non-ASCII_encoded_character_found=
Background_color_for_resolved_fields=
Color_codes_for_resolved_fields=
5 changes: 2 additions & 3 deletions src/main/resources/l10n/JabRef_sv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,6 @@ You_must_enter_at_least_one_field_name=Du_måste_ange_minst_ett_fältnamn


Non-ASCII_encoded_character_found=Bokstäver_som_inte_är_ASCII-kodade_hittades
Non-ASCII_encoded_character_found=

Background_color_for_resolved_fields=
Color_codes_for_resolved_fields=
Background_color_for_resolved_fields=Bakgrundsfärg_för_uppslagna_fält
Color_codes_for_resolved_fields=Färgkodning_av_uppslagna_fält
46 changes: 0 additions & 46 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1684,52 +1684,6 @@ You_must_enter_at_least_one_field_name=En_az_bir_alan_adı_girmelisiniz


Non-ASCII_encoded_character_found=ASCII_koduyla_kodlanmamış_karakter_bulundu
Connection=
Host=
Database=
User=
Connection_error=
Driver_error=
Connection_to_%0_server_stablished.=
Required_field_"%0"_is_empty.=
Corrupt_shared_database_structure.=
Integrity_check_failed._Fixing...=

%0_driver_not_available.=

The_connection_to_the_server_has_been_determinated.=

Connection_lost.=
Reconnect=
Work_offline=

Working_offline.=

Update_refused.=
Update_refused=
Local_entry=
Shared_entry=
Update_could_not_be_performed_due_to_existing_change_conflicts.=
You_are_not_working_on_the_newest_version_of_BibEntry.=
Local_version\:_%0=
Shared_version\:_%0=
Please_merge_the_shared_entry_with_yours_and_press_"Merge_entries"_to_resolve_this_problem.=
Canceling_this_operation_will_leave_your_changes_unsynchronized._Cancel_anyway?=
The_BibEntry_you_currently_work_on_has_been_deleted_on_the_shared_side._Hit_"Keep"_to_recover_the_entry.=
Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
New_technical_report=

%0_file=
Custom_layout_file=
Protected_terms_file=
Style_file=

Open_OpenOffice/LibreOffice_connection=

You_must_enter_at_least_one_field_name=


Non-ASCII_encoded_character_found=

Background_color_for_resolved_fields=
Color_codes_for_resolved_fields=

0 comments on commit f4db19e

Please sign in to comment.