Weekdays(except if they represent flags)
JabRefException; This is especially important if the message stored in the Exception should be shown to the user.
JabRefExceptionhas already implemented the
getLocalizedMessage()method which should be used for such cases (see details below!).
IOExceptions) and rethrow them
EventBusrepresents a communication line between multiple components. Objects can be passed through the bus and reach the listening method of another object which is registered on that
EventBusinstance. Hence, the passed object is available as a parameter in the listening method.
@Subscribekeyword and must have only one accepting parameter. Furthermore, the object which contains such listening method(s) has to be registered using the
register(Object)method provided by
EventBus. The listening methods can be overloaded by using different parameter types.
post(object)posts an object through the
EventBuswhich has been used to register the listening/subscribing methods.
eventpackage contains some specific events which occur in JabRef.
EntryAddedEventis sent through the
eventBuswhich is located in
registerListener(Object listener)method in
EntryAddedEventprovides also methods to get the inserted
key=valuepairs for each String to be localized.
org.jabref.logic.l10n.Localizationhas to be used. The Class currently provides three methods to obtain translated strings:
Localization.lang("Translate me");instead of
Localization.lang(someVariable)(possibly in the form
someVariable = Localization.lang("Translate me")
%x-variables where appropriate:
Localization.lang("Exported %0 entries.", number)instead of
Localization.lang("Exported ") + number + Localization.lang(" entries.");
Localization.lang("KEY")to Java file. Run the
pt_BRit is necessary to add a language mapping for Crowdin to the crowdin.yml file in the root. Of course the properties file also has to be named according to the language code and locale.
CustomLocalDragboardwhich is a generic alternative to the system one.
BasePanelare the two main classes. You should never directly call them, instead pass them as parameters to the class.
String pathCan be the files name or a relative path to it. The Preferences should only be directly accessed in the GUI. For the usage in logic pass them as parameter
logicmust not know
ProxyPreferencesfor encapsulated preferences and https://github.com/JabRef/jabref/pull/658 for a detailed discussion.
format(String value)in the class
BracesFormatterwhich removes double braces in a given string.
methodUnderTest_ expectedBehavior_context(without the dashes). So for example
formatRemovesDoubleBracesAtBeginning. Try to avoid naming the tests with a
testprefix since this information is already contained in the class name. Moreover, starting the name with
testleads often to inferior test names (see also the Stackoverflow discussion about naming).
assertstatement and named accordingly (
formatDoesNotRemoveSingleBrace, , etc.). See JUnit AntiPattern for background.
assertEquals(Collections.emptyList(), actualList);instead of
assertEquals(0, actualList.size());to test whether a list is empty.
assertEquals(Arrays.asList("a", "b"), actualList);to compare lists instead of
BibtexEntryAssertto check that the correct BibEntry is returned.
Files.createFile(path). Using this pattern automatically ensures that the test folder is deleted after the tests are run. See the junit-pioneer doc for more details.
PreferencesMigrationsTestfor an example.
org.jabref.model.entry.AuthorList.fixAuthor_firstNameFirst(String). Then the authors always look nice. The only alternative containing all data of the names is
org.jabref.model.entry.AuthorList.fixAuthor_lastNameFirst(String). The other
fix...methods omit data (like the von parts or the junior information).
==operator to check if the argument is a reference to this object. If so, return
instanceofoperator to check if the argument has the correct type. If not, return
Objectin the equals declaration
DialogServiceprovides methods to display various dialogs (including custom ones) to the user. It also ensures the displayed dialog opens on the correct window via
initOwner()(for cases where the user has multiple screens). The following code snippet demonstrates how a custom dialog is displayed to the user:
DialogServiceis unavailable within current class/scope in which the dialog needs to be displayed,
DialogServicecan be instantiated via the code snippet shown as follows: