Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare multi module build #3913

Merged
merged 20 commits into from
Apr 16, 2018
Merged
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
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.jabref.cli.ArgumentProcessor;
import org.jabref.gui.remote.JabRefMessageHandler;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyAuthenticator;
Expand Down Expand Up @@ -146,7 +145,7 @@ private static void start(String[] args) {
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = ExporterFactory.create(Globals.prefs, Globals.journalAbbreviationLoader);
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);

// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());
Expand Down
40 changes: 19 additions & 21 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,18 @@ private boolean exportMatches(List<ParserResult> loaded) {

//read in the export format, take default format if no format entered
switch (data.length) {
case 3:
formatName = data[2];
break;
case 2:
//default exporter: HTML table (with Abstract & BibTeX)
formatName = "tablerefsabsbib";
break;
default:
System.err.println(Localization.lang("Output file missing").concat(". \n \t ")
.concat(Localization.lang("Usage")).concat(": ") + JabRefCLI.getExportMatchesSyntax());
noGUINeeded = true;
return false;
case 3:
formatName = data[2];
break;
case 2:
//default exporter: HTML table (with Abstract & BibTeX)
formatName = "tablerefsabsbib";
break;
default:
System.err.println(Localization.lang("Output file missing").concat(". \n \t ")
.concat(Localization.lang("Usage")).concat(": ") + JabRefCLI.getExportMatchesSyntax());
noGUINeeded = true;
return false;
}

//export new database
Expand Down Expand Up @@ -359,7 +359,7 @@ private boolean generateAux(List<ParserResult> loaded, String[] data) {

try {
System.out.println(Localization.lang("Saving") + ": " + subName);
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs);
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences();
BibDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(FileSaveSession::new);
Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
SaveSession session = databaseWriter.saveDatabase(new BibDatabaseContext(newBase, defaults), prefs);
Expand All @@ -368,8 +368,8 @@ private boolean generateAux(List<ParserResult> loaded, String[] data) {
if (!session.getWriter().couldEncodeAll()) {
System.err.println(Localization.lang("Warning") + ": "
+ Localization.lang(
"The chosen encoding '%0' could not encode the following characters:",
session.getEncoding().displayName())
"The chosen encoding '%0' could not encode the following characters:",
session.getEncoding().displayName())
+ " " + session.getWriter().getProblemCharacters());
}
session.commit(subName);
Expand Down Expand Up @@ -398,7 +398,7 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
if (!pr.isInvalid()) {
try {
System.out.println(Localization.lang("Saving") + ": " + data[0]);
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs);
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences();
Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
BibDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(
FileSaveSession::new);
Expand All @@ -409,8 +409,8 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
if (!session.getWriter().couldEncodeAll()) {
System.err.println(Localization.lang("Warning") + ": "
+ Localization.lang(
"The chosen encoding '%0' could not encode the following characters:",
session.getEncoding().displayName())
"The chosen encoding '%0' could not encode the following characters:",
session.getEncoding().displayName())
+ " " + session.getWriter().getProblemCharacters());
}
session.commit(data[0]);
Expand Down Expand Up @@ -453,7 +453,6 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
+ Throwables.getStackTraceAsString(ex));
}
}

}
}

Expand All @@ -466,7 +465,7 @@ private void importPreferences() {
Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs
.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs);
SavePreferences savePreferences = Globals.prefs.loadForExportFromPreferences();
XmpPreferences xmpPreferences = Globals.prefs.getXMPPreferences();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
} catch (JabRefException ex) {
Expand Down Expand Up @@ -582,5 +581,4 @@ public boolean shouldShutDown() {
public enum Mode {
INITIAL_START, REMOTE_START
}

}
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
this.tableModel = new MainTableDataModel(getBibDatabaseContext());

citationStyleCache = new CitationStyleCache(bibDatabaseContext);
annotationCache = new FileAnnotationCache(bibDatabaseContext);
annotationCache = new FileAnnotationCache(bibDatabaseContext, Globals.prefs.getFileDirectoryPreferences());

this.preview = new PreviewPanel(this, getBibDatabaseContext());
DefaultTaskExecutor.runInJavaFXThread(() -> frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview));
Expand Down Expand Up @@ -1092,7 +1092,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset enc,
frame.block();
final String SAVE_DATABASE = Localization.lang("Save library");
try {
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs)
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences()
.withEncoding(enc)
.withSaveType(saveType);
BibtexDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/actions/CleanupAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public void run() {
return;
}
CleanupPresetPanel presetPanel = new CleanupPresetPanel(panel.getBibDatabaseContext(),
CleanupPreset.loadFromPreferences(preferences));
preferences.getCleanupPreset());
int choice = showDialog(presetPanel);
if (choice != JOptionPane.OK_OPTION) {
canceled = true;
return;
}
CleanupPreset cleanupPreset = presetPanel.getCleanupPreset();
cleanupPreset.storeInPreferences(preferences);
preferences.setCleanupPreset(cleanupPreset);

if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) {
CheckBoxMessage cbm = new CheckBoxMessage(
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void displayResult(final DisplayResultCallback fup) {
storeTempDatabase();
}
});

} else {
JOptionPane.showMessageDialog(frame, Localization.lang("No actual changes found."),
Localization.lang("External changes"), JOptionPane.INFORMATION_MESSAGE);
Expand All @@ -104,7 +103,7 @@ public void displayResult(final DisplayResultCallback fup) {
private void storeTempDatabase() {
JabRefExecutorService.INSTANCE.execute(() -> {
try {
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withMakeBackup(false)
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences().withMakeBackup(false)
.withEncoding(panel.getBibDatabaseContext().getMetaData().getEncoding()
.orElse(Globals.prefs.getDefaultEncoding()));

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/exporter/ExportAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public InternalExportAction(JabRefFrame frame, boolean selectedOnly) {

@Override
public void actionPerformed(ActionEvent e) {
Globals.exportFactory = ExporterFactory.create(Globals.prefs, Globals.journalAbbreviationLoader);
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);
FileDialogConfiguration fileDialogConfiguration = ExportAction.createExportFileChooser(Globals.exportFactory, Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY));
DialogService dialogService = new FXDialogService();
DefaultTaskExecutor.runInJavaFXThread(() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ExportCustomizationDialog(final JabRefFrame frame) {
if (ecd.okPressed()) {
Globals.prefs.customExports.addFormat(ecd.name(), ecd.layoutFile(), ecd.extension(),
Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader),
SavePreferences.loadForExportFromPreferences(Globals.prefs));
Globals.prefs.loadForExportFromPreferences());
Globals.prefs.customExports.store(Globals.prefs);
}
});
Expand Down Expand Up @@ -111,7 +111,7 @@ public ExportCustomizationDialog(final JabRefFrame frame) {
}
LayoutFormatterPreferences layoutPreferences = Globals.prefs
.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs);
SavePreferences savePreferences = Globals.prefs.loadForExportFromPreferences();
for (List<String> list : entries) {
Globals.prefs.customExports.remove(list, layoutPreferences, savePreferences);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding)
frame.block();

try {
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withEncoding(encoding);
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences().withEncoding(encoding);
BibtexDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(FileSaveSession::new);

if (selectedOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.awt.BorderLayout;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -50,7 +52,7 @@ public DetectOpenOfficeInstallation(JDialog parent, OpenOfficePreferences prefer

public boolean isInstalled() {
foundPaths = false;
if (preferences.checkAutoDetectedPaths()) {
if (this.checkAutoDetectedPaths(preferences)) {
return true;
}
init();
Expand Down Expand Up @@ -110,6 +112,14 @@ private boolean autoDetectPaths() {
return false;
}

/**
* Checks whether the executablePath exists
*/
private boolean checkAutoDetectedPaths(OpenOfficePreferences openOfficePreferences) {
String executablePath = openOfficePreferences.getExecutablePath();
return ((executablePath != null) && Files.exists(Paths.get(executablePath)));
}

private boolean setOpenOfficePreferences(Path installDir) {
Optional<Path> execPath = Optional.empty();

Expand All @@ -124,7 +134,7 @@ private boolean setOpenOfficePreferences(Path installDir) {
Optional<Path> jarFilePath = FileUtil.find(OpenOfficePreferences.OO_JARS.get(0), installDir);

if (execPath.isPresent() && jarFilePath.isPresent()) {
preferences.setOOPath(installDir.toString());
preferences.setInstallationPath(installDir.toString());
preferences.setExecutablePath(execPath.get().toString());
preferences.setJarsPath(jarFilePath.get().getParent().toString());
return true;
Expand Down
40 changes: 25 additions & 15 deletions src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public OpenOfficePanel(JabRefFrame jabRefFrame, SidePaneManager spManager) {
update = new JButton(IconTheme.JabRefIcon.REFRESH.getSmallIcon());
update.setToolTipText(Localization.lang("Sync OpenOffice/LibreOffice bibliography"));
update.setPreferredSize(new Dimension(24, 24));
preferences = new OpenOfficePreferences(Globals.prefs);
preferences = Globals.prefs.getOpenOfficePreferences();
loader = new StyleLoader(preferences,
Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader),
Globals.prefs.getDefaultEncoding());
Expand Down Expand Up @@ -353,7 +353,7 @@ private void exportEntries() {

private List<BibDatabase> getBaseList() {
List<BibDatabase> databases = new ArrayList<>();
if (preferences.useAllDatabases()) {
if (preferences.getUseAllDatabases()) {
for (BasePanel basePanel : frame.getBasePanelList()) {
databases.add(basePanel.getDatabase());
}
Expand Down Expand Up @@ -599,7 +599,7 @@ private void pushEntries(boolean inParenthesisIn, boolean withText, boolean addP
style = loader.getUsedStyle();
}
ooBase.insertEntry(entries, database, getBaseList(), style, inParenthesis, withText, pageInfo,
preferences.syncWhenCiting());
preferences.getSyncWhenCiting());
} catch (FileNotFoundException ex) {
JOptionPane.showMessageDialog(frame,
Localization
Expand Down Expand Up @@ -717,28 +717,38 @@ private void showSettingsPopup() {
JPopupMenu menu = new JPopupMenu();
final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(
Localization.lang("Automatically sync bibliography when inserting citations"),
preferences.syncWhenCiting());
preferences.getSyncWhenCiting());
final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(
Localization.lang("Look up BibTeX entries in the active tab only"));
final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(
Localization.lang("Look up BibTeX entries in all open libraries"));
final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
ButtonGroup bg = new ButtonGroup();
bg.add(useActiveBase);
bg.add(useAllBases);
if (preferences.useAllDatabases()) {

ButtonGroup lookupButtonGroup = new ButtonGroup();
lookupButtonGroup.add(useActiveBase);
lookupButtonGroup.add(useAllBases);
if (preferences.getUseAllDatabases()) {
useAllBases.setSelected(true);
} else {
useActiveBase.setSelected(true);
}

autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected()));

useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected()));

useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected()));

clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings()));
autoSync.addActionListener(e -> {
preferences.setSyncWhenCiting(autoSync.isSelected());
Globals.prefs.setOpenOfficePreferences(preferences);
});
useAllBases.addActionListener(e -> {
preferences.setUseAllDatabases(useAllBases.isSelected());
Globals.prefs.setOpenOfficePreferences(preferences);
});
useActiveBase.addActionListener(e -> {
preferences.setUseAllDatabases(!useActiveBase.isSelected());
Globals.prefs.setOpenOfficePreferences(preferences);
});
clearConnectionSettings.addActionListener(e -> {
preferences.clearConnectionSettings();
Globals.prefs.setOpenOfficePreferences(preferences);
});

menu.add(autoSync);
menu.addSeparator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public OpenOfficeSidePanel(SidePaneManager sidePaneManager, Icon icon, String ti
super(sidePaneManager, icon, title);
this.preferences = preferences;
sidePaneManager.register(this);
if (preferences.showPanel()) {
if (preferences.getShowPanel()) {
manager.show(OpenOfficeSidePanel.class);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/preftabs/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.jabref.gui.maintable.MainTable;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.shared.prefs.SharedDatabasePreferences;
import org.jabref.logic.util.FileType;
Expand Down Expand Up @@ -225,7 +224,7 @@ private String getPrefsExportPath() {
private void updateAfterPreferenceChanges() {
setValues();

Globals.exportFactory = ExporterFactory.create(Globals.prefs, Globals.journalAbbreviationLoader);
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);

Globals.prefs.updateEntryEditorTabList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private Optional<Path> determineBackupPath() {
private void performBackup(Path backupPath) {
try {
Charset charset = bibDatabaseContext.getMetaData().getEncoding().orElse(preferences.getDefaultEncoding());
SavePreferences savePreferences = SavePreferences.loadForSaveFromPreferences(preferences).withEncoding
SavePreferences savePreferences = preferences.loadForSaveFromPreferences().withEncoding
(charset).withMakeBackup(false);
new BibtexDatabaseWriter<>(FileSaveSession::new).saveDatabase(bibDatabaseContext, savePreferences).commit
(backupPath);
Expand Down
Loading