diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c7e8561b56..6c6a54c04a92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Changed - Add session restoring functionality for shared database. Related to [#1703](https://github.com/JabRef/jabref/issues/1703) - Implementation of LiveUpdate for PostgreSQL & Oracle systems. Related to [#970](https://github.com/JabRef/jabref/issues/970). +- Added support for [1.0.1 CitationStyles](http://citationstyles.org/) +- You can set and cycle between different preview styles (including CitationStyles) - Added fetcher for [MathSciNet](http://www.ams.org/mathscinet), [zbMATH](https://www.zbmath.org/) and [Astrophysics Data System](http://www.adsabs.harvard.edu/) - Improved search: - Search queries consisting of a normal query and a field-based query are now supported (for example, `JabRef AND author == you`) @@ -72,7 +74,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed [#1996](https://github.com/JabRef/jabref/issues/1996): Unnecessary other fields tab in entry editor removed (BibTeX mode) ### Removed -- The non-supported feature of being able to define file directories for any extension is removed. Still, it should work for older databases using the legacy `ps` and `pdf` fields, although we strongly encourage using the `file` field. +- Removed 2nd preview style +- The non-supported feature of being able to define file directories for any extension is removed. Still, it should work for older databases using the legacy `ps` and `pdf` fields, although we strongly encourage using the `file` field. - Automatic migration for the `evastar_pdf` field is removed. diff --git a/build.gradle b/build.gradle index cad274d9a236..fc50236a1518 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,9 @@ install4j { repositories { jcenter() + maven { + url 'https://oss.sonatype.org/content/groups/public' + } } configurations { @@ -124,6 +127,13 @@ dependencies { compile 'org.xmlunit:xmlunit-core:2.2.1' compile 'org.xmlunit:xmlunit-matchers:2.2.1' + // need to use snapshots as the stable version is from 2013 and doesn't support v1.0.1 CitationStyles + compile 'org.citationstyles:styles:1.0.1-SNAPSHOT' + compile 'org.citationstyles:locales:1.0.1-SNAPSHOT' + compile 'de.undercouch:citeproc-java:0.6' + // in Java 8 Rhino was replaced by Nashorn, but 'de.undercouch:citeproc-java:0.6' depends on Rhino + compile 'org.mozilla:rhino:1.7.7.1' + testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'com.github.tomakehurst:wiremock:2.1.12' diff --git a/external-libraries.txt b/external-libraries.txt index c56b36334757..ccba7055ef89 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -159,4 +159,24 @@ Project: Spin URL: http://spin.sourceforge.net/ License: LGPL 2.1+ +Id: org.citationstyles.styles +Project: CSL Styles +URL: citationStyles.org +Licence: Creative Commons Attribution-ShareAlike 3.0 Unported license + +Id: org.citationstyles.locales +Project: CSL Locales +URL: citationStyles.org +Licence: Creative Commons Attribution-ShareAlike 3.0 Unported license + +Id: de.undercouch.citeproc-java +Project: Citeproc-Java +URL: http://michel-kraemer.github.io/citeproc-java/ +Licence: Apache License, Version 2.0 + +Id: org.mozilla.rhino +Project: Rhino +URL: https://developer.mozilla.org/de/docs/Rhino +Licence: Mozilla Public License Version 2.0 + The last entry has to end with an empty line. Otherwise the entry is not present in About.html. diff --git a/licenses/de.undercouch.citeproc-java.txt b/licenses/de.undercouch.citeproc-java.txt new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/licenses/de.undercouch.citeproc-java.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/licenses/org.citationstyles.locales.txt b/licenses/org.citationstyles.locales.txt new file mode 100644 index 000000000000..604209a80463 --- /dev/null +++ b/licenses/org.citationstyles.locales.txt @@ -0,0 +1,359 @@ +Creative Commons Legal Code + +Attribution-ShareAlike 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined below) for the purposes of this + License. + c. "Creative Commons Compatible License" means a license that is listed + at https://creativecommons.org/compatiblelicenses that has been + approved by Creative Commons as being essentially equivalent to this + License, including, at a minimum, because that license: (i) contains + terms that have the same purpose, meaning and effect as the License + Elements of this License; and, (ii) explicitly permits the relicensing + of adaptations of works made available under that license under this + License or a Creative Commons jurisdiction license with the same + License Elements as this License. + d. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + e. "License Elements" means the following high-level license attributes + as selected by Licensor and indicated in the title of this License: + Attribution, ShareAlike. + f. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + g. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + h. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + i. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + j. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + k. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(c), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(c), as requested. + b. You may Distribute or Publicly Perform an Adaptation only under the + terms of: (i) this License; (ii) a later version of this License with + the same License Elements as this License; (iii) a Creative Commons + jurisdiction license (either this or a later license version) that + contains the same License Elements as this License (e.g., + Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible + License. If you license the Adaptation under one of the licenses + mentioned in (iv), you must comply with the terms of that license. If + you license the Adaptation under the terms of any of the licenses + mentioned in (i), (ii) or (iii) (the "Applicable License"), you must + comply with the terms of the Applicable License generally and the + following provisions: (I) You must include a copy of, or the URI for, + the Applicable License with every copy of each Adaptation You + Distribute or Publicly Perform; (II) You may not offer or impose any + terms on the Adaptation that restrict the terms of the Applicable + License or the ability of the recipient of the Adaptation to exercise + the rights granted to that recipient under the terms of the Applicable + License; (III) You must keep intact all notices that refer to the + Applicable License and to the disclaimer of warranties with every copy + of the Work as included in the Adaptation You Distribute or Publicly + Perform; (IV) when You Distribute or Publicly Perform the Adaptation, + You may not impose any effective technological measures on the + Adaptation that restrict the ability of a recipient of the Adaptation + from You to exercise the rights granted to that recipient under the + terms of the Applicable License. This Section 4(b) applies to the + Adaptation as incorporated in a Collection, but this does not require + the Collection apart from the Adaptation itself to be made subject to + the terms of the Applicable License. + c. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Ssection 3(b), in the case of an + Adaptation, a credit identifying the use of the Work in the Adaptation + (e.g., "French translation of the Work by Original Author," or + "Screenplay based on original Work by Original Author"). The credit + required by this Section 4(c) may be implemented in any reasonable + manner; provided, however, that in the case of a Adaptation or + Collection, at a minimum such credit will appear, if a credit for all + contributing authors of the Adaptation or Collection appears, then as + part of these credits and in a manner at least as prominent as the + credits for the other contributing authors. For the avoidance of + doubt, You may only use the credit required by this Section for the + purpose of attribution in the manner set out above and, by exercising + Your rights under this License, You may not implicitly or explicitly + assert or imply any connection with, sponsorship or endorsement by the + Original Author, Licensor and/or Attribution Parties, as appropriate, + of You or Your use of the Work, without the separate, express prior + written permission of the Original Author, Licensor and/or Attribution + Parties. + d. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of the License. + + Creative Commons may be contacted at https://creativecommons.org/. diff --git a/licenses/org.citationstyles.styles.txt b/licenses/org.citationstyles.styles.txt new file mode 100644 index 000000000000..604209a80463 --- /dev/null +++ b/licenses/org.citationstyles.styles.txt @@ -0,0 +1,359 @@ +Creative Commons Legal Code + +Attribution-ShareAlike 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined below) for the purposes of this + License. + c. "Creative Commons Compatible License" means a license that is listed + at https://creativecommons.org/compatiblelicenses that has been + approved by Creative Commons as being essentially equivalent to this + License, including, at a minimum, because that license: (i) contains + terms that have the same purpose, meaning and effect as the License + Elements of this License; and, (ii) explicitly permits the relicensing + of adaptations of works made available under that license under this + License or a Creative Commons jurisdiction license with the same + License Elements as this License. + d. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + e. "License Elements" means the following high-level license attributes + as selected by Licensor and indicated in the title of this License: + Attribution, ShareAlike. + f. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + g. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + h. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + i. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + j. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + k. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(c), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(c), as requested. + b. You may Distribute or Publicly Perform an Adaptation only under the + terms of: (i) this License; (ii) a later version of this License with + the same License Elements as this License; (iii) a Creative Commons + jurisdiction license (either this or a later license version) that + contains the same License Elements as this License (e.g., + Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible + License. If you license the Adaptation under one of the licenses + mentioned in (iv), you must comply with the terms of that license. If + you license the Adaptation under the terms of any of the licenses + mentioned in (i), (ii) or (iii) (the "Applicable License"), you must + comply with the terms of the Applicable License generally and the + following provisions: (I) You must include a copy of, or the URI for, + the Applicable License with every copy of each Adaptation You + Distribute or Publicly Perform; (II) You may not offer or impose any + terms on the Adaptation that restrict the terms of the Applicable + License or the ability of the recipient of the Adaptation to exercise + the rights granted to that recipient under the terms of the Applicable + License; (III) You must keep intact all notices that refer to the + Applicable License and to the disclaimer of warranties with every copy + of the Work as included in the Adaptation You Distribute or Publicly + Perform; (IV) when You Distribute or Publicly Perform the Adaptation, + You may not impose any effective technological measures on the + Adaptation that restrict the ability of a recipient of the Adaptation + from You to exercise the rights granted to that recipient under the + terms of the Applicable License. This Section 4(b) applies to the + Adaptation as incorporated in a Collection, but this does not require + the Collection apart from the Adaptation itself to be made subject to + the terms of the Applicable License. + c. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Ssection 3(b), in the case of an + Adaptation, a credit identifying the use of the Work in the Adaptation + (e.g., "French translation of the Work by Original Author," or + "Screenplay based on original Work by Original Author"). The credit + required by this Section 4(c) may be implemented in any reasonable + manner; provided, however, that in the case of a Adaptation or + Collection, at a minimum such credit will appear, if a credit for all + contributing authors of the Adaptation or Collection appears, then as + part of these credits and in a manner at least as prominent as the + credits for the other contributing authors. For the avoidance of + doubt, You may only use the credit required by this Section for the + purpose of attribution in the manner set out above and, by exercising + Your rights under this License, You may not implicitly or explicitly + assert or imply any connection with, sponsorship or endorsement by the + Original Author, Licensor and/or Attribution Parties, as appropriate, + of You or Your use of the Work, without the separate, express prior + written permission of the Original Author, Licensor and/or Attribution + Parties. + d. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of the License. + + Creative Commons may be contacted at https://creativecommons.org/. diff --git a/licenses/org.mozilla.rhino.txt b/licenses/org.mozilla.rhino.txt new file mode 100644 index 000000000000..cd6ebb83d755 --- /dev/null +++ b/licenses/org.mozilla.rhino.txt @@ -0,0 +1,375 @@ +The majority of Rhino is licensed under the MPL 2.0: + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/src/integrationTest/java/net/sf/jabref/gui/GUITest.java b/src/integrationTest/java/net/sf/jabref/gui/GUITest.java index 0416a9afbdf4..7aac5ed45ccc 100644 --- a/src/integrationTest/java/net/sf/jabref/gui/GUITest.java +++ b/src/integrationTest/java/net/sf/jabref/gui/GUITest.java @@ -83,8 +83,8 @@ public void testViewChanges() { mainFrame.menuItemWithPath("View", "Toggle entry preview").click(); mainFrame.menuItemWithPath("View", "Toggle entry preview").click(); - mainFrame.menuItemWithPath("View", "Switch preview layout").click(); - mainFrame.menuItemWithPath("View", "Switch preview layout").click(); + mainFrame.menuItemWithPath("View", "Next preview layout").click(); + mainFrame.menuItemWithPath("View", "Previous preview layout").click(); mainFrame.menuItemWithPath("View", "Hide/show toolbar").click(); mainFrame.menuItemWithPath("View", "Hide/show toolbar").click(); diff --git a/src/main/java/net/sf/jabref/collab/EntryAddChange.java b/src/main/java/net/sf/jabref/collab/EntryAddChange.java index f4dddb6085d9..a0a79a19061c 100644 --- a/src/main/java/net/sf/jabref/collab/EntryAddChange.java +++ b/src/main/java/net/sf/jabref/collab/EntryAddChange.java @@ -3,7 +3,6 @@ import javax.swing.JComponent; import javax.swing.JScrollPane; -import net.sf.jabref.Globals; import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.PreviewPanel; import net.sf.jabref.gui.undo.NamedCompound; @@ -12,7 +11,6 @@ import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.IdGenerator; -import net.sf.jabref.preferences.JabRefPreferences; class EntryAddChange extends Change { @@ -24,7 +22,7 @@ public EntryAddChange(BibEntry diskEntry) { super(Localization.lang("Added entry")); this.diskEntry = diskEntry; - PreviewPanel pp = new PreviewPanel(null, diskEntry, null, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); + PreviewPanel pp = new PreviewPanel(null, diskEntry, null); sp = new JScrollPane(pp); } diff --git a/src/main/java/net/sf/jabref/collab/EntryDeleteChange.java b/src/main/java/net/sf/jabref/collab/EntryDeleteChange.java index 5b925c3e8a2a..7d8a4223e9dc 100644 --- a/src/main/java/net/sf/jabref/collab/EntryDeleteChange.java +++ b/src/main/java/net/sf/jabref/collab/EntryDeleteChange.java @@ -3,7 +3,6 @@ import javax.swing.JComponent; import javax.swing.JScrollPane; -import net.sf.jabref.Globals; import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.PreviewPanel; import net.sf.jabref.gui.undo.NamedCompound; @@ -12,7 +11,6 @@ import net.sf.jabref.model.DuplicateCheck; import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,7 +39,7 @@ public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) { LOGGER.debug("Modified entry: " + memEntry.getCiteKeyOptional().orElse("") + "\n Modified locally: " + isModifiedLocally); - PreviewPanel pp = new PreviewPanel(null, memEntry, null, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); + PreviewPanel pp = new PreviewPanel(null, memEntry, null); sp = new JScrollPane(pp); } diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index f256630a9a53..9a4ab7b2fb74 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -94,6 +94,7 @@ import net.sf.jabref.logic.autocompleter.AutoCompleterFactory; import net.sf.jabref.logic.autocompleter.ContentAutoCompleters; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; +import net.sf.jabref.logic.citationstyle.CitationStyleCache; import net.sf.jabref.logic.exporter.BibtexDatabaseWriter; import net.sf.jabref.logic.exporter.FileSaveSession; import net.sf.jabref.logic.exporter.SaveException; @@ -124,6 +125,7 @@ import net.sf.jabref.model.entry.event.EntryEventSource; import net.sf.jabref.preferences.HighlightMatchingGroupPreferences; import net.sf.jabref.preferences.JabRefPreferences; +import net.sf.jabref.preferences.PreviewPreferences; import net.sf.jabref.shared.DBMSSynchronizer; import net.sf.jabref.specialfields.Printed; import net.sf.jabref.specialfields.Priority; @@ -151,12 +153,13 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe private final BibDatabaseContext bibDatabaseContext; private final MainTableDataModel tableModel; + private final CitationStyleCache citationStyleCache; + // To contain instantiated entry editors. This is to save time // As most enums, this must not be null private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING; private EntryEditor currentEditor; - private PreviewPanel currentPreview; private MainTableSelectionListener selectionListener; private ListEventListener groupsHighlightListener; @@ -220,6 +223,8 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { this.frame = frame; this.tableModel = new MainTableDataModel(getBibDatabaseContext()); + citationStyleCache = new CitationStyleCache(bibDatabaseContext); + setupMainPanel(); setupActions(); @@ -694,8 +699,13 @@ public void update() { } actions.put(Actions.TOGGLE_PREVIEW, (BaseAction) () -> { - boolean enabled = !Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED); - Globals.prefs.putBoolean(JabRefPreferences.PREVIEW_ENABLED, enabled); + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences(); + boolean enabled = !previewPreferences.isPreviewPanelEnabled(); + PreviewPreferences newPreviewPreferences = previewPreferences + .getBuilder() + .withPreviewPanelEnabled(enabled) + .build(); + Globals.prefs.storePreviewPreferences(newPreviewPreferences); setPreviewActiveBasePanels(enabled); frame.setPreviewToggle(enabled); }); @@ -718,7 +728,8 @@ public void update() { groupsHighlightListener.listChanged(null); }); - actions.put(Actions.SWITCH_PREVIEW, (BaseAction) selectionListener::switchPreview); + actions.put(Actions.NEXT_PREVIEW_STYLE, (BaseAction) selectionListener::nextPreviewStyle); + actions.put(Actions.PREVIOUS_PREVIEW_STYLE, (BaseAction) selectionListener::previousPreviewStyle); actions.put(Actions.MANAGE_SELECTORS, (BaseAction) () -> { ContentSelectorDialog2 csd = new ContentSelectorDialog2(frame, frame, BasePanel.this, false, null); @@ -1492,7 +1503,7 @@ public void setupMainPanel() { // otherwise set the bottom component to null. if (mode == BasePanelMode.SHOWING_PREVIEW) { mode = BasePanelMode.SHOWING_NOTHING; - highlightEntry(currentPreview.getEntry()); + highlightEntry(selectionListener.getPreview().getEntry()); } else if (mode == BasePanelMode.SHOWING_EDITOR) { mode = BasePanelMode.SHOWING_NOTHING; } else { @@ -1568,7 +1579,7 @@ public void updateStringDialog() { public void adjustSplitter() { if (mode == BasePanelMode.SHOWING_PREVIEW) { splitPane.setDividerLocation( - splitPane.getHeight() - Globals.prefs.getInt(JabRefPreferences.PREVIEW_PANEL_HEIGHT)); + splitPane.getHeight() - Globals.prefs.getPreviewPreferences().getPreviewPanelHeight()); } else { splitPane.setDividerLocation( splitPane.getHeight() - Globals.prefs.getInt(JabRefPreferences.ENTRY_EDITOR_HEIGHT)); @@ -1689,9 +1700,6 @@ public void showEntryEditor(EntryEditor editor) { if (mode == BasePanelMode.SHOWING_EDITOR) { Globals.prefs.putInt(JabRefPreferences.ENTRY_EDITOR_HEIGHT, splitPane.getHeight() - splitPane.getDividerLocation()); - } else if (mode == BasePanelMode.SHOWING_PREVIEW) { - Globals.prefs.putInt(JabRefPreferences.PREVIEW_PANEL_HEIGHT, - splitPane.getHeight() - splitPane.getDividerLocation()); } mode = BasePanelMode.SHOWING_EDITOR; currentEditor = editor; @@ -1709,8 +1717,8 @@ public void showEntryEditor(EntryEditor editor) { */ public void showPreview(PreviewPanel preview) { mode = BasePanelMode.SHOWING_PREVIEW; - currentPreview = preview; splitPane.setBottomComponent(preview); + adjustSplitter(); } /** @@ -1775,7 +1783,7 @@ public void entryEditorClosing(EntryEditor editor) { */ public void ensureNotShowingBottomPanel(BibEntry entry) { if (((mode == BasePanelMode.SHOWING_EDITOR) && (currentEditor.getEntry() == entry)) - || ((mode == BasePanelMode.SHOWING_PREVIEW) && (currentPreview.getEntry() == entry))) { + || ((mode == BasePanelMode.SHOWING_PREVIEW) && (selectionListener.getPreview().getEntry() == entry))) { hideBottomComponent(); } } @@ -1984,8 +1992,12 @@ private void setPreviewActive(boolean enabled) { */ public void saveDividerLocation() { if (mode == BasePanelMode.SHOWING_PREVIEW) { - Globals.prefs.putInt(JabRefPreferences.PREVIEW_PANEL_HEIGHT, - splitPane.getHeight() - splitPane.getDividerLocation()); + int previewPanelHeight = splitPane.getHeight() - splitPane.getDividerLocation(); + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences() + .getBuilder() + .withPreviewPanelHeight(previewPanelHeight) + .build(); + Globals.prefs.storePreviewPreferences(previewPreferences); } else if (mode == BasePanelMode.SHOWING_EDITOR) { Globals.prefs.putInt(JabRefPreferences.ENTRY_EDITOR_HEIGHT, splitPane.getHeight() - splitPane.getDividerLocation()); @@ -2100,11 +2112,9 @@ private class PrintPreviewAction implements BaseAction { @Override public void action() throws Exception { - if (currentPreview == null) { - selectionListener.setPreviewActive(true); - showPreview(selectionListener.getPreview()); - } - currentPreview.getPrintAction().actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null)); + selectionListener.setPreviewActive(true); + showPreview(selectionListener.getPreview()); + selectionListener.getPreview().getPrintAction().actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null)); } } @@ -2453,4 +2463,17 @@ public SearchQuery getCurrentSearchQuery() { public void setCurrentSearchQuery(SearchQuery currentSearchQuery) { this.currentSearchQuery = currentSearchQuery; } + + public CitationStyleCache getCitationStyleCache() { + return citationStyleCache; + } + + public PreviewPanel getPreviewPanel() { + if (selectionListener == null) { + // only occurs if this is called while instantiating this BasePanel + return null; + } + return selectionListener.getPreview(); + } + } diff --git a/src/main/java/net/sf/jabref/gui/FileDialog.java b/src/main/java/net/sf/jabref/gui/FileDialog.java index 238d70300283..c1d24ebf4f5b 100644 --- a/src/main/java/net/sf/jabref/gui/FileDialog.java +++ b/src/main/java/net/sf/jabref/gui/FileDialog.java @@ -1,5 +1,6 @@ package net.sf.jabref.gui; +import java.awt.Component; import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; @@ -13,7 +14,6 @@ import java.util.stream.Collectors; import javax.swing.JFileChooser; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; @@ -55,7 +55,7 @@ public void approveSelection() { } }; - private final JFrame parent; + private final Component parent; private final String directory; private Collection extensions = EnumSet.noneOf(FileExtensions.class); @@ -63,7 +63,7 @@ public void approveSelection() { * Creates a new filedialog showing the current working dir {@link JabRefPreferences#WORKING_DIRECTORY} * @param parent The parent frame associated with this dialog */ - public FileDialog(JFrame parent) { + public FileDialog(Component parent) { this(parent, getWorkingDir()); } @@ -72,7 +72,7 @@ public FileDialog(JFrame parent) { * @param parent The parent frame associated with this dialog * @param dir The starting directory to show in the dialog */ - public FileDialog(JFrame parent, String dir) { + public FileDialog(Component parent, String dir) { Objects.requireNonNull(dir, "Directory must not be null"); this.parent = parent; diff --git a/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java index eed57f975ac9..7d4a8d13720f 100644 --- a/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java +++ b/src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java @@ -1024,7 +1024,8 @@ private void createEntryTypesCombobox() { Iterator iterator = EntryTypes .getAllValues(frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).iterator(); Vector list = new Vector<>(); - list.add(new BibtexEntryTypeWrapper(null)); + list.add( + new BibtexEntryTypeWrapper(null)); while (iterator.hasNext()) { list.add(new BibtexEntryTypeWrapper(iterator.next())); } diff --git a/src/main/java/net/sf/jabref/gui/JabRefFrame.java b/src/main/java/net/sf/jabref/gui/JabRefFrame.java index 8a9401241c68..d83930c70683 100644 --- a/src/main/java/net/sf/jabref/gui/JabRefFrame.java +++ b/src/main/java/net/sf/jabref/gui/JabRefFrame.java @@ -376,9 +376,12 @@ public void actionPerformed(ActionEvent e) { Localization.lang("Disable highlight groups matching entries"))); - private final AbstractAction switchPreview = new GeneralAction(Actions.SWITCH_PREVIEW, - Localization.menuTitle("Switch preview layout"), - Globals.getKeyPrefs().getKey(KeyBinding.SWITCH_PREVIEW_LAYOUT)); + private final AbstractAction nextPreviewStyle = new GeneralAction(Actions.NEXT_PREVIEW_STYLE, + Localization.menuTitle("Next preview layout"), + Globals.getKeyPrefs().getKey(KeyBinding.NEXT_PREVIEW_LAYOUT)); + private final AbstractAction previousPreviewStyle = new GeneralAction(Actions.PREVIOUS_PREVIEW_STYLE, + Localization.menuTitle("Previous preview layout"), + Globals.getKeyPrefs().getKey(KeyBinding.PREVIOUS_PREVIEW_LAYOUT)); private final AbstractAction makeKeyAction = new GeneralAction(Actions.MAKE_KEY, Localization.menuTitle("Autogenerate BibTeX keys"), Localization.lang("Autogenerate BibTeX keys"), @@ -658,8 +661,10 @@ public void windowClosing(WindowEvent e) { globalSearchBar.setSearchTerm(content, true); } + currentBasePanel.getPreviewPanel().updateLayout(); + groupToggle.setSelected(sidePaneManager.isComponentVisible("groups")); - previewToggle.setSelected(Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED)); + previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()); fetcherToggle.setSelected(sidePaneManager.isComponentVisible(generalFetcher.getTitle())); Globals.getFocusListener().setFocused(currentBasePanel.getMainTable()); setWindowTitle(); @@ -1273,7 +1278,8 @@ private void fillMenu() { view.add(new JCheckBoxMenuItem(enableToggle(generalFetcher.getAction()))); view.add(new JCheckBoxMenuItem(toggleGroups)); view.add(new JCheckBoxMenuItem(togglePreview)); - view.add(getSwitchPreviewAction()); + view.add(getNextPreviewStyleAction()); + view.add(getPreviousPreviewStyleAction()); mb.add(view); @@ -1513,7 +1519,7 @@ private void initActions() { sendAsEmail, downloadFullText, writeXmpAction, optMenuItem, findUnlinkedFiles, addToGroup, removeFromGroup, moveToGroup, autoLinkFile, resolveDuplicateKeys, openUrl, openFolder, openFile, togglePreview, dupliCheck, autoSetFile, newEntryAction, newSpec, customizeAction, plainTextImport, getMassSetField(), getManageKeywords(), - pushExternalButton.getMenuAction(), closeDatabaseAction, getSwitchPreviewAction(), checkIntegrity, + pushExternalButton.getMenuAction(), closeDatabaseAction, getNextPreviewStyleAction(), getPreviousPreviewStyleAction(), checkIntegrity, toggleHighlightAny, toggleHighlightAll, toggleHighlightDisable, databaseProperties, abbreviateIso, abbreviateMedline, unabbreviate, exportAll, exportSelected, importCurrent, saveAll, focusTable, increaseFontSize, decreseFontSize, toggleRelevance, toggleQualityAssured, togglePrinted, pushExternalButton.getComponent())); @@ -2310,8 +2316,12 @@ public AbstractAction getBackAction() { return back; } - public AbstractAction getSwitchPreviewAction() { - return switchPreview; + public AbstractAction getNextPreviewStyleAction() { + return nextPreviewStyle; + } + + public AbstractAction getPreviousPreviewStyleAction() { + return previousPreviewStyle; } public JSplitPane getSplitPane() { diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index c4fa0c95e974..6183bc827d89 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -7,7 +7,6 @@ import java.awt.print.PrinterException; import java.io.IOException; import java.io.StringReader; -import java.util.Objects; import java.util.Optional; import java.util.regex.Pattern; @@ -33,6 +32,8 @@ import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.gui.fieldeditors.PreviewPanelTransferHandler; import net.sf.jabref.gui.keyboard.KeyBinding; +import net.sf.jabref.gui.worker.CitationStyleWorker; +import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.exporter.ExportFormats; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.layout.Layout; @@ -42,6 +43,7 @@ import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.event.FieldChangedEvent; +import net.sf.jabref.preferences.PreviewPreferences; import com.google.common.eventbus.Subscribe; import org.apache.commons.logging.Log; @@ -50,8 +52,7 @@ /** * Displays an BibEntry using the given layout format. */ -public class PreviewPanel extends JPanel - implements SearchQueryHighlightListener, EntryContainer { +public class PreviewPanel extends JPanel implements SearchQueryHighlightListener, EntryContainer { private static final Log LOGGER = LogFactory.getLog(PreviewPanel.class); @@ -66,26 +67,20 @@ public class PreviewPanel extends JPanel */ private Optional databaseContext = Optional.empty(); - private Optional layout = Optional.empty(); - - /** - * must not be null, must always be set during constructor, but can change over time - */ - private String layoutFile; - - private final Optional basePanel; + private Optional basePanel = Optional.empty(); + private boolean fixedLayout; + private Optional layout = Optional.empty(); private JEditorPane previewPane; private final JScrollPane scrollPane; - private final PrintAction printAction; - - private final CloseAction closeAction; - - private final CopyPreviewAction copyPreviewAction; + private final PrintAction printAction = new PrintAction(); + private final CloseAction closeAction = new CloseAction(); + private final CopyPreviewAction copyPreviewAction = new CopyPreviewAction(); private Optional highlightPattern = Optional.empty(); + private Optional citationStyleWorker = Optional.empty(); /** * @param databaseContext @@ -96,12 +91,9 @@ public class PreviewPanel extends JPanel * @param panel * (may be null) If not given no toolbar is shown on the right * hand side. - * @param layoutFile - * (must be given) Used for layout */ - public PreviewPanel(BibDatabaseContext databaseContext, BibEntry entry, - BasePanel panel, String layoutFile) { - this(panel, databaseContext, layoutFile); + public PreviewPanel(BibDatabaseContext databaseContext, BibEntry entry, BasePanel panel) { + this(panel, databaseContext); setEntry(entry); } @@ -112,25 +104,17 @@ public PreviewPanel(BibDatabaseContext databaseContext, BibEntry entry, * hand side. * @param databaseContext * (may be null) Used for resolving pdf directories for links. - * @param layoutFile - * (must be given) Used for layout */ - public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, String layoutFile) { + public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext) { super(new BorderLayout(), true); this.databaseContext = Optional.ofNullable(databaseContext); - this.layoutFile = Objects.requireNonNull(layoutFile); - updateLayout(); - - this.closeAction = new CloseAction(); - this.printAction = new PrintAction(); - this.copyPreviewAction = new CopyPreviewAction(); - this.basePanel = Optional.ofNullable(panel); createPreviewPane(); + updateLayout(); - if (panel != null) { + if (this.basePanel.isPresent()) { // dropped files handler only created for main window // not for Windows as like the search results window this.previewPane.setTransferHandler(new PreviewPanelTransferHandler(panel.frame(), this, this.previewPane.getTransferHandler())); @@ -142,7 +126,6 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, String ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); - add(scrollPane, BorderLayout.CENTER); this.createKeyBindings(); @@ -165,7 +148,8 @@ private JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); menu.add(this.printAction); menu.add(this.copyPreviewAction); - this.basePanel.ifPresent(p -> menu.add(p.frame().getSwitchPreviewAction())); + this.basePanel.ifPresent(p -> menu.add(p.frame().getNextPreviewStyleAction())); + this.basePanel.ifPresent(p -> menu.add(p.frame().getPreviousPreviewStyleAction())); return menu; } @@ -202,12 +186,43 @@ public void setDatabaseContext(BibDatabaseContext databaseContext) { this.databaseContext = Optional.ofNullable(databaseContext); } - public void updateLayout(String layoutFormat) { - layoutFile = layoutFormat; - updateLayout(); + public Optional getBasePanel() { + return this.basePanel; + } + + public void setBasePanel(BasePanel basePanel) { + this.basePanel = Optional.ofNullable(basePanel); } - private void updateLayout() { + public void updateLayout() { + if (fixedLayout) { + LOGGER.debug("cannot change the layout because the layout is fixed"); + return; + } + + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences(); + String style = previewPreferences.getPreviewCycle().get(previewPreferences.getPreviewCyclePosition()); + + if (CitationStyle.isCitationStyleFile(style)) { + if (basePanel.isPresent()) { + layout = Optional.empty(); + CitationStyle citationStyle = CitationStyle.createCitationStyleFromFile(style); + if (citationStyle != null) { + basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); + basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); + } + } + } else { + updatePreviewLayout(previewPreferences.getPreviewStyle()); + if (basePanel.isPresent()) { + basePanel.get().output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))); + } + } + + update(); + } + + private void updatePreviewLayout(String layoutFile){ StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); try { layout = Optional.of( @@ -229,7 +244,6 @@ public void setEntry(BibEntry newEntry) { bibEntry = Optional.ofNullable(newEntry); bibEntry.ifPresent(e -> e.registerListener(this)); - updateLayout(); update(); } @@ -249,26 +263,36 @@ public BibEntry getEntry() { } public void update() { - StringBuilder sb = new StringBuilder(); ExportFormats.entryNumber = 1; // Set entry number in case that is included in the preview layout. - bibEntry.ifPresent(entry -> - layout.ifPresent(acutalLayout -> sb.append(acutalLayout - .doLayout(entry, databaseContext.map(BibDatabaseContext::getDatabase).orElse(null), - highlightPattern))) - ); - String newValue = sb.toString(); + if (citationStyleWorker.isPresent()){ + citationStyleWorker.get().cancel(true); + citationStyleWorker = Optional.empty(); + } + + if (layout.isPresent()){ + StringBuilder sb = new StringBuilder(); + bibEntry.ifPresent(entry -> sb.append(layout.get() + .doLayout(entry, databaseContext.map(BibDatabaseContext::getDatabase).orElse(null), highlightPattern))); + setPreviewLabel(sb.toString()); + } + else if (basePanel.isPresent()){ + citationStyleWorker = Optional.of(new CitationStyleWorker(this, previewPane)); + citationStyleWorker.get().execute(); + } + } + + public void setPreviewLabel(String text) { if (SwingUtilities.isEventDispatchThread()) { - previewPane.setText(newValue); + previewPane.setText(text); previewPane.revalidate(); } else { SwingUtilities.invokeLater(() -> { - previewPane.setText(newValue); + previewPane.setText(text); previewPane.revalidate(); }); } - // Scroll to top: - scrollToTop(); + this.scrollToTop(); } private void scrollToTop() { @@ -281,6 +305,31 @@ public void highlightPattern(Optional newPattern) { update(); } + public Optional getHighlightPattern() { + return highlightPattern; + } + + /** + * this fixes the Layout, the user cannot change it anymore. Useful for testing the styles in the settings + * @param parameter should be either a {@link String} (for the old PreviewStyle) or a {@link CitationStyle}. + */ + public PreviewPanel setFixedLayout(Object parameter) { + this.fixedLayout = true; + + if (parameter instanceof String) { + updatePreviewLayout((String) parameter); + } else if (parameter instanceof CitationStyle) { + layout = Optional.empty(); + if (basePanel.isPresent()){ + basePanel.get().getCitationStyleCache().setCitationStyle((CitationStyle) parameter); + } + } else { + LOGGER.error("unknown style type"); + } + update(); + return this; + } + class PrintAction extends AbstractAction { public PrintAction() { super(Localization.lang("Print entry preview"), IconTheme.JabRefIcon.PRINTED.getIcon()); diff --git a/src/main/java/net/sf/jabref/gui/actions/Actions.java b/src/main/java/net/sf/jabref/gui/actions/Actions.java index 8be2aa07949e..76958d38d096 100644 --- a/src/main/java/net/sf/jabref/gui/actions/Actions.java +++ b/src/main/java/net/sf/jabref/gui/actions/Actions.java @@ -33,6 +33,7 @@ public class Actions { public static final String MERGE_DATABASE = "mergeDatabase"; public static final String MERGE_ENTRIES = "mergeEntries"; public static final String MERGE_WITH_FETCHED_ENTRY = "mergeWithFetchedEntry"; + public static final String NEXT_PREVIEW_STYLE = "nextPreviewStyle"; public static final String MOVE_TO_GROUP = "moveToGroup"; public static final String OPEN_CONSOLE = "openConsole"; public static final String OPEN_EXTERNAL_FILE = "openExternalFile"; @@ -40,6 +41,7 @@ public class Actions { public static final String OPEN_URL = "openUrl"; public static final String PASTE = "paste"; public static final String PLAIN_TEXT_IMPORT = "plainTextImport"; + public static final String PREVIOUS_PREVIEW_STYLE = "previousPreviewStyle"; public static final String PULL_CHANGES_FROM_SHARED_DATABASE = "pullChangesFromSharedDatabase"; public static final String REDO = "redo"; public static final String REMOVE_FROM_GROUP = "removeFromGroup"; @@ -53,7 +55,6 @@ public class Actions { public static final String GLOBAL_SEARCH = "globalSearch"; public static final String SELECT_ALL = "selectAll"; public static final String SEND_AS_EMAIL = "sendAsEmail"; - public static final String SWITCH_PREVIEW = "switchPreview"; public static final String TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ALL = "toggleHighlightGroupsMatchingAll"; public static final String TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ANY = "toggleHighlightGroupsMatchingAny"; public static final String TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_DISABLE = "toggleHighlightGroupsMatchingDisable"; diff --git a/src/main/java/net/sf/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java b/src/main/java/net/sf/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java index 926438bb068e..d8dcbfd6e04b 100644 --- a/src/main/java/net/sf/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java +++ b/src/main/java/net/sf/jabref/gui/bibtexkeypattern/ResolveDuplicateLabelDialog.java @@ -38,19 +38,6 @@ class ResolveDuplicateLabelDialog { private boolean okPressed; private boolean cancelPressed; - private static final String LAYOUT = "\\entrytype\\begin{bibtexkey} (\\bibtexkey)\\end{bibtexkey}
\n" - + "\\begin{author} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\author}
\\end{author}\n" - + "\\begin{editor} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}\n" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
\n" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}\n" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}\n" - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}\n" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}\n" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}\n" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}\n" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}\n" - + "

"; - public ResolveDuplicateLabelDialog(BasePanel panel, String key, List entries) { diag = new JDialog(panel.frame(), Localization.lang("Duplicate BibTeX key"), true); @@ -66,7 +53,7 @@ public ResolveDuplicateLabelDialog(BasePanel panel, String key, List e JCheckBox cb = new JCheckBox(Localization.lang("Generate BibTeX key"), !first); b.appendRows("1dlu, p"); b.add(cb).xy(1, row); - PreviewPanel pp = new PreviewPanel(null, entry, null, ResolveDuplicateLabelDialog.LAYOUT); + PreviewPanel pp = new PreviewPanel(null, entry, null); pp.setPreferredSize(new Dimension(800, 90)); b.add(new JScrollPane(pp)).xy(3, row); row += 2; diff --git a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java index 69ace5e336d0..e9586abdd17c 100644 --- a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java +++ b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java @@ -199,7 +199,7 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoNam this.undoName = undoName; this.newDatabase = newDatabase; setIconImage(new ImageIcon(IconTheme.getIconUrl("jabrefIcon48")).getImage()); - preview = new PreviewPanel(null, bibDatabaseContext, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); + preview = new PreviewPanel(panel, bibDatabaseContext); duplLabel.setToolTipText(Localization.lang("Possible duplicate of existing entry. Click to resolve.")); diff --git a/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java b/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java index d20b893e881f..e3ecae78394b 100644 --- a/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java @@ -55,6 +55,7 @@ public enum KeyBinding { NEW_PROCEEDINGS("New proceedings", Localization.lang("New proceedings"), "ctrl shift P"), NEW_UNPUBLISHED("New unpublished", Localization.lang("New unpublished"), "ctrl shift U"), NEW_TECHREPORT("New technical report", Localization.lang("New technical report"), "ctrl shift R"), + NEXT_PREVIEW_LAYOUT("Next preview layout", Localization.lang("Next preview layout"), "F9"), NEXT_TAB("Next tab", Localization.lang("Next tab"), "ctrl PAGE_DOWN"), OPEN_CONSOLE("Open terminal here", Localization.lang("Open terminal here"), "ctrl shift L"), OPEN_DATABASE("Open database", Localization.lang("Open database"), "ctrl O"), @@ -64,6 +65,7 @@ public enum KeyBinding { PASTE("Paste", Localization.lang("Paste"), "ctrl V"), PULL_CHANGES_FROM_SHARED_DATABASE("Pull changes from shared database", Localization.lang("Pull changes from shared database"), "ctrl shift R"), PREAMBLE_EDITOR_STORE_CHANGES("Preamble editor, store changes", Localization.lang("Preamble editor, store changes"), "alt S"), + PREVIOUS_PREVIEW_LAYOUT("Previous preview layout", Localization.lang("Previous preview layout"), "shift F9"), PREVIOUS_TAB("Previous tab", Localization.lang("Previous tab"), "ctrl PAGE_UP"), PUSH_TO_APPLICATION("Push to application", Localization.lang("Push to application"), "ctrl L"), QUIT_JABREF("Quit JabRef", Localization.lang("Quit JabRef"), "ctrl Q"), @@ -82,7 +84,6 @@ public enum KeyBinding { SELECT_LAST_ENTRY("Select last entry", Localization.lang("Select last entry"), "END"), STRING_DIALOG_ADD_STRING("String dialog, add string", Localization.lang("String dialog, add string"), "ctrl N"), STRING_DIALOG_REMOVE_STRING("String dialog, remove string", Localization.lang("String dialog, remove string"), "shift DELETE"), - SWITCH_PREVIEW_LAYOUT("Switch preview layout", Localization.lang("Switch preview layout"), "F9"), SYNCHRONIZE_FILES("Synchronize files", Localization.lang("Synchronize files"), "ctrl shift F7"), TOGGLE_ENTRY_PREVIEW("Toggle entry preview", Localization.lang("Toggle entry preview"), "alt 2"), TOGGLE_GROUPS_INTERFACE("Toggle groups interface", Localization.lang("Toggle groups interface"), "alt 3"), diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java index e0dc3d92beba..5ccf05c84380 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableSelectionListener.java @@ -36,7 +36,7 @@ import net.sf.jabref.logic.util.OS; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.FieldName; -import net.sf.jabref.preferences.JabRefPreferences; +import net.sf.jabref.preferences.PreviewPreferences; import net.sf.jabref.specialfields.SpecialFieldValue; import net.sf.jabref.specialfields.SpecialFieldsUtils; @@ -53,14 +53,12 @@ public class MainTableSelectionListener implements ListEventListener, MouseListener, KeyListener, FocusListener { - private final PreviewPanel[] previewPanel; private final MainTable table; private final BasePanel panel; private final EventList tableRows; - private int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW); private PreviewPanel preview; - private boolean previewActive = Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED); + private boolean previewActive = Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled(); private boolean workingOnPreview; private boolean enabled = true; @@ -78,28 +76,19 @@ public MainTableSelectionListener(BasePanel panel, MainTable table) { this.table = table; this.panel = panel; this.tableRows = table.getTableModel().getTableRows(); - previewPanel = new PreviewPanel[] { - new PreviewPanel(panel.getBibDatabaseContext(), null, panel, - Globals.prefs.get(JabRefPreferences.PREVIEW_0)), - new PreviewPanel(panel.getBibDatabaseContext(), null, panel, - Globals.prefs.get(JabRefPreferences.PREVIEW_1))}; - - panel.frame().getGlobalSearchBar().getSearchQueryHighlightObservable() - .addSearchListener(previewPanel[0]) - .addSearchListener(previewPanel[1]); - - this.preview = previewPanel[activePreview]; + PreviewPanel previewPanel = panel.getPreviewPanel(); + if (previewPanel != null){ + preview = previewPanel; + } else { + preview = new PreviewPanel(panel.getBibDatabaseContext(), null, panel); + panel.frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview); + } } public void setEnabled(boolean enabled) { this.enabled = enabled; } - public void updatePreviews() { - previewPanel[0].updateLayout(Globals.prefs.get(JabRefPreferences.PREVIEW_0)); - previewPanel[1].updateLayout(Globals.prefs.get(JabRefPreferences.PREVIEW_1)); - } - @Override public void listChanged(ListEvent e) { if (!enabled) { @@ -462,19 +451,26 @@ public void setPreviewActive(boolean enabled) { } } - public void switchPreview() { - if (activePreview < (previewPanel.length - 1)) { - activePreview++; - } else { - activePreview = 0; - } - Globals.prefs.putInt(JabRefPreferences.ACTIVE_PREVIEW, activePreview); - if (previewActive) { - this.preview = previewPanel[activePreview]; + public void nextPreviewStyle(){ + cyclePreview(Globals.prefs.getPreviewPreferences().getPreviewCyclePosition() + 1); + } - if (!table.getSelected().isEmpty()) { - updatePreview(table.getSelected().get(0), true); - } + public void previousPreviewStyle(){ + cyclePreview(Globals.prefs.getPreviewPreferences().getPreviewCyclePosition() - 1); + } + + private void cyclePreview(int newPosition) { + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences() + .getBuilder() + .withPreviewCyclePosition(newPosition) + .build(); + Globals.prefs.storePreviewPreferences(previewPreferences); + + preview.updateLayout(); + preview.update(); + panel.showPreview(preview); + if (!table.getSelected().isEmpty()) { + updatePreview(table.getSelected().get(0), true); } } diff --git a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java index c4d078addcd0..8e7c9a7fc6c6 100644 --- a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java +++ b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java @@ -179,7 +179,7 @@ private void initialize() { // Setup a PreviewPanel and a Bibtex source box for the merged entry mainPanel.add(boldFontLabel(Localization.lang("Merged entry")), CELL_CONSTRAINTS.xyw(1, 6, 6)); - entryPreview = new PreviewPanel(null, mergedEntry, null, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); + entryPreview = new PreviewPanel(null, mergedEntry, null); mainPanel.add(entryPreview, CELL_CONSTRAINTS.xyw(1, 8, 6)); mainPanel.add(boldFontLabel(Localization.lang("Merged BibTeX source code")), CELL_CONSTRAINTS.xyw(8, 6, 4)); diff --git a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java index c2c7c2a1ca01..47253c859d29 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java @@ -134,7 +134,7 @@ private void init() { // Create a preview panel for previewing styles // Must be done before creating the table to avoid NPEs - preview = new PreviewPanel(null, null, ""); + preview = new PreviewPanel(null, null); // Use the test entry from the Preview settings tab in Preferences: preview.setEntry(prevEntry); diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java index b8846baa33aa..b4deeb113d87 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java @@ -92,7 +92,7 @@ public PreferencesDialog(JabRefFrame parent) { tabs.add(new TablePrefsTab(prefs)); tabs.add(new TableColumnsTab(prefs, parent)); tabs.add(new BibtexKeyPatternPrefTab(prefs, parent.getCurrentBasePanel())); - tabs.add(new PreviewPrefsTab(prefs)); + tabs.add(new PreviewPrefsTab()); tabs.add(new NameFormatterTab(prefs)); tabs.add(new ImportSettingsTab(prefs)); tabs.add(new XmpPrefsTab(prefs)); diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java index 4f2a8a1680cd..38bdaf180582 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java @@ -1,186 +1,258 @@ package net.sf.jabref.gui.preftabs; +import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.swing.BoxLayout; +import javax.swing.DefaultListModel; import javax.swing.JButton; -import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSeparator; import javax.swing.JTextArea; -import javax.swing.SwingConstants; +import javax.swing.ListSelectionModel; +import javax.swing.SwingWorker; +import net.sf.jabref.Globals; +import net.sf.jabref.JabRefGUI; +import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.PreviewPanel; +import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.TestEntry; -import net.sf.jabref.preferences.JabRefPreferences; +import net.sf.jabref.preferences.PreviewPreferences; +import com.jgoodies.forms.builder.FormBuilder; +import com.jgoodies.forms.factories.Paddings; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -class PreviewPrefsTab extends JPanel implements PrefsTab { - - private static final Log LOGGER = LogFactory.getLog(PrefsTab.class); - - private final JabRefPreferences prefs; - - private final JTextArea layout1 = new JTextArea("", 1, 1); - private final JTextArea layout2 = new JTextArea("", 1, 1); - - private final JButton testButton = new JButton(Localization.lang("Test")); - private final JButton defaultButton = new JButton(Localization.lang("Default")); - private final JButton testButton2 = new JButton(Localization.lang("Test")); - private final JButton defaultButton2 = new JButton(Localization.lang("Default")); - - private final JPanel firstPanel = new JPanel(); - private final JScrollPane firstScrollPane = new JScrollPane(layout1); - - private final JPanel secondPanel = new JPanel(); - private final JScrollPane secondScrollPane = new JScrollPane(layout2); - - - public PreviewPrefsTab(JabRefPreferences prefs) { - this.prefs = prefs; - - GridBagLayout layout = new GridBagLayout(); - firstPanel.setLayout(layout); - secondPanel.setLayout(layout); - - setLayout(layout); - JLabel lab = new JLabel(Localization.lang("Preview") + " 1"); - GridBagConstraints layoutConstraints = new GridBagConstraints(); - layoutConstraints.anchor = GridBagConstraints.WEST; - layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; - layoutConstraints.fill = GridBagConstraints.BOTH; - layoutConstraints.weightx = 1; - layoutConstraints.weighty = 0; - layoutConstraints.insets = new Insets(2, 2, 2, 2); - layout.setConstraints(lab, layoutConstraints); - layoutConstraints.weighty = 1; - layout.setConstraints(firstScrollPane, layoutConstraints); - firstPanel.add(firstScrollPane); - layoutConstraints.weighty = 0; - layoutConstraints.gridwidth = 1; - layoutConstraints.weightx = 0; - layoutConstraints.fill = GridBagConstraints.NONE; - layoutConstraints.anchor = GridBagConstraints.WEST; - layout.setConstraints(testButton, layoutConstraints); - firstPanel.add(testButton); - layout.setConstraints(defaultButton, layoutConstraints); - firstPanel.add(defaultButton); - layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; - JPanel newPan = new JPanel(); - layoutConstraints.weightx = 1; - layout.setConstraints(newPan, layoutConstraints); - firstPanel.add(newPan); - lab = new JLabel(Localization.lang("Preview") + " 2"); - layout.setConstraints(lab, layoutConstraints); - // p2.add(lab); - layoutConstraints.weighty = 1; - layoutConstraints.fill = GridBagConstraints.BOTH; - layout.setConstraints(secondScrollPane, layoutConstraints); - secondPanel.add(secondScrollPane); - layoutConstraints.weighty = 0; - layoutConstraints.weightx = 0; - layoutConstraints.fill = GridBagConstraints.NONE; - layoutConstraints.gridwidth = 1; - layout.setConstraints(testButton2, layoutConstraints); - secondPanel.add(testButton2); - layout.setConstraints(defaultButton2, layoutConstraints); - secondPanel.add(defaultButton2); - layoutConstraints.gridwidth = 1; - newPan = new JPanel(); - layoutConstraints.weightx = 1; - layout.setConstraints(newPan, layoutConstraints); - secondPanel.add(newPan); - - layoutConstraints.weightx = 1; - layoutConstraints.weighty = 0; - layoutConstraints.fill = GridBagConstraints.BOTH; - layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; - lab = new JLabel(Localization.lang("Preview") + " 1"); - layout.setConstraints(lab, layoutConstraints); - add(lab); - layoutConstraints.weighty = 1; - layout.setConstraints(firstPanel, layoutConstraints); - add(firstPanel); - lab = new JLabel(Localization.lang("Preview") + " 2"); - layoutConstraints.weighty = 0; - JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL); - layout.setConstraints(sep, layoutConstraints); - add(sep); - layout.setConstraints(lab, layoutConstraints); - add(lab); - layoutConstraints.weighty = 1; - layout.setConstraints(secondPanel, layoutConstraints); - add(secondPanel); - layoutConstraints.weighty = 0; - - defaultButton.addActionListener(e -> { - String tmp = layout1.getText().replace("\n", "__NEWLINE__"); - PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_0); - layout1.setText(PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_0).replace("__NEWLINE__", "\n")); - PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_0, tmp); + +public class PreviewPrefsTab extends JPanel implements PrefsTab { + + private static final Log LOGGER = LogFactory.getLog(PreviewPrefsTab.class); + + private SwingWorker, Void> discoverCitationStyleWorker; + + private final DefaultListModel availableModel = new DefaultListModel<>(); + private final DefaultListModel chosenModel = new DefaultListModel<>(); + + private final JList available = new JList<>(availableModel); + private final JList chosen = new JList<>(chosenModel); + + private final JButton btnRight = new JButton("»"); + private final JButton btnLeft = new JButton("«"); + private final JButton btnUp = new JButton(Localization.lang("Up")); + private final JButton btnDown = new JButton(Localization.lang("Down")); + + + private final JTextArea layout = new JTextArea("", 1, 1); + private final JButton btnTest = new JButton(Localization.lang("Test")); + private final JButton btnDefault = new JButton(Localization.lang("Default")); + private final JScrollPane scrollPane = new JScrollPane(layout); + + + public PreviewPrefsTab() { + setupLogic(); + setupGui(); + } + + private void setupLogic(){ + chosen.getSelectionModel().addListSelectionListener(event -> { + boolean selectionEmpty = ((ListSelectionModel) event.getSource()).isSelectionEmpty(); + btnLeft.setEnabled(!selectionEmpty); + btnDown.setEnabled(!selectionEmpty); + btnUp.setEnabled(!selectionEmpty); }); - defaultButton2.addActionListener(e -> { - String tmp = layout2.getText().replace("\n", "__NEWLINE__"); - PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_1); - layout2.setText(PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_1).replace("__NEWLINE__", "\n")); - PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_1, tmp); + available.getSelectionModel() + .addListSelectionListener(e -> btnRight.setEnabled(!((ListSelectionModel) e.getSource()).isSelectionEmpty())); + + btnRight.addActionListener(event -> { + for (Object object : available.getSelectedValuesList()) { + availableModel.removeElement(object); + chosenModel.addElement(object); + } }); - testButton.addActionListener(e -> { - try { - PreviewPanel testPanel = new PreviewPanel(null, TestEntry.getTestEntry(), null, layout1.getText()); - testPanel.setPreferredSize(new Dimension(800, 350)); - JOptionPane.showMessageDialog(null, testPanel, Localization.lang("Preview"), JOptionPane.PLAIN_MESSAGE); - } catch (StringIndexOutOfBoundsException ex) { - LOGGER.warn("Parsing error.", ex); - JOptionPane.showMessageDialog(null, - Localization.lang("Parsing error") + ": " + Localization.lang("illegal backslash expression") - + ".\n" + ex.getMessage(), - Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE); + btnLeft.addActionListener(event -> { + for (Object object : chosen.getSelectedValuesList()) { + availableModel.addElement(object); + chosenModel.removeElement(object); } }); - testButton2.addActionListener(e -> { + btnUp.addActionListener(event -> { + List newSelectedIndices = new ArrayList<>(); + for (int oldIndex : chosen.getSelectedIndices()) { + boolean alreadyTaken = newSelectedIndices.contains(oldIndex - 1); + int newIndex = (oldIndex > 0 && !alreadyTaken) ? oldIndex - 1 : oldIndex; + chosenModel.add(newIndex, chosenModel.remove(oldIndex)); + newSelectedIndices.add(newIndex); + } + chosen.setSelectedIndices(ArrayUtils.toPrimitive(newSelectedIndices.toArray(new Integer[newSelectedIndices.size()]))); + }); + + btnDown.addActionListener(event -> { + List newSelectedIndices = new ArrayList<>(); + int[] selectedIndices = chosen.getSelectedIndices(); + for (int i = selectedIndices.length - 1; i >= 0; i--) { + int oldIndex = selectedIndices[i]; + boolean alreadyTaken = newSelectedIndices.contains(oldIndex + 1); + int newIndex = (oldIndex < chosenModel.getSize() - 1 && !alreadyTaken) ? oldIndex + 1 : oldIndex; + chosenModel.add(newIndex, chosenModel.remove(oldIndex)); + newSelectedIndices.add(newIndex); + } + chosen.setSelectedIndices(ArrayUtils.toPrimitive(newSelectedIndices.toArray(new Integer[newSelectedIndices.size()]))); + }); + + + btnDefault.addActionListener(event -> layout.setText(Globals.prefs.getPreviewPreferences() + .getPreviewStyleDefault().replace("__NEWLINE__", "\n"))); + + btnTest.addActionListener(event -> { try { - PreviewPanel testPanel = new PreviewPanel(null, TestEntry.getTestEntry(), null, - layout2.getText()); - testPanel.setPreferredSize(new Dimension(800, 350)); - JOptionPane.showMessageDialog(null, new JScrollPane(testPanel), Localization.lang("Preview"), - JOptionPane.PLAIN_MESSAGE); - } catch (StringIndexOutOfBoundsException ex) { - LOGGER.warn("Parsing error.", ex); + PreviewPanel testPane = new PreviewPanel(null, TestEntry.getTestEntry(), null) + .setFixedLayout(layout.getText()); + testPane.setPreferredSize(new Dimension(800, 350)); + JOptionPane.showMessageDialog(PreviewPrefsTab.this, new JScrollPane(testPane), Localization.lang("Preview"), JOptionPane.PLAIN_MESSAGE); + } catch (StringIndexOutOfBoundsException exception) { + LOGGER.warn("Parsing error.", exception); JOptionPane.showMessageDialog(null, Localization.lang("Parsing error") + ": " + Localization.lang("illegal backslash expression") - + ".\n" + ex.getMessage(), + + ".\n" + exception.getMessage(), Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE); } }); } + private void setupGui(){ + JPanel chooseStyle = FormBuilder.create() + .columns("0:grow, $lcgap, pref, $lcgap, 0:grow") + .rows("pref, $lg, fill:pref:grow, $lg, pref:grow, $lg, pref:grow, $lg, pref:grow") + .padding(Paddings.DIALOG) + + .addSeparator(Localization.lang("Current Preview")).xyw(1, 1, 5) + .add(available).xywh(1, 3, 1, 7) + .add(chosen).xywh(5, 3, 1, 7) + + .add(btnRight).xy(3, 3, "fill, bottom") + .add(btnLeft).xy(3, 5, "fill, top") + .add(btnUp).xy(3, 7, "fill, bottom") + .add(btnDown).xy(3, 9, "fill, top") + .build(); + + JPanel preview = FormBuilder.create() + .columns("pref:grow, $lcgap, pref, $lcgap, pref") + .rows("pref, $lg, fill:pref:grow") + .padding(Paddings.DIALOG) + + .addSeparator(Localization.lang("Preview")).xy(1, 1) + .add(btnTest).xy(3, 1) + .add(btnDefault).xy(5, 1) + .add(scrollPane).xyw(1, 3, 5) + .build(); + + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + add(chooseStyle, BorderLayout.CENTER); + add(preview, BorderLayout.PAGE_END); + } @Override public void setValues() { - layout1.setText(prefs.get(JabRefPreferences.PREVIEW_0).replace("__NEWLINE__", "\n")); - layout2.setText(prefs.get(JabRefPreferences.PREVIEW_1).replace("__NEWLINE__", "\n")); + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences(); + + chosenModel.clear(); + boolean isPreviewChosen = false; + for (String style : previewPreferences.getPreviewCycle()) { + if (CitationStyle.isCitationStyleFile(style)) { + chosenModel.addElement(CitationStyle.createCitationStyleFromFile(style)); + } else { + if (isPreviewChosen) { + LOGGER.error("Preview is already in the list, something went wrong"); + continue; + } + isPreviewChosen = true; + chosenModel.addElement(Localization.lang("Preview")); + } + } + + availableModel.clear(); + if (!isPreviewChosen){ + availableModel.addElement(Localization.lang("Preview")); + } + + btnLeft.setEnabled(!chosen.isSelectionEmpty()); + btnRight.setEnabled(!available.isSelectionEmpty()); + btnUp.setEnabled(!chosen.isSelectionEmpty()); + btnDown.setEnabled(!chosen.isSelectionEmpty()); + + if (discoverCitationStyleWorker != null){ + discoverCitationStyleWorker.cancel(true); + } + + discoverCitationStyleWorker = new SwingWorker, Void>() { + @Override + protected List doInBackground() throws Exception { + return CitationStyle.discoverCitationStyles(); + } + + @Override + public void done(){ + if (this.isCancelled()) { + return; + } + try { + get().stream() + .filter(style -> !previewPreferences.getPreviewCycle().contains(style.getFilepath())) + .sorted((style0, style1) -> style0.getTitle().compareTo(style1.getTitle())) + .forEach(availableModel::addElement); + + btnRight.setEnabled(!availableModel.isEmpty()); + } catch (InterruptedException | ExecutionException e) { + LOGGER.error("something went wrong while adding the discovered CitationStyles to the list "); + } + } + }; + discoverCitationStyleWorker.execute(); + + layout.setText(Globals.prefs.getPreviewPreferences().getPreviewStyle().replace("__NEWLINE__", "\n")); } @Override public void storeSettings() { - prefs.put(JabRefPreferences.PREVIEW_0, layout1.getText().replace("\n", "__NEWLINE__")); - prefs.put(JabRefPreferences.PREVIEW_1, layout2.getText().replace("\n", "__NEWLINE__")); + List styles = new ArrayList<>(); + Enumeration elements = chosenModel.elements(); + while (elements.hasMoreElements()) { + Object obj = elements.nextElement(); + if (obj instanceof CitationStyle) { + styles.add(((CitationStyle) obj).getFilepath()); + } else if (obj instanceof String) { + styles.add("Preview"); + } + } + PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences() + .getBuilder() + .withPreviewCycle(styles) + .withPreviewStyle(layout.getText().replace("\n", "__NEWLINE__")) + .build(); + Globals.prefs.storePreviewPreferences(previewPreferences); + + // update preview + for (BasePanel basePanel : JabRefGUI.getMainFrame().getBasePanelList()) { + basePanel.getPreviewPanel().updateLayout(); + } } @Override public boolean validateSettings() { - return true; + return !chosenModel.isEmpty(); } @Override diff --git a/src/main/java/net/sf/jabref/gui/search/SearchResultFrame.java b/src/main/java/net/sf/jabref/gui/search/SearchResultFrame.java index dc38cdbbb88e..532514afd3e7 100644 --- a/src/main/java/net/sf/jabref/gui/search/SearchResultFrame.java +++ b/src/main/java/net/sf/jabref/gui/search/SearchResultFrame.java @@ -61,7 +61,6 @@ import net.sf.jabref.model.entry.FieldName; import net.sf.jabref.model.entry.FieldProperty; import net.sf.jabref.model.entry.InternalBibtexFields; -import net.sf.jabref.preferences.JabRefPreferences; import net.sf.jabref.preferences.SearchPreferences; import ca.odell.glazedlists.BasicEventList; @@ -128,10 +127,7 @@ private void init(String title) { searchResultFrame.setTitle(title); searchResultFrame.setIconImage(IconTheme.getImage("jabrefIcon48").getImage()); - int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW); - String layoutFile = activePreview == 0 ? Globals.prefs.get(JabRefPreferences.PREVIEW_0) : Globals.prefs - .get(JabRefPreferences.PREVIEW_1); - preview = new PreviewPanel(null, null, layoutFile); + preview = new PreviewPanel(null, null); sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR)); model = (DefaultEventTableModel) GlazedListsSwing.eventTableModelWithThreadProxyList(sortedEntries, @@ -396,6 +392,12 @@ public void addEntries(List newEntries, BasePanel panel) { private void addEntry(BibEntry entry, BasePanel panel) { entries.add(entry); entryHome.put(entry, panel); + + if (preview.getEntry() == null || !preview.getBasePanel().isPresent()){ + preview.setEntry(entry); + preview.setBasePanel(panel); + preview.setDatabaseContext(panel.getBibDatabaseContext()); + } } private void selectEntryInBasePanel(BibEntry entry){ @@ -545,6 +547,8 @@ public void listChanged(ListEvent listEvent) { preview.setDatabaseContext(basePanel.getBibDatabaseContext()); // Update the preview's entry: preview.setEntry(entry); + preview.setBasePanel(entryHome.get(entry)); + preview.setDatabaseContext(entryHome.get(entry).getBibDatabaseContext()); contentPane.setDividerLocation(0.5f); SwingUtilities.invokeLater(() -> preview.scrollRectToVisible(toRect)); } diff --git a/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java b/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java new file mode 100644 index 000000000000..e9724e6505ed --- /dev/null +++ b/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java @@ -0,0 +1,77 @@ +package net.sf.jabref.gui.worker; + +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ExecutionException; +import java.util.regex.Pattern; + +import javax.swing.JEditorPane; +import javax.swing.SwingWorker; + +import net.sf.jabref.gui.BasePanel; +import net.sf.jabref.gui.PreviewPanel; +import net.sf.jabref.logic.citationstyle.CitationStyle; +import net.sf.jabref.logic.l10n.Localization; +import net.sf.jabref.logic.search.MatchesHighlighter; +import net.sf.jabref.model.entry.BibEntry; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + +/** + * Generates a citation and updates the linked preview panel + */ +public class CitationStyleWorker extends SwingWorker { + + private static final Log LOGGER = LogFactory.getLog(CitationStyleWorker.class); + + private final PreviewPanel previewPanel; + + + public CitationStyleWorker(PreviewPanel previewPanel, JEditorPane previewPane) { + this.previewPanel = Objects.requireNonNull(previewPanel); + Objects.requireNonNull(previewPane); + + Optional basePanel = previewPanel.getBasePanel(); + if (basePanel.isPresent()){ + Optional citationStyle = basePanel.get().getCitationStyleCache().getCitationStyle(); + if (citationStyle.isPresent()) { + previewPane.setText("" + Localization.lang("Processing %0", Localization.lang("Citation Style")) + + ": " + citationStyle.get().getTitle() + " ..." + ""); + } + } + previewPane.revalidate(); + } + + @Override + protected String doInBackground() throws Exception { + Optional basePanel = this.previewPanel.getBasePanel(); + BibEntry entry = this.previewPanel.getEntry(); + Optional highlightPattern = this.previewPanel.getHighlightPattern(); + + String fieldText = ""; + if (entry != null && basePanel.isPresent()) { + fieldText = basePanel.get().getCitationStyleCache().getCitationFor(entry); + fieldText = MatchesHighlighter.highlightWordsWithHTML(fieldText, highlightPattern); + } + return fieldText; + } + + @Override + public void done() { + if (this.isCancelled()) { + return; + } + String text; + try { + text = this.get(); + } catch (InterruptedException | ExecutionException e) { + LOGGER.error("Error while generating citation style", e); + text = Localization.lang("Error while generating citation style"); + } + + previewPanel.setPreviewLabel(text); + } + +} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java new file mode 100644 index 000000000000..f4988b46d803 --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java @@ -0,0 +1,178 @@ +package net.sf.jabref.logic.citationstyle; + +import java.io.IOException; +import java.io.StringReader; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Objects; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import net.sf.jabref.logic.util.FileExtensions; + +import de.undercouch.citeproc.helper.CSLUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.CharacterData; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + + +/** + * Representation of a CitationStyle + * Stores its name, the filepath and the style itself + */ +public class CitationStyle { + + public static final String DEFAULT = "/ieee.csl"; + private static final Log LOGGER = LogFactory.getLog(CitationStyle.class); + + private final String filepath; + private final String title; + private final String source; + + + private CitationStyle(final String filename, final String title, final String source) { + this.filepath = Objects.requireNonNull(filename); + this.title = Objects.requireNonNull(title); + this.source = Objects.requireNonNull(source); + } + + /** + * Creates an CitationStyle instance out of the style string + */ + private static CitationStyle createCitationStyleFromSource(final String source, final String filename) { + try { + DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(source)); + + Document doc = db.parse(is); + NodeList nodes = doc.getElementsByTagName("info"); + + NodeList titleNode = ((Element) nodes.item(0)).getElementsByTagName("title"); + String title = ((CharacterData) titleNode.item(0).getFirstChild()).getData(); + + return new CitationStyle(filename, title, source); + } catch (ParserConfigurationException | SAXException | IOException e) { + LOGGER.error("Error while parsing source", e); + } + return null; + } + + /** + * Loads the CitationStyle from the given file + */ + public static CitationStyle createCitationStyleFromFile(final String styleFile) { + if (!isCitationStyleFile(styleFile)) { + LOGGER.error("Can only load style files: "+ styleFile); + return null; + } + + try { + String text; + String internalFile = (styleFile.startsWith("/") ? "" : "/") + styleFile; + URL url = CitationStyle.class.getResource(internalFile); + if (url != null) { + text = CSLUtils.readURLToString(url, StandardCharsets.UTF_8.toString()); + } else { + // if the url is null then the style is located outside the classpath + text = new String(Files.readAllBytes(Paths.get(styleFile)), StandardCharsets.UTF_8); + } + return createCitationStyleFromSource(text, styleFile); + } catch (NoSuchFileException e){ + LOGGER.error("Could not find file: "+ styleFile, e); + } catch (IOException e) { + LOGGER.error("Error reading source file", e); + } + return null; + } + + public static CitationStyle getDefault(){ + return createCitationStyleFromFile(DEFAULT); + } + + /** + * THIS ONLY WORKS WHEN JabRef IS STARTED AS AN APPLICATION (JAR) + * + * Reads all available CitationStyle in the Jar + */ + public static List discoverCitationStyles() { + try { + final List citationStyles = new ArrayList<>(); + String path = CitationStyle.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); + + try (JarFile file = new JarFile(path)) { + Enumeration entries = file.entries(); + while (entries.hasMoreElements()) { + String filename = entries.nextElement().getName(); + if (!filename.startsWith("dependent") && filename.endsWith("csl")) { + CitationStyle citationStyle = CitationStyle.createCitationStyleFromFile(filename); + if (citationStyle != null) { + citationStyles.add(citationStyle); + } + } + } + } + return citationStyles; + } catch (IOException | URISyntaxException ex) { + LOGGER.error("something went wrong while searching available CitationStyles. " + + "Are you running directly from source code?", ex); + } + return Collections.emptyList(); + } + + /** + * Checks if the given style file is a CitationStyle + */ + public static boolean isCitationStyleFile(String styleFile){ + return Arrays.stream(FileExtensions.CITATION_STYLE.getExtensions()).anyMatch(styleFile::endsWith); + } + + public String getTitle() { + return title; + } + + public String getSource() { + return source; + } + + public String getFilepath() { + return filepath; + } + + @Override + public String toString() { + return title; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null || getClass() != other.getClass()) { + return false; + } + + CitationStyle that = (CitationStyle) other; + return source != null ? source.equals(that.source) : that.source == null; + } + +} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java new file mode 100644 index 000000000000..7dfa17795a05 --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java @@ -0,0 +1,78 @@ +package net.sf.jabref.logic.citationstyle; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import net.sf.jabref.model.database.BibDatabaseContext; +import net.sf.jabref.model.database.event.EntryRemovedEvent; +import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.event.EntryChangedEvent; + +import com.google.common.eventbus.Subscribe; + + +/** + * Caches the generated Citations for quicker access + * {@link CitationStyleGenerator} generates the citaiton with JavaScript which may take some time + */ +public class CitationStyleCache { + + private Optional citationStyle = Optional.of(CitationStyle.getDefault()); + private Map citationStylesCache = new HashMap<>(); + + + public CitationStyleCache(BibDatabaseContext bibDatabaseContext) { + this(bibDatabaseContext, CitationStyle.getDefault()); + } + + public CitationStyleCache(BibDatabaseContext bibDatabaseContext, CitationStyle citationStyle) { + this.setCitationStyle(citationStyle); + bibDatabaseContext.getDatabase().registerListener(new BibDatabaseEntryListener()); + } + + /** + * returns the citation for the given BibEntry and the set CitationStyle + */ + public String getCitationFor(BibEntry entry) { + String citation = citationStylesCache.get(entry); + if (citation == null) { + citation = CitationStyleGenerator.generateCitation(entry, this.citationStyle.get().getSource()); + citationStylesCache.put(entry, citation); + } + return citation; + } + + public void setCitationStyle(CitationStyle citationStyle) { + Objects.requireNonNull(citationStyle); + if (!this.citationStyle.isPresent() || !this.citationStyle.get().equals(citationStyle)){ + this.citationStyle = Optional.of(citationStyle); + this.citationStylesCache.clear(); + } + } + + public Optional getCitationStyle() { + return citationStyle; + } + + + private class BibDatabaseEntryListener { + /** + * removes the outdated citation of the changed entry + */ + @Subscribe + public void listen(EntryChangedEvent entryChangedEvent) { + citationStylesCache.remove(entryChangedEvent.getBibEntry()); + } + + /** + * removes the citation of the removed entry as it's not needed anymore + */ + @Subscribe + public void listen(EntryRemovedEvent entryRemovedEvent) { + citationStylesCache.remove(entryRemovedEvent.getBibEntry()); + } + } + +} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java new file mode 100644 index 000000000000..abca958d7d33 --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java @@ -0,0 +1,72 @@ +package net.sf.jabref.logic.citationstyle; + +import java.io.IOException; +import java.util.Map; + +import net.sf.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter; +import net.sf.jabref.logic.l10n.Localization; +import net.sf.jabref.model.entry.BibEntry; + +import de.undercouch.citeproc.CSL; +import de.undercouch.citeproc.bibtex.BibTeXConverter; +import de.undercouch.citeproc.csl.CSLItemData; +import de.undercouch.citeproc.output.Bibliography; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jbibtex.BibTeXEntry; +import org.jbibtex.DigitStringValue; +import org.jbibtex.Key; +import org.jbibtex.TokenMgrError; + + +/** + * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread + */ +public class CitationStyleGenerator { + + private static final Log LOGGER = LogFactory.getLog(CitationStyleGenerator.class); + private static final UnicodeToLatexFormatter UNICODE_TO_LATEX_FORMATTER = new UnicodeToLatexFormatter(); + private static final BibTeXConverter BIBTEX_CONVERTER = new BibTeXConverter(); + + + /** + * Generates a Citation based on the given entry and style + * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread + */ + protected static String generateCitation(BibEntry entry, String style) { + return generateCitation(entry, style, CitationStyleOutputFormat.HTML); + } + + /** + * Generates a Citation based on the given entry, style, and output format + * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread + */ + protected static String generateCitation(BibEntry entry, String style, CitationStyleOutputFormat outputFormat) { + try { + String citeKey = entry.getCiteKeyOptional().orElse(""); + BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(entry.getType()), new Key(citeKey)); + for (Map.Entry field : entry.getFieldMap().entrySet()) { + String value = UNICODE_TO_LATEX_FORMATTER.format(field.getValue()); + bibTeXEntry.addField(new Key(field.getKey()), new DigitStringValue(value)); + } + + CSLItemData cslItemData = BIBTEX_CONVERTER.toItemData(bibTeXEntry); + Bibliography bibliography = CSL.makeAdhocBibliography(style, outputFormat.getFormat(), cslItemData); + return bibliography.getEntries()[0]; + + } catch (IOException | ArrayIndexOutOfBoundsException e) { + LOGGER.error("Could not generate BibEntry Citation", e); + } catch (TokenMgrError e) { + LOGGER.error("Bad character inside BibEntry", e); + // sadly one cannot easily retrieve the bad char from the TokenMgrError + return new StringBuilder() + .append(Localization.lang("Bad character inside entry")) + .append(outputFormat == CitationStyleOutputFormat.HTML ? "
" : "\n") + .append(e.getLocalizedMessage()) + .toString(); + } + + return ""; + } + +} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java new file mode 100644 index 000000000000..dc6bf3119f02 --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java @@ -0,0 +1,27 @@ +package net.sf.jabref.logic.citationstyle; + + +public enum CitationStyleOutputFormat { + + HTML("html"), + TEXT("text"), + ASCII_DOC("asciidoc"), + FO("fo"), + RTF("rtf"); + + private final String format; + + CitationStyleOutputFormat(String format) { + this.format = format; + } + + public String getFormat() { + return format; + } + + @Override + public String toString() { + return format; + } + +} diff --git a/src/main/java/net/sf/jabref/logic/util/FileExtensions.java b/src/main/java/net/sf/jabref/logic/util/FileExtensions.java index 2aa7ea546dd3..5f746dd3a7ae 100644 --- a/src/main/java/net/sf/jabref/logic/util/FileExtensions.java +++ b/src/main/java/net/sf/jabref/logic/util/FileExtensions.java @@ -15,6 +15,7 @@ public enum FileExtensions { BIBTEXML(Localization.lang("%0 file", "BibTeXML"), "bibx", "xml"), BILBIOSCAPE(Localization.lang("%0 file", "Biblioscape"), "txt"), COPAC(Localization.lang("%0 file", "Copac"), "txt"), + CITATION_STYLE(Localization.lang("%0 file", "CSL"), "csl"), ENDNOTE(Localization.lang("%0 file", "Endnote/Refer"), "ref", "enw"), FREECITE(Localization.lang("%0 file", "FreeCite"), "txt", "xml"), INSPEC(Localization.lang("%0 file", "INSPEC"), "txt"), diff --git a/src/main/java/net/sf/jabref/model/entry/event/EntryEvent.java b/src/main/java/net/sf/jabref/model/entry/event/EntryEvent.java index 0d55615aff46..ded8aa9c1d7d 100644 --- a/src/main/java/net/sf/jabref/model/entry/event/EntryEvent.java +++ b/src/main/java/net/sf/jabref/model/entry/event/EntryEvent.java @@ -1,5 +1,7 @@ package net.sf.jabref.model.entry.event; +import java.util.Objects; + import net.sf.jabref.model.entry.BibEntry; /** @@ -24,8 +26,8 @@ public EntryEvent(BibEntry bibEntry) { * @param location Location affected by this event */ public EntryEvent(BibEntry bibEntry, EntryEventSource location) { - this.bibEntry = bibEntry; - this.location = location; + this.bibEntry = Objects.requireNonNull(bibEntry); + this.location = Objects.requireNonNull(location); } public BibEntry getBibEntry() { diff --git a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java index e519426b57c4..7e818dbca626 100644 --- a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java @@ -42,6 +42,7 @@ import net.sf.jabref.logic.bibtex.FieldContentParserPreferences; import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; +import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.cleanup.CleanupPreferences; import net.sf.jabref.logic.cleanup.CleanupPreset; import net.sf.jabref.logic.cleanup.FieldFormatterCleanup; @@ -123,7 +124,6 @@ public class JabRefPreferences { public static final String BIBLATEX_DEFAULT_MODE = "biblatexMode"; public static final String NAMES_AS_IS = "namesAsIs"; public static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeight"; - public static final String PREVIEW_PANEL_HEIGHT = "previewPanelHeight"; public static final String AUTO_RESIZE_MODE = "autoResizeMode"; public static final String WINDOW_MAXIMISED = "windowMaximised"; public static final String USE_DEFAULT_LOOK_AND_FEEL = "useDefaultLookAndFeel"; @@ -274,10 +274,6 @@ public class JabRefPreferences { public static final String NON_WRAPPABLE_FIELDS = "nonWrappableFields"; public static final String RESOLVE_STRINGS_ALL_FIELDS = "resolveStringsAllFields"; public static final String DO_NOT_RESOLVE_STRINGS_FOR = "doNotResolveStringsFor"; - public static final String PREVIEW_1 = "preview1"; - public static final String PREVIEW_0 = "preview0"; - public static final String ACTIVE_PREVIEW = "activePreview"; - public static final String PREVIEW_ENABLED = "previewEnabled"; public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; public static final String CUSTOM_EXPORT_FORMAT = "customExportFormat"; @@ -449,6 +445,13 @@ public static String getCustomTypeName(){ public static final String USE_REMOTE_SERVER = "useRemoteServer"; public static final String REMOTE_SERVER_PORT = "remoteServerPort"; + // Preview + private static final String CYCLE_PREVIEW_POS = "cyclePreviewPos"; + private static final String CYCLE_PREVIEW = "cyclePreview"; + private static final String PREVIEW_PANEL_HEIGHT = "previewPanelHeight"; + private static final String PREVIEW_STYLE = "previewStyle"; + private static final String PREVIEW_ENABLED = "previewEnabled"; + public final String MARKING_WITH_NUMBER_PATTERN; private final Preferences prefs; @@ -557,7 +560,6 @@ private JabRefPreferences() { defaults.put(SIZE_Y, 768); defaults.put(WINDOW_MAXIMISED, Boolean.FALSE); defaults.put(AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS); - defaults.put(PREVIEW_PANEL_HEIGHT, 200); defaults.put(ENTRY_EDITOR_HEIGHT, 400); defaults.put(TABLE_COLOR_CODES_ON, Boolean.FALSE); defaults.put(TABLE_RESOLVED_COLOR_CODES_ON, Boolean.FALSE); @@ -753,47 +755,6 @@ private JabRefPreferences() { defaults.put(CONFIRM_DELETE, Boolean.TRUE); defaults.put(GRAY_OUT_NON_HITS, Boolean.TRUE); defaults.put(DEFAULT_BIBTEX_KEY_PATTERN, "[auth][year]"); - defaults.put(PREVIEW_ENABLED, Boolean.TRUE); - defaults.put(ACTIVE_PREVIEW, 0); - defaults.put(PREVIEW_0, - "" - + "\\format[EntryTypeFormatter]{\\entrytype}\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" - + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" - + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" - + "__NEWLINE__

"); - defaults.put(PREVIEW_1, - "" - + "\\format[EntryTypeFormatter]{\\entrytype}\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" - + "__NEWLINE__

"); - defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, FieldName.URL); defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file;isbn;issn"); @@ -884,6 +845,32 @@ private JabRefPreferences() { //versioncheck defaults defaults.put(VERSION_IGNORED_UPDATE, ""); + + // preview + defaults.put(CYCLE_PREVIEW, "Preview;" + CitationStyle.DEFAULT); + defaults.put(CYCLE_PREVIEW_POS, 0); + defaults.put(PREVIEW_PANEL_HEIGHT, 200); + defaults.put(PREVIEW_ENABLED, Boolean.TRUE); + defaults.put(PREVIEW_STYLE, + "" + + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + + "\\end{bibtexkey}
__NEWLINE__" + + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + + "__NEWLINE__

"); } public String getUser() { @@ -1466,6 +1453,25 @@ public FileLinkPreferences getFileLinkPreferences() { fileDirForDatabase); } + public JabRefPreferences storePreviewPreferences(PreviewPreferences previewPreferences) { + putInt(CYCLE_PREVIEW_POS, previewPreferences.getPreviewCyclePosition()); + putStringList(CYCLE_PREVIEW, previewPreferences.getPreviewCycle()); + putInt(PREVIEW_PANEL_HEIGHT, previewPreferences.getPreviewPanelHeight()); + put(PREVIEW_STYLE, previewPreferences.getPreviewStyle()); + putBoolean(PREVIEW_ENABLED, previewPreferences.isPreviewPanelEnabled()); + return this; + } + + public PreviewPreferences getPreviewPreferences(){ + int cyclePos = getInt(CYCLE_PREVIEW_POS); + List cycle = getStringList(CYCLE_PREVIEW); + int panelHeight = getInt(PREVIEW_PANEL_HEIGHT); + String style = get(PREVIEW_STYLE); + String styleDefault = (String) defaults.get(PREVIEW_STYLE); + boolean enabled = getBoolean(PREVIEW_ENABLED); + return new PreviewPreferences(cycle, cyclePos, panelHeight, enabled, style, styleDefault); + } + public void storeProxyPreferences(ProxyPreferences proxyPreferences) { putBoolean(PROXY_USE, proxyPreferences.isUseProxy()); put(PROXY_HOSTNAME, proxyPreferences.getHostname()); diff --git a/src/main/java/net/sf/jabref/preferences/PreviewPreferences.java b/src/main/java/net/sf/jabref/preferences/PreviewPreferences.java new file mode 100644 index 000000000000..086c6ee057e5 --- /dev/null +++ b/src/main/java/net/sf/jabref/preferences/PreviewPreferences.java @@ -0,0 +1,106 @@ +package net.sf.jabref.preferences; + +import java.util.List; + + +public class PreviewPreferences { + + private final List previewCycle; + private final int previewCyclePosition; + private final int previewPanelHeight; + private final boolean previewPanelEnabled; + private final String previewStyle; + private final String previewStyleDefault; + + + public PreviewPreferences(List previewCycle, int previeCyclePosition, int previewPanelHeight, boolean previewPanelEnabled, String previewStyle, String previewStyleDefault) { + this.previewCycle = previewCycle; + this.previewCyclePosition = previeCyclePosition; + this.previewPanelHeight = previewPanelHeight; + this.previewPanelEnabled = previewPanelEnabled; + this.previewStyle = previewStyle; + this.previewStyleDefault = previewStyleDefault; + } + + public List getPreviewCycle() { + return previewCycle; + } + + public int getPreviewCyclePosition() { + return previewCyclePosition; + } + + public int getPreviewPanelHeight() { + return previewPanelHeight; + } + + public boolean isPreviewPanelEnabled() { + return previewPanelEnabled; + } + + public String getPreviewStyle() { + return previewStyle; + } + + public String getPreviewStyleDefault() { + return previewStyleDefault; + } + + public Builder getBuilder() { + return new Builder(this); + } + + + public static class Builder { + private List previewCycle; + private int previeCyclePosition; + private int previewPanelHeight; + private boolean previewPanelEnabled; + private String previewStyle; + private final String previewStyleDefault; + + + public Builder(PreviewPreferences previewPreferences) { + this.previewCycle = previewPreferences.getPreviewCycle(); + this.previeCyclePosition = previewPreferences.getPreviewCyclePosition(); + this.previewPanelHeight = previewPreferences.getPreviewPanelHeight(); + this.previewPanelEnabled = previewPreferences.isPreviewPanelEnabled(); + this.previewStyle = previewPreferences.getPreviewStyle(); + this.previewStyleDefault = previewPreferences.getPreviewStyleDefault(); + } + + public Builder withPreviewCycle(List previewCycle) { + this.previewCycle = previewCycle; + return withPreviewCyclePosition(previeCyclePosition); + } + + public Builder withPreviewCyclePosition(int position) { + previeCyclePosition = position; + while (previeCyclePosition < 0) { + previeCyclePosition += previewCycle.size(); + } + previeCyclePosition %= previewCycle.size(); + return this; + } + + public Builder withPreviewPanelHeight(int previewPanelHeight) { + this.previewPanelHeight = previewPanelHeight; + return this; + } + + public Builder withPreviewPanelEnabled(boolean previewPanelEnabled) { + this.previewPanelEnabled = previewPanelEnabled; + return this; + } + + public Builder withPreviewStyle(String previewStyle) { + this.previewStyle = previewStyle; + return this; + } + + public PreviewPreferences build() { + return new PreviewPreferences(previewCycle, previeCyclePosition, previewPanelHeight, previewPanelEnabled, previewStyle, previewStyleDefault); + } + } + +} diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index 627a5224397b..ac1a9d501b6b 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -982,6 +982,13 @@ Preferences=Indstillinger Preferences_recorded.=Indstillinger_gemt. Preview=Forhåndsvisning +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Forrige_post @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 5c1d640f9056..ed498184cda1 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -982,6 +982,13 @@ Preferences=Einstellungen Preferences_recorded.=Einstellungen_gespeichert. Preview=Vorschau +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Vorheriger_Eintrag @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=Doppelte_BibTeX-Keys_auflösen Save_all=Alle_speichern String_dialog,_add_string=Stringdialog,_String_hinzufügen String_dialog,_remove_string=Stringdialog,_String_entfernen -Switch_preview_layout=Wechsele_Vorschau_Layout Synchronize_files=Sychronisiere_Dateien Unabbreviate=Abkürzung_aufheben should_contain_a_protocol=sollte_ein_Protokoll_beinhalten diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 645ff742c7fd..4a55273c6676 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -982,6 +982,13 @@ Preferences=Preferences Preferences_recorded.=Preferences_recorded. Preview=Preview +Citation_Style=Citation_Style +Current_Preview=Current_Preview +Bad_character_inside_entry=Bad_character_inside_entry +Error_while_generating_citation_style=Error_while_generating_citation_style +Preview_style_changed_to\:_%0=Preview_style_changed_to\:_%0 +Next_preview_layout=Next_preview_layout +Previous_preview_layout=Previous_preview_layout Previous_entry=Previous_entry @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=Resolve_duplicate_BibTeX_keys Save_all=Save_all String_dialog,_add_string=String_dialog,_add_string String_dialog,_remove_string=String_dialog,_remove_string -Switch_preview_layout=Switch_preview_layout Synchronize_files=Synchronize_files Unabbreviate=Unabbreviate should_contain_a_protocol=should_contain_a_protocol diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 45d4af2c3fed..aaed8d474665 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -982,6 +982,13 @@ Preferences=Preferencias Preferences_recorded.=Preferencias_guardadas. Preview=Vista_previa +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Entrada_anterior @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=Resolver_claves_BibTeX_duplicadas Save_all=Guardar_todo String_dialog,_add_string=Diálogo_de_cadena,_añadir_cadena String_dialog,_remove_string=Diálogo_de_cadena,_eliminar_cadena -Switch_preview_layout=Cambiar_esquema_de_previsualización Synchronize_files=Sincronizar_archivos Unabbreviate=Eliminar_abreviatura should_contain_a_protocol=Debería_contener_un_protocolo diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index ed8e39316445..4ed4e979c471 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -982,6 +982,13 @@ Preferences= Preferences_recorded.= Preview= +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry= @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index c11c70e2e9b4..dac81d019a5b 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -982,6 +982,13 @@ Preferences=Préférences Preferences_recorded.=Préférences_enregistrées. Preview=Aperçu +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Entrée_précédente @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=Solutionner_les_clefs_BibTeX_dupliquées Save_all=Enregistrer_tout String_dialog,_add_string=Chaine_de_dialogue,_ajouter_une_chaine String_dialog,_remove_string=Chaine_de_dialogue,_supprimer_une_chaine -Switch_preview_layout=Basculer_la_prévisualisation Synchronize_files=Synchroniser_les_fichiers Unabbreviate=Dés-abréger should_contain_a_protocol=doit_contenir_un_protocole diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 69e4ab12b058..921ca5c0791c 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -982,6 +982,13 @@ Preferences=Preferensi Preferences_recorded.=Preferensi_disimpan. Preview=Pratampilan +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Entri_sebelumnya @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all=Simpan_semua String_dialog,_add_string=Dialog_string,_tambah_string String_dialog,_remove_string=Dialog_string,_hapus_string -Switch_preview_layout= Synchronize_files=Sinkronkan_berkas Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 3c7be2c77271..a99fd9a1ed85 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -982,6 +982,13 @@ Preferences=Preferenze Preferences_recorded.=Preferenze_registrate. Preview=Anteprima +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Voce_precedente @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index bf145a43451e..4e399fa60bf3 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -982,6 +982,13 @@ Preferences=設定 Preferences_recorded.=設定が記録されました。 Preview=プレビュー +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=前の項目 @@ -1982,7 +1989,6 @@ Resolve_duplicate_BibTeX_keys=重複BibTeX鍵を解消 Save_all=全て保存 String_dialog,_add_string=文字列ダイアログ・文字列を追加 String_dialog,_remove_string=文字列ダイアログ・文字列を削除 -Switch_preview_layout=プレビューレイアウトを切り替え Synchronize_files=ファイルを同期 Unabbreviate=非短縮形化 should_contain_a_protocol=プロトコルを含む必要あり diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index c96f956c2022..ddd9ef5ca313 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -982,6 +982,13 @@ Preferences=Instellingen Preferences_recorded.=Instellingen_opgeslagen. Preview=Voorbeeld +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Vorige_entry @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index a75f239be5f4..e69d0c04bccc 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -982,6 +982,13 @@ Preferences=Oppsett Preferences_recorded.=Lagret_oppsett. Preview=Forh\u00e5ndsvisning +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Forrige_enhet @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index f90fedfbe846..4ec48a05387a 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -982,6 +982,13 @@ Preferences=Preferências Preferences_recorded.=Preferências_salvas. Preview=Previsualização +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Referência_anterior @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all=Salvar_todos String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files=Sincronizar_arquivos Unabbreviate=Reverter_abreviações should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 025b9ad7cd0d..741bf881081a 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -982,6 +982,13 @@ Preferences=Пользовательские_настройки Preferences_recorded.=Выполнена_запись_пользовательских_настроек. Preview=Предпросмотр +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Предыдущая_запись @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index d8c472c89c2d..fc5c558b854d 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -982,6 +982,13 @@ Preferences=Inställningar Preferences_recorded.=Inställningar_sparade. Preview=Postvisning +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Föregående_post @@ -1982,7 +1989,6 @@ Resolve_duplicate_BibTeX_keys=Hantera_BibTeX-nyckeldubbletter Save_all=Spara_alla String_dialog,_add_string=Strängdialog,_lägg_till_sträng String_dialog,_remove_string=Strängdialog,_ta_bort_sträng -Switch_preview_layout=Byt_postvisningsstil Synchronize_files=Synkronisera_filer Unabbreviate=Expandera_förkortning should_contain_a_protocol=ska_innehålla_ett_protokoll diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index d7c594f45b87..9dcbba117385 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -982,6 +982,13 @@ Preferences=Tercihler Preferences_recorded.=Tercihler_kaydedildi. Preview=Önizleme +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Önceki_girdi @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=Çift_kopyalı_BibTeX_anahtarlarını_çözümle Save_all=Tümünü_kaydet String_dialog,_add_string=Dizilim_iletişim_kutusu,_dizilim_ekle String_dialog,_remove_string=Dizilim_iletişim_kutusu,_dizilim_çıkar -Switch_preview_layout=Önizleme_anahattını_değiştir Synchronize_files=Dosyaları_eşzamanla Unabbreviate=Kısaltmayı_kaldır should_contain_a_protocol=bir_protokol_içermeli diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index eb47536de86c..e5a13c7cb231 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -982,6 +982,13 @@ Preferences=Các_tùy_thích Preferences_recorded.=Các_tùy_thích_được_ghi_lại. Preview=Xem_trước +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=Mục_trước_đó @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys= Save_all= String_dialog,_add_string= String_dialog,_remove_string= -Switch_preview_layout= Synchronize_files= Unabbreviate= should_contain_a_protocol= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index b900b7fd6cfe..19a6b1ab4259 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -982,6 +982,13 @@ Preferences=首选项 Preferences_recorded.=首选项被记录。 Preview=预览 +Citation_Style= +Current_Preview= +Bad_character_inside_entry= +Error_while_generating_citation_style= +Preview_style_changed_to\:_%0= +Next_preview_layout= +Previous_preview_layout= Previous_entry=上一条 @@ -1981,7 +1988,6 @@ Resolve_duplicate_BibTeX_keys=处理重复的_BibTeX_键值 Save_all=保存所有 String_dialog,_add_string=简写字串对话框,添加简写字串 String_dialog,_remove_string=简写字串对话框,删除简写字串 -Switch_preview_layout=切换预览视图 Synchronize_files=同步文件 Unabbreviate=展开缩写 should_contain_a_protocol= diff --git a/src/main/resources/l10n/Menu_da.properties b/src/main/resources/l10n/Menu_da.properties index 7a174a633298..3ab8e417a55e 100644 --- a/src/main/resources/l10n/Menu_da.properties +++ b/src/main/resources/l10n/Menu_da.properties @@ -70,7 +70,8 @@ Select_all=&Vælg_alle Set_up_general_fields=Administrer_&generelle_felter Show_error_console=Vis_fejlkonsol Sort_tabs=Sorter_faneblade -Switch_preview_layout=&Skift_layout_på_forhåndsvisning +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Vis/skjul_forhåndsvisning Toggle_groups_interface=Vis/skjul_&grupperingspanel diff --git a/src/main/resources/l10n/Menu_de.properties b/src/main/resources/l10n/Menu_de.properties index 89e1147ad00c..915b4516284e 100644 --- a/src/main/resources/l10n/Menu_de.properties +++ b/src/main/resources/l10n/Menu_de.properties @@ -70,7 +70,8 @@ Select_all=&Alle_ausw\u00e4hlen Set_up_general_fields=Allgemeine_&Felder_festlegen Show_error_console=Fehlerkonsole_anzeigen Sort_tabs=Tabs_&sortieren -Switch_preview_layout=&Layout_der_Vorschau_wechseln +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Eintragsvorschau_ein-/ausblenden Toggle_groups_interface=&Gruppenansicht_ein-/ausblenden diff --git a/src/main/resources/l10n/Menu_en.properties b/src/main/resources/l10n/Menu_en.properties index f5535e888ed6..4ccc758f9bcf 100644 --- a/src/main/resources/l10n/Menu_en.properties +++ b/src/main/resources/l10n/Menu_en.properties @@ -70,7 +70,8 @@ Select_all=Select_&all Set_up_general_fields=Set_up_&general_fields Show_error_console=Show_error_console Sort_tabs=&Sort_tabs -Switch_preview_layout=&Switch_preview_layout +Next_preview_layout=&Next_preview_layout +Previous_preview_layout=&Previous_preview_layout # Export menu Toggle_entry_preview=&Toggle_entry_preview Toggle_groups_interface=Toggle_&groups_interface diff --git a/src/main/resources/l10n/Menu_es.properties b/src/main/resources/l10n/Menu_es.properties index 832343604cb0..0fa2c0eebbd1 100644 --- a/src/main/resources/l10n/Menu_es.properties +++ b/src/main/resources/l10n/Menu_es.properties @@ -70,7 +70,8 @@ Select_all=Seleccionar_&todos Set_up_general_fields=Establecer_&campos_generales Show_error_console=Mostrar_consola_de_error Sort_tabs=&Ordenar_pestañas -Switch_preview_layout=&Intercambiar_vista_anterior +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=A&ctivar/Desactivar_previsualización_de_registro Toggle_groups_interface=Activar/Desactivar_ventana_de_&grupos diff --git a/src/main/resources/l10n/Menu_fa.properties b/src/main/resources/l10n/Menu_fa.properties index 276e218377c8..9af1f88b21ba 100644 --- a/src/main/resources/l10n/Menu_fa.properties +++ b/src/main/resources/l10n/Menu_fa.properties @@ -70,7 +70,8 @@ Select_all=انتخاب_همه Set_up_general_fields=نصب_کردن_حوزه‌های_کلی Show_error_console=نمایش_میزفرمان_خطاها Sort_tabs=دسته‌بندی_کردن_سربرگ‌ها -Switch_preview_layout=جهش_به_آرایش_قبلی +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=انتصاب_پیش‌نمایش_ورودی‌ها Toggle_groups_interface=انتصاب_واسط_گروه‌ها diff --git a/src/main/resources/l10n/Menu_fr.properties b/src/main/resources/l10n/Menu_fr.properties index 7eb97c97807d..03965efcf270 100644 --- a/src/main/resources/l10n/Menu_fr.properties +++ b/src/main/resources/l10n/Menu_fr.properties @@ -70,7 +70,8 @@ Select_all=&Tout_s\u00e9lectionner Set_up_general_fields=Configurer_les_champs_&g\u00e9n\u00e9raux Show_error_console=Afficher_la_console_d'erreur Sort_tabs=Trier_les_onglets -Switch_preview_layout=Aper\u00e7u_1/Aper\u00e7u_2 +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Afficher/masquer_l'aper\u00e7u Toggle_groups_interface=Afficher/masquer_l'interface_des_&groupes diff --git a/src/main/resources/l10n/Menu_in.properties b/src/main/resources/l10n/Menu_in.properties index adb422872eb3..7f5ce91a86b2 100644 --- a/src/main/resources/l10n/Menu_in.properties +++ b/src/main/resources/l10n/Menu_in.properties @@ -70,7 +70,8 @@ Select_all=Pilih_semua Set_up_general_fields=Penetapan_bidang_umum Show_error_console=Tampilkan_pesan_kesalahan Sort_tabs=Urutkan_tab -Switch_preview_layout=Ubah_tataletak_tampilan +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=Tampilkan_entri Toggle_groups_interface=Aktifkan_antarmuka_grup diff --git a/src/main/resources/l10n/Menu_it.properties b/src/main/resources/l10n/Menu_it.properties index f1c999e39401..d9f53644a655 100644 --- a/src/main/resources/l10n/Menu_it.properties +++ b/src/main/resources/l10n/Menu_it.properties @@ -70,7 +70,8 @@ Select_all=Sele&ziona_tutto Set_up_general_fields=Configura_i_campi_generali Show_error_console=Mostra_la_console_d'errore Sort_tabs=Ordina_le_schede -Switch_preview_layout=S&cambia_layout_anteprima +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Visualizza/nascondi_anteprima Toggle_groups_interface=V&isualizza/nascondi_l'interfaccia_dei_gruppi diff --git a/src/main/resources/l10n/Menu_ja.properties b/src/main/resources/l10n/Menu_ja.properties index f0110b544bda..3053f16eaef0 100644 --- a/src/main/resources/l10n/Menu_ja.properties +++ b/src/main/resources/l10n/Menu_ja.properties @@ -70,7 +70,8 @@ Select_all=全て選択(&A) Set_up_general_fields=汎用フィールドを設定(&G) Show_error_console=エラーコンソールを表示 Sort_tabs=タブを整序(&S) -Switch_preview_layout=プレビューのレイアウトを切替(&S) +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=項目プレビューを入切(&T) Toggle_groups_interface=グループ操作面を入切(&G) diff --git a/src/main/resources/l10n/Menu_nl.properties b/src/main/resources/l10n/Menu_nl.properties index 0ec40952f8de..730acbd1927a 100644 --- a/src/main/resources/l10n/Menu_nl.properties +++ b/src/main/resources/l10n/Menu_nl.properties @@ -70,7 +70,8 @@ Select_all=Selecteer_alles Set_up_general_fields=Stel_algemene_velden_in Show_error_console=Toon_foutenconsole Sort_tabs=Tabbladen_sorteren -Switch_preview_layout=Toon_voorbeeld_layout +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=Toon_entry_voorbeeld Toggle_groups_interface=Toon_groepenvenster diff --git a/src/main/resources/l10n/Menu_no.properties b/src/main/resources/l10n/Menu_no.properties index 2ec20d1983d4..1f79037106a0 100644 --- a/src/main/resources/l10n/Menu_no.properties +++ b/src/main/resources/l10n/Menu_no.properties @@ -70,7 +70,8 @@ Select_all=&Velg_alle Set_up_general_fields=Sett_opp_&generelle_felter Show_error_console=Vis_feilkonsoll Sort_tabs=Sorter_tabs -Switch_preview_layout=&Skift_layout_på_forhåndsvisning +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Vis/skjul_forhåndsvisning Toggle_groups_interface=Vis/skjul_&grupperingskontroll diff --git a/src/main/resources/l10n/Menu_pt_BR.properties b/src/main/resources/l10n/Menu_pt_BR.properties index 467c7b15f496..b8dd240ab686 100644 --- a/src/main/resources/l10n/Menu_pt_BR.properties +++ b/src/main/resources/l10n/Menu_pt_BR.properties @@ -70,7 +70,8 @@ Select_all=Selecionar_&tudo Set_up_general_fields=Configurar_&campos_gerais Show_error_console=Exibir_console_de_erros Sort_tabs=&Ordenar_abas -Switch_preview_layout=&Trocar_layout_da_previsualização +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Mostrar/Esconder_previsualização_de_referências Toggle_groups_interface=Mostrar/Esconder_interface_de_&grupos diff --git a/src/main/resources/l10n/Menu_ru.properties b/src/main/resources/l10n/Menu_ru.properties index 36b0665ae4d8..7e14e84e8a9d 100644 --- a/src/main/resources/l10n/Menu_ru.properties +++ b/src/main/resources/l10n/Menu_ru.properties @@ -70,7 +70,8 @@ Select_all=Выбрать_все Set_up_general_fields=Настройка_общих_полей Show_error_console=Показать_консоль_ошибок Sort_tabs=Сортировать_вкладки -Switch_preview_layout=Переключить_макет_предпросмотра +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=Показать/скрыть_просмотр_записи Toggle_groups_interface=Показать/скрыть_интерфейс_групп diff --git a/src/main/resources/l10n/Menu_sv.properties b/src/main/resources/l10n/Menu_sv.properties index ea20554c8cfc..939f03089fe2 100644 --- a/src/main/resources/l10n/Menu_sv.properties +++ b/src/main/resources/l10n/Menu_sv.properties @@ -70,7 +70,8 @@ Select_all=Välj_&alla Set_up_general_fields=Hantera_generella_fält Show_error_console=Visa_felmeddelanden Sort_tabs=Sortera_flikar -Switch_preview_layout=&Byt_postvisningsstil +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=Växla_&postvisning Toggle_groups_interface=Växla_&grupphantering diff --git a/src/main/resources/l10n/Menu_tr.properties b/src/main/resources/l10n/Menu_tr.properties index 9edb69c4e230..cea1ec3a0290 100644 --- a/src/main/resources/l10n/Menu_tr.properties +++ b/src/main/resources/l10n/Menu_tr.properties @@ -70,7 +70,8 @@ Select_all=T&ümünü_seç Set_up_general_fields=&Genel_alanları_ayarla Show_error_console=Hata_konsolunu_göster Sort_tabs=&Sekmeleri_sırala -Switch_preview_layout=Önizleme_yerleşimini_de&ğiştir +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=Girdi_önzilemesini_aç/kapa&t Toggle_groups_interface=&Grup_arayüzünü_aç/kapat diff --git a/src/main/resources/l10n/Menu_vi.properties b/src/main/resources/l10n/Menu_vi.properties index 7d49458fb27a..599c15fb60dc 100644 --- a/src/main/resources/l10n/Menu_vi.properties +++ b/src/main/resources/l10n/Menu_vi.properties @@ -70,7 +70,8 @@ Select_all=Chọn_tất_&cả Set_up_general_fields=Thiết_lập_các_trường_tổng_&quát Show_error_console=Hiển_thị_cửa_&sổ_báo_lỗi Sort_tabs=Phân_loại_t&hẻ -Switch_preview_layout=&Bật_trình_bày_xem_trước +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=&Bật/tắt_xem_trước_mục Toggle_groups_interface=Bật/tắt_&giao_diện_nhóm diff --git a/src/main/resources/l10n/Menu_zh.properties b/src/main/resources/l10n/Menu_zh.properties index a5d285f896ed..026797329f68 100644 --- a/src/main/resources/l10n/Menu_zh.properties +++ b/src/main/resources/l10n/Menu_zh.properties @@ -70,7 +70,8 @@ Select_all=全选_(&A) Set_up_general_fields=配置_&general_域 Show_error_console=打开错误显示终端 Sort_tabs=标签页排序_(&S) -Switch_preview_layout=切换记录预览方式_(&S) +Next_preview_layout= +Previous_preview_layout= # Export menu Toggle_entry_preview=打开/关闭记录预览_(&T) Toggle_groups_interface=打开/关闭分组界面_(&G) diff --git a/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java b/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java new file mode 100644 index 000000000000..d3152232127f --- /dev/null +++ b/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java @@ -0,0 +1,28 @@ +package net.sf.jabref.logic.citationstyle; + +import net.sf.jabref.logic.util.TestEntry; + +import org.junit.Assert; +import org.junit.Test; + + +public class CitationStyleTest { + + @Test + public void getDefault() throws Exception { + Assert.assertNotNull(CitationStyle.getDefault()); + } + + @Test + public void testDefaultCitation() { + String citation = CitationStyleGenerator.generateCitation(TestEntry.getTestEntry(), CitationStyle.getDefault().getSource()); + String expected = "
\n" + + "
[1]
" + + "B. Smith, B. Jones, and J. Williams, “Title of the test entry,” " + + "BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016.
\n" + + "
\n"; + + Assert.assertEquals(citation, expected); + } + +}