-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Enhanced message log #4815
Enhanced message log #4815
Changes from 1 commit
3ab1bd7
577de6a
7e20650
23362fa
7995593
deff466
e5cb625
7ccf914
67e33e1
0444b6a
f2a31d0
d87c7f6
ea3e786
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,6 @@ public static void openConsole(File file) throws IOException { | |
Localization.lang("Error occured while executing the command \"%0\".", commandLoggingText), | ||
Localization.lang("Open console") + " - " + Localization.lang("Error"), | ||
JOptionPane.ERROR_MESSAGE); | ||
JabRefGUI.getMainFrame().getDialogService().notify(null); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just saw that we seemed to forgot to convert that old swing dialog here. Could you please fix this as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did it in f2a31d0, there was also another one in the same class |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.JabRefFrame; | ||
import org.jabref.gui.util.BackgroundTask; | ||
import org.jabref.gui.util.DefaultTaskExecutor; | ||
import org.jabref.gui.util.TaskExecutor; | ||
import org.jabref.logic.importer.ImportException; | ||
import org.jabref.logic.importer.ImportFormatReader; | ||
|
@@ -95,11 +96,11 @@ private List<ImportFormatReader.UnknownFormatImport> doImport(List<Path> files) | |
try { | ||
if (!importer.isPresent()) { | ||
// Unknown format: | ||
frame.getDialogService().notify(Localization.lang("Importing in unknown format") + "..."); | ||
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().notify(Localization.lang("Importing in unknown format") + "...")); | ||
// This import method never throws an IOException: | ||
imports.add(Globals.IMPORT_FORMAT_READER.importUnknownFormat(filename, Globals.getFileUpdateMonitor())); | ||
} else { | ||
frame.getDialogService().notify(Localization.lang("Importing in %0 format", importer.get().getName()) + "..."); | ||
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().notify(Localization.lang("Importing in %0 format", importer.get().getName()) + "...")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also a workaround here and i would suggest to remove the notifications |
||
// Specific importer: | ||
ParserResult pr = importer.get().importDatabase(filename, Globals.prefs.getDefaultEncoding()); | ||
imports.add(new ImportFormatReader.UnknownFormatImport(importer.get().getName(), pr)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
import javax.swing.undo.CompoundEdit; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.JabRefExecutorService; | ||
import org.jabref.gui.BasePanel; | ||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.JabRefFrame; | ||
|
@@ -18,6 +17,7 @@ | |
import org.jabref.gui.undo.NamedCompound; | ||
import org.jabref.gui.undo.UndoableInsertEntry; | ||
import org.jabref.gui.undo.UndoableInsertString; | ||
import org.jabref.gui.util.BackgroundTask; | ||
import org.jabref.gui.util.FileDialogConfiguration; | ||
import org.jabref.logic.importer.OpenDatabase; | ||
import org.jabref.logic.importer.ParserResult; | ||
|
@@ -159,32 +159,31 @@ public void action() { | |
} | ||
filesToOpen.addAll(chosen); | ||
|
||
// Run the actual open in a thread to prevent the program locking until the file is loaded. | ||
JabRefExecutorService.INSTANCE.execute( | ||
() -> openIt(dialog.importEntries(), dialog.importStrings(), dialog.importGroups(), dialog.importSelectorWords())); | ||
} | ||
} | ||
if (filesToOpen.isEmpty()) { | ||
return; | ||
} | ||
|
||
private void openIt(boolean importEntries, boolean importStrings, boolean importGroups, | ||
boolean importSelectorWords) { | ||
if (filesToOpen.isEmpty()) { | ||
return; | ||
} | ||
for (Path file : filesToOpen) { | ||
try { | ||
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent().toString()); | ||
// Should this be done _after_ we know it was successfully opened? | ||
ParserResult parserResult = OpenDatabase.loadDatabase(file.toFile(), | ||
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor()); | ||
AppendDatabaseAction.mergeFromBibtex(panel, parserResult, importEntries, importStrings, importGroups, | ||
importSelectorWords); | ||
panel.output(Localization.lang("Imported from library") + " '" + file + "'"); | ||
} catch (IOException | KeyCollisionException ex) { | ||
LOGGER.warn("Could not open database", ex); | ||
|
||
dialogService.showErrorDialogAndWait(Localization.lang("Open library"), ex); | ||
for (Path file : filesToOpen) { | ||
// Run the actual open in a thread to prevent the program locking until the file is loaded. | ||
BackgroundTask.wrap(() -> openIt(file, dialog.importEntries(), dialog.importStrings(), dialog.importGroups(), dialog.importSelectorWords())) | ||
.onSuccess(fileName -> { dialogService.notify(Localization.lang("Imported from library") + " '" + fileName + "'");}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. singleLineLambdas usually don't need curly braces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed it :) |
||
.onFailure(exception -> { | ||
LOGGER.warn("Could not open database", exception); | ||
dialogService.showErrorDialogAndWait(Localization.lang("Open library"), exception);}) | ||
.executeWith(Globals.TASK_EXECUTOR);; | ||
} | ||
} | ||
} | ||
|
||
private String openIt(Path file, boolean importEntries, boolean importStrings, boolean importGroups, | ||
boolean importSelectorWords) throws IOException, KeyCollisionException { | ||
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent().toString()); | ||
// Should this be done _after_ we know it was successfully opened? | ||
ParserResult parserResult = OpenDatabase.loadDatabase(file.toFile(), | ||
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor()); | ||
AppendDatabaseAction.mergeFromBibtex(panel, parserResult, importEntries, importStrings, importGroups, | ||
importSelectorWords); | ||
return file.toString(); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookupIdentifiers is executed in a background thread and in order to provide feedback to the user, i used a workaround here and explicitly called DefaultTaskExecutor.runInJavaFXThread
However, i would suggest to completely remove the notifications here, because they do not provide much value