Skip to content

Commit

Permalink
Implemented #1682
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Aug 5, 2016
1 parent 0e618b5 commit 4e51bf7
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed [#1643](https://github.com/JabRef/jabref/issues/1643): Searching with double quotes in a specific field ignores the last character
- Fixed [#1288](https://github.com/JabRef/jabref/issues/1288): Newly opened bib-file is not focused
- Fixed [#1669](https://github.com/JabRef/jabref/issues/1669): Dialog for manual connection to OpenOffice/LibreOffice works again on Linux
- Fixed [#16682](https://github.com/JabRef/jabref/issues/1682): An entry now must have a BibTeX key to be cited in OpenOffice/LibreOffice


### Removed
Expand Down
41 changes: 39 additions & 2 deletions src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;

import net.sf.jabref.BibDatabaseContext;
import net.sf.jabref.Defaults;
import net.sf.jabref.Globals;
Expand All @@ -57,9 +56,13 @@
import net.sf.jabref.gui.actions.BrowseAction;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.undo.NamedCompound;
import net.sf.jabref.gui.undo.UndoableKeyChange;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.layout.LayoutFormatterPreferences;
import net.sf.jabref.logic.openoffice.OOBibStyle;
import net.sf.jabref.logic.openoffice.OpenOfficePreferences;
Expand Down Expand Up @@ -638,7 +641,8 @@ private void pushEntries(boolean inParenthesisIn, boolean withText, boolean addP
if (panel != null) {
final BibDatabase database = panel.getDatabase();
List<BibEntry> entries = panel.getSelectedEntries();
if (!entries.isEmpty()) {
if (!entries.isEmpty() && checkThatEntriesHaveKeys(entries)) {

try {
if (style == null) {
style = loader.getUsedStyle();
Expand Down Expand Up @@ -669,6 +673,39 @@ private void pushEntries(boolean inParenthesisIn, boolean withText, boolean addP

}

private boolean checkThatEntriesHaveKeys(List<BibEntry> entries) {
boolean emptyKeys = false;
for (BibEntry entry : entries) {
if (entry.getCiteKey() == null) {
emptyKeys = true;
break;
}
}
if (!emptyKeys) {
return true;
}
BasePanel panel = frame.getCurrentBasePanel();
int answer = JOptionPane.showConfirmDialog(this.frame,
Localization.lang("Cannot cite entries without BibTeX keys. Generate keys now?"),
Localization.lang("Cite"), JOptionPane.YES_NO_OPTION);
if ((answer == JOptionPane.YES_OPTION) && (panel != null)) {
LabelPatternPreferences prefs = LabelPatternPreferences.fromPreferences(Globals.prefs);
NamedCompound undoCompound = new NamedCompound(Localization.lang("Cite"));
for (BibEntry entry : entries) {
if (entry.getCiteKey() == null) {
LabelPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry,
prefs);
undoCompound.addEdit(new UndoableKeyChange(panel.getDatabase(), entry, null, entry.getCiteKey()));
}
}
undoCompound.end();
panel.getUndoManager().addEdit(undoCompound);
return true;
} else {
return false;
}
}

private void showConnectionLostErrorMessage() {
JOptionPane.showMessageDialog(frame,
Localization.lang("Connection to OpenOffice/LibreOffice has been lost. "
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1715,3 +1715,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2432,3 +2432,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2279,3 +2279,5 @@ Note\:_Use_the_placeholder_%0_for_the_location_of_the_opened_database_file.=Note
Executing_command_\"%0\"...=Executing_command_\"%0\"...
Error_occured_while_executing_the_command_\"%0\".=Error_occured_while_executing_the_command_\"%0\".
Reformat_ISSN=Reformat_ISSN

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1618,3 +1618,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2398,3 +2398,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1659,3 +1659,5 @@ Error_occured_while_executing_the_command_\"%0\".=Une_erreur_est_survenue_lors_d
Reformat_ISSN=Reformater_l'ISSN
Unable_to_generate_new_database=Impossible_de_générer_une_nouvelle_base_de_données
Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1637,3 +1637,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1736,3 +1736,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2377,3 +2377,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2410,3 +2410,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2805,3 +2805,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1631,3 +1631,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2378,3 +2378,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_sv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1574,3 +1574,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1650,3 +1650,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2402,3 +2402,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1644,3 +1644,5 @@ Reformat_ISSN=
Unable_to_generate_new_database=

Export_cited=

Cannot_cite_entries_without_BibTeX_keys._Generate_keys_now?=

0 comments on commit 4e51bf7

Please sign in to comment.