New upstream release.
authorgregor herrmann <gregoa@debian.org>
Wed, 9 Mar 2011 19:31:39 +0000 (19:31 -0000)
committergregor herrmann <gregoa@debian.org>
Wed, 9 Mar 2011 19:31:39 +0000 (19:31 -0000)
12 files changed:
CHANGELOG
OOPlugin-jabref.php [new file with mode: 0644]
OOPlugin.html [deleted file]
build.xml
debian/changelog
example_style_file.jstyle
net/sf/jabref/oo/OOBibBase.java
net/sf/jabref/oo/OOBibStyle.java
net/sf/jabref/oo/OOTestPanel.java [new file with mode: 0755]
net/sf/jabref/oo/StyleDirectoriesPanel.java [new file with mode: 0755]
net/sf/jabref/oo/StyleSelectDialog.java [new file with mode: 0755]
plugin.xml

index aac278796ff84c3acff72ca77950ec5e60a73172..bae3b2dcd4c937f27b45c341495435b605e6e074 100755 (executable)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,11 @@
-
+0.8:
+ - Added some explanatory text to style selection dialog.
+ - Added context menu for style list that allows quickly opening a style file in an external
+   editor.
+ - Introduced optional double quotes for style file properties.
+ - Removed extra space between number marker and rest of citation in numbered reference
+   list.
+ - Fixed bug: update crash caused by reference marks not related to JabRef. 
 0.7.4:
  - Added optional citation property "AuthorLastSeparatorInText" which, if present,
    overrides "AuthorLastSeparator" for in-text author-year citations.
diff --git a/OOPlugin-jabref.php b/OOPlugin-jabref.php
new file mode 100644 (file)
index 0000000..1d9a794
--- /dev/null
@@ -0,0 +1,472 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+  <title>OpenOffice plugin for JabRef</title>
+  <link href="css/style.css" rel="stylesheet" type="text/css" />
+</head>
+
+<body>
+  <div id="main">
+    <div id="container">
+
+      <?php include("navigation.php"); ?>
+
+      <h1>OpenOffice plugin for JabRef</h1>
+
+      <h2>Introduction</h2>
+
+      <p>This plugin offers an interface for inserting citations and formatting a Bibliography in an OpenOffice writer document from JabRef.</p>
+
+      <h2>How to use the plugin</h2>
+
+      <p>The plugin can be used with JabRef 2.4 or newer. If your JabRef version doesn't have a plugin manager (versions 2.4.x), you need to put the plugin jar file in a directory named <code>plugins</code> below the directory where the JabRef jar file is installed (typically under <code>C:\Program files\Jabref 2.x</code> if you are running under Windows). The plugin should be loaded next time you start JabRef, and an item named <b>OpenOffice.org panel</b> should appear in JabRef's <b>Plugins</b> menu.</p>
+
+      <p>The plugin should work with OpenOffice versions 2.4.x and 3.x, provided it is installed with Java support (this is usually the case on Windows, while in some Linux distributions you need to install a separate package named <code>openoffice.org-java-common</code> or something similar).</p>
+
+      <h2>Updates</h2>
+      <ul>
+       <li>2010-06-03: Version 0.8: Style file format now allows optional double quotes aroung property values.</li>
+        <li>2010-05-12: Version 0.7.4: Added a couple of new citation properties: AuthorLastSeparatorInText and MultiCiteChronological</li>
+        <li>2010-03-04: Version 0.7.3: Added support for &lt;smallcaps&gt; tag to indicate small caps in reference list. Several bug fixes.</li>
+        <li>2010-02-02: Version 0.7.2: Added MaxAuthorsFirst property to override MaxAuthors the first time each citation appears.</li>
+        <li>2009-10-07: Version 0.7.1: Several important bug fixes.</li>
+        <li>2009-08-26: Version 0.7: BibTeX fields are now preprocessed to handle LaTeX \textit and \textbf commands and character sequences. <b>NOTE: it is no longer necessary to run FormatChars on fields.</b></li>
+        <li>2009-08-23: Version 0.6: Improved handling of undefined BibTeX keys. Added option to not sync automatically when adding citation.</li>
+        <li>2009-08-05: Version 0.5: Fixed connection problem on Mac. Fixed bug in merge function.</li>
+        <li>2009-06-03: Version 0.4: Added support for superscript/subscript tags in reference list, subscripted citations and different brackets for numbering in the reference list.</li>
+        <li>2009-05-17: Version 0.3: Added MinimumGroupingCount property. Some GUI changes.</li>
+        <li>2009-04-02: Version 0.2.1: Fixed bug in sorting of reference list.</li>
+        <li>2009-03-01: Version 0.2: Better sorting of citations in captions, tables and footnotes.</li>
+        <li>2009-02-25: Version 0.1.9: Added support for bold/italic citation markers, and for citations in table cells and footnotes.</li>
+        <li>2008-12-21: Version 0.1.2: Added invisible citations. Merged citations are now sorted.</li>
+        <li>2008-11-19: Version 0.1.1: Improved handling of OpenOffice shutdown and reconnect.</li>
+        <li>2008-10-25: Version 0.1: User interface improvements. Can now select which Writer document to work with.</li>
+        <li>2008-10-19: Version 0.0.9: Enabled connection to OpenOffice.org 3. Streamlined connection process.</li>
+        <li>2008-09-03: Version 0.0.8: No major changes, but packaged with JabRef 2.4.</li>
+        <li>2008-02-20: Version 0.0.7: New interface for style selection. Styles can now specify paragraph format.</li>
+        <li>2008-02-13: Version 0.0.6: Sorting and grouping of number citation markers.</li>
+        <li>2008-02-06: Version 0.0.5: Modified style file format. Fixed bug in handling names with elements like "van der".</li>
+        <li>2008-01-09: Version 0.0.4: Style file is now automatically reloaded if modified.</li>
+        <li>2007-12-17: Version 0.0.3: From this version, we bypass OO's built-in bibliographic system.</li>
+        <li>2007-12-04: Version 0.0.2</li>
+        <li>2007-12-01: Version 0.0.1</li>
+      </ul>
+
+      <h2>Downloads</h2>
+
+      <p><a href="plugins/net.sf.jabref.oo.ooplugin-0.8.jar">The plugin.</a></p>
+
+      <p><a href="plugins/JabRef-oo-0.8-src.zip">Plugin source code.</a> The source code tree includes four OpenOffice.org jars and JabRef 2.6. The plugin is built using an included Ant build file.</p>
+
+      <p><a href="plugins/example_style_file.jstyle">Example style file</a></p>
+
+      <p>The plugin is distributed under the terms of the GNU <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">General Public License</a>, version 2 or later.</p>
+
+      <h2>Using the OpenOffice interface</h2>
+
+      <p>To communicate with OpenOffice, the OO plugin must first connect to a running OpenOffice instance. You need to start OpenOffice and enter your document before connecting from JabRef. The plugin needs to know the location of your OpenOffice executable (<b>soffice.exe</b> on Windows, and <b>soffice</b> on other platforms), and the directory where several OpenOffice jar files reside. If you connect by clicking the <b>Connect</b> button, the plugin will try to automatically determine these locations. If this does not work, you need to connect using the <b>Manual connect</b> button, which will open a window asking you for the needed locations.</p>
+
+      <p>After the connection has been established, you can insert citations by selecting one or more entries in JabRef and using the <b>Push to OpenOffice</b> button in the dropdown menu of JabRef's toolbar, or by using the appropriate button in the OpenOffice plugin panel in the side pane. This will insert citations for the selected entries at the current cursor position in the OpenOffice document, and update the bibliography to contain the full reference.</p>
+
+      <p><b>Note:</b> JabRef does not use OpenOffice's built-in bibliography system, because of the limitations of that system. A document containing citations inserted from JabRef will not generally be compatible with other reference managers such as Bibus and Zotero.</p>
+
+      <p>Two different types of citations can be inserted - either a citation in parenthesis, "(Author 2007)", or an in-text citation, "Author (2007)". This distinction is only meaningful if author-year citations are used instead of numbered citations, but the distinction will be preserved if you switch between the two styles.</p>
+
+      <p>If you modify entries in JabRef after inserting their citations into OpenOffice, you will need to synchronize the bibliography. The <b>Sync OO bibliography</b> button will update all entries of the bibliography, provided their BibTeX keys have not been altered (JabRef encodes the BibTeX key into the reference name for each citation to keep track of which BibTeX key the original JabRef entry has).</p>
+
+      <h2>The style file</h2>
+
+      <p>You need to select a style file before connecting to OpenOffice - an external file which is selected using a standard file dialog. The style file defines the format of citations and the format of the bibliography. You can use standard JabRef export formatters to process entry fields before they are sent to OpenOffice. Through the style file, the intention is to give as much flexibility in citation styles as possible.</p>
+
+      <p>Here is an example style file:</p>
+<pre>
+NAME
+Example style file for JabRef-oo plugin.
+
+JOURNALS
+Journal name 1
+Journal name 2
+
+PROPERTIES
+Title="References"
+IsSortByPosition="false"
+IsNumberEntries="false"
+ReferenceParagraphFormat="Default"
+ReferenceHeaderParagraphFormat="Heading 1"
+
+CITATION
+AuthorField="author/editor"
+YearField="year"
+MaxAuthors="3"
+MaxAuthorsFirst="3"
+AuthorSeparator=", "
+AuthorLastSeparator=" &amp; "
+EtAlString=" et al."
+YearSeparator=" "
+InTextYearSeparator=" "
+BracketBefore="["
+BracketAfter="]"
+BracketBeforeInList="["
+BracketAfterInList="]"
+CitationSeparator="; "
+UniquefierSeparator=","
+GroupedNumbersSeparator="-"
+MinimumGroupingCount="3"
+FormatCitations="false"
+ItalicCitations="false"
+BoldCitations="false"
+SuperscriptCitations="false"
+SubscriptCitations="false"
+MultiCiteChronological="false"
+
+LAYOUT
+article=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}
+(&lt;b&gt;\year\uniq&lt;/b&gt;). &lt;i&gt;\title&lt;/i&gt;, \journal \volume\begin{pages} :
+\format[FormatPagesForHTML]{\pages}\end{pages}.
+
+book=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}\begin{editor}
+\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.)\end{editor},
+&lt;b&gt;\year\uniq&lt;/b&gt;. &lt;i&gt;\title&lt;/i&gt;. \publisher, \address.
+
+incollection=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}
+(&lt;b&gt;\year\uniq&lt;/b&gt;). &lt;i&gt;\title&lt;/i&gt;. In: \format[AuthorLastFirst,
+AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.), &lt;i&gt;\booktitle&lt;/i&gt;, \publisher.
+
+inbook=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}
+(&lt;b&gt;\year\uniq&lt;/b&gt;). &lt;i&gt;\chapter&lt;/i&gt;. In: \format[AuthorLastFirst,
+AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.), &lt;i&gt;\title&lt;/i&gt;, \publisher.
+
+phdthesis=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}
+(&lt;b&gt;\year\uniq&lt;/b&gt;). &lt;i&gt;\title&lt;/i&gt;, \school.
+
+default=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}
+(&lt;b&gt;\year\uniq&lt;/b&gt;). &lt;i&gt;\title&lt;/i&gt;, \journal \volume\begin{pages} :
+\format[FormatPagesForHTML]{\pages}\end{pages}.
+
+</pre>
+
+        <p>(Note that the layout for each entry type must be constrained to a single line in the style file - above, the lines are broken up to improve readability.)</p>
+
+                       <h3>Global properties</h3>
+
+        <p>The <b>PROPERTIES</b> section describes global properties for the bibliography.
+        The following table describes the available properties:
+
+                       <table border=1 rules=none>
+                       <tr>
+                       <td><b>Property</b></td>
+                       <td><b>Type</b></td>
+                       <td><b>Default value</b></td>
+                       <td><b>Description</b></td>
+                       </tr>
+                       <tr>
+                       <td>IsNumberEntries</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>Determines the type of citations to use. If <code>true</code>, number citations will be
+                       used. If <code>false</code>, author-year citations will be used.</td>
+                       </tr>
+                       <tr>
+                       <td>IsSortByPosition</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>Determines how the bibliography is sorted. If true, the entries
+          will be sorted according to the order in which they are cited. If false, the entries will be
+         sorted alphabetically by authors.</td>
+                       </tr>
+                       <tr>
+                       <td>ReferenceParagraphFormat</td>
+                       <td>string</td>
+                       <td><code>Default</code></td>
+                       <td>Gives the name of the paragraph format to be used for the reference list. This format
+                       must be defined in your OpenOffice document.</td>
+                       </tr>
+                       <tr>
+                       <td>ReferenceHeaderParagraphFormat</td>
+                       <td>string</td>
+                       <td><code>Heading 1</code></td>
+                       <td>Gives the name of the paragraph format to be used for the headline of the reference list. 
+                       This format must be defined in your OpenOffice document.</td>
+                       </tr>
+                       <tr>
+                       <td>Title</td>
+                       <td>string</td>
+                       <td><code>Bibliography</code></td>
+                       <td>The text to enter as the headline of the reference list.</td>
+                       </tr>
+                       </table></p>
+                       
+                       <h3>Citation properties</h3>
+
+        <p>The <b>CITATION</b> section describes the format of the citation markers inserted into the text.
+        
+        <p>The following table gives a brief description of all the available citation properties. Properties that are not
+                 given in the style file will keep their default value.
+                 
+                 <table border=1 rules=none>
+                       <tr>
+                       <td><b>Property</b></td>
+                       <td><b>Type</b></td>
+                       <td><b>Default value</b></td>
+                       <td><b>Description</b></td>
+                       </tr>
+                       <tr>
+                       <td>AuthorField</td>
+                       <td>string</td>
+                       <td><code>author/editor</code></td>
+                       <td>BibTeX field containing author names. Can specify fallback field, e.g. <code>author/editor</code></td>
+                       </tr>
+                       <tr>
+                       <td>AuthorLastSeparator</td>
+                       <td>string</td>
+                       <td><code> & </code></td>
+                       <td>Text inserted between the two last author names.</td>
+                       </tr>
+                       <tr>
+                       <td>AuthorLastSeparatorInText</td>
+                       <td>string</td>
+                       <td>&nbsp;</td>
+                       <td>If specified, this propery overrides <code>AuthorLastSeparator</code> for in-text citations such as
+                       <code>Smith & Jones (2001)</code>.</td>
+                       </tr>
+                       <tr>
+                       <td>AuthorSeparator</td>
+                       <td>string</td>
+                       <td><code>, </code></td>
+                       <td>Text inserted between author names except the last two.</td>
+                       </tr>
+                       <tr>
+                       <td>BoldCitations</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>If <code>FormatCitations</code> is on, controls whether citations should be bold.</td>
+                       </tr>
+                       <tr>
+                       <td>BracketAfter</td>
+                       <td>string</td>
+                       <td><code>]</code></td>
+                       <td>The closing bracket of citations.</td>
+                       </tr>
+                       <tr>
+                       <td>BracketAfterInList</td>
+                       <td>string</td>
+                       <td>]</td>
+                       <td>The closing bracket for citation numbering in the reference list.</td>
+                       </tr>
+                       <tr>
+                       <td>BracketBefore</td>
+                       <td>string</td>
+                       <td><code>[</code></td>
+                       <td>The opening bracket of citations</td>
+                       </tr>
+                       <tr>
+                       <td>BracketBeforeInList</td>
+                       <td>string</td>
+                       <td>[</td>
+                       <td>The opening bracket for citation numbering in the reference list.</td>
+                       </tr>
+                       <tr>
+                       <td>CitationSeparator</td>
+                       <td>string</td>
+                       <td><code>; </code></td>
+                       <td>Text inserter between items when a citation contains multiple entries, e.g. <code>[Smith 2001; Jones 2002]</code></td>
+                       </tr>
+                       <tr>
+                       <td>EtAlString</td>
+                       <td>string</td>
+                       <td><code> et al. </code></td>
+                       <td>Text inserted after author names when not all authors are listed, e.g. <code>[Smith et al. 2001]</code></td>
+                       </tr>
+                       <tr>
+                       <td>FormatCitations</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>Determines whether formatting should be applied to citations. If true, formatting is controlled by
+                       properties like <code>BoldCitations</code>, <code>ItalicCitations</code>, <code>SubscriptCitations</code> 
+                       and <code>SuperscriptCitations</code>.</td>
+                       </tr>
+                       <tr>
+                       <td>GroupedNumbersSeparator</td>
+                       <td>string</td>
+                       <td><code>-</code></td>
+                       <td>Text inserted between numbers when numbered citations are grouped, e.g. <code>[4-6]</code></td>
+                       </tr>
+                       <tr>
+                       <td>InTextYearSeparator</td>
+                       <td>string</td>
+                       <td><code> </code></td>
+                       <td>Text inserted between author names and starting bracket before year in in-text citations.</td>
+                       </tr>
+                       <tr>
+                       <td>ItalicCitations</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>If <code>FormatCitations</code> is on, controls whether citations should be in italics.</td>
+                       </tr>
+                       <tr>
+                       <td>MaxAuthors</td>
+                       <td>integer</td>
+                       <td><code>3</code></td>
+                       <td>The maximum number of authors to list in a citation that has appeared earlier in the document.</td>
+                       </tr>
+                       <tr>
+                       <td>MaxAuthorsFirst</td>
+                       <td>integer</td>
+                       <td><code>3</code></td>
+                       <td>The maximum number of authors to list in a citation when appearing for the first time.</td>
+                       </tr>
+                       <tr>
+                       <td>MinimumGroupingCount</td>
+                       <td>integer</td>
+                       <td><code>3</code></td>
+                       <td>The minimum number of consecutive entries a citation should contain before the numbers are grouped, 
+                       e.g. <code>[4-6]</code> vs. <code>[4; 5; 6]</code>.</td>
+                       </tr>
+                       <tr>
+                       <td>MultiCiteChronological</td>
+                       <td>boolean</td>
+                       <td><code>true</code></td>
+                       <td>If <code>true</code>, multiple entries in the same citation are sorted chronologically, otherwise
+                       they are sorted alphabetically.</td>
+                       </tr>
+                       <td>SubscriptCitations</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>If <code>FormatCitations</code> is on, controls whether citations should be in subscript.</td>
+                       </tr>
+                       <td>SuperscriptCitations</td>
+                       <td>boolean</td>
+                       <td><code>false</code></td>
+                       <td>If <code>FormatCitations</code> is on, controls whether citations should be in superscript.</td>
+                       </tr>
+                       <tr>
+                       <td>UniquefierSeparator</td>
+                       <td>string</td>
+                       <td><code>, </code></td>
+                       <td>Text inserted between letters used to differentiate citations with similar authors and year. E.g.
+                       the text between <code>a</code> and <code>b</code> in <code>[Smith 2001a, b]</code>.</td>
+                       </tr>
+                       <tr>
+                       <td>YearField</td>
+                       <td>string</td>
+                       <td><code>year</code></td>
+                       <td>The BibTeX field to get publication year from.</td>
+                       </tr>
+                       <tr>
+                       <td>YearSeparator</td>
+                       <td>string</td>
+                       <td><code> </code></td>
+                       <td>Text inserted between author names and year in parenthesis citations such as <code>[Smith 2001]</code>.</td>
+                       </tr>
+                       
+                       </table></p>
+
+        If numbered entries are used, the <code>BracketBefore</code> and <code>BracketAfter</code> properties
+        are the most important - they define which characters the citation number is wrapped in. The citation is composed
+        as follows:<br />
+            <code>[BracketBefore][Number][BracketAfter]</code><br />
+        where [Number] is the number of the citation, determined according to the ordering of the bibliography and/or
+        the position of the citation in the text. If a citation refers to several entries, these will be separated
+        by the string given in the property <code>CitationSeparator</code> (for instance, if <code>CitationSeparator</code>=;,
+        the citation could look like <code>[2;4;6]</code>). If two or more of the entries have a series of consecutive
+        numbers, the numbers can be grouped (for instance <code>[2-4]</code> for 2, 3 and 4 or <code>[2;5-7]</code> for
+        2, 5, 6 and 7). The property <code>GroupedNumbersSeparator</code> (default <code>-</code>) determines which string separates the first and last
+        of the grouped numbers. The integer property <code>MinimumGroupingCount</code> (default 3) determines what number of
+        consecutive numbers are required before entries are grouped. If <code>MinimumGroupingCount</code>=3, the numbers
+        2 and 3 will not be grouped, while 2, 3, 4 will be. If <code>MinimumGroupingCount</code>=0, no grouping will be
+        done regardless of the number of consecutive numbers.
+        </p>
+        <p>If numbered entries are not used, author-year citations will be created based on the citation properties.
+        A parenthesis citation is composed as follows:<br />
+            <code>[BracketBefore][Author][YearSeparator][Year][BracketAfter]</code><br />
+        where [Author] is the result of looking up the field or fields given in the <code>AuthorField</code> property,
+        and formatting a list of authors. The list can contain up to <code>MaxAuthors</code> names - if more are present,
+        the list will be composed as the first author plus the text specified in the property <code>EtAlString</code>.
+       If the property <code>MaxAuthorsFirst</code> is given, it overrides <code>MaxAuthors</code> the first time each
+        citation appears in the text.</p>
+       <p>If several, slash-separated, fields are given in the <code>AuthorField</code> property, they will be looked up
+        successively if the first field is empty for the given BibTeX entry. In the example above, the "author" field will
+        be used, but if empty, the "editor" field will be used as a backup.</p>
+        <p>The names in the author list will be separated by the text given by the <code>AuthorSeparator</code>
+        property, except for the last two names, which will be separated by the text given by <code>AuthorLastSeparator</code>.
+       If the property <code>AuthorLastSeparatorInText</code> is given, it overrides the former for citations of the in-text
+        type. This makes it possible to get citations like <code>(Olsen &amp; Jensen, 2008)</code> and <code>Olsen and Jensen (2008)</code>
+        for the same style.
+        </p>
+        <p>[Year] is the result of looking up the field or fields given in the [YearField] property.</p>
+        <p>An in-text citation is composed as follows:<br />
+            <code>[Author][InTextYearSeparator][BracketBefore][Year][BracketAfter]</code><br />
+        where [Author] and [Year] are resolved in exactly the same way as for the parenthesis citations.
+        </p>
+        <p>If two different cited sources have the same authors and publication year, and author-year citations are used,
+        their markers will need modification in order to be distinguishable. This is done automatically by appending a
+        letter after the year for
+        each of the publications; 'a' for the first cited reference, 'b' for the next, and so on.
+        For instance, if the author "Olsen" has two cited papers from 2005, the citation markers will be modified to
+        <code>(Olsen, 2005a)</code> and <code>(Olsen, 2005b)</code>. In the bibliography
+        layout, the placement of the "uniquefier" letter is indicated explicitly by inserting the virtual field
+        <code>uniq</code>.</p>
+        <p>If several entries that have been "uniquefied" are cited together, they will be grouped in the citation
+        marker. For instance, of the two entries in the example above are cited together, the citation marker will
+        be <code>(Olsen, 2005a, b)</code> rather than <code>Olsen, 2005a; Olsen, 2005b)</code>. The grouped uniquefier
+        letters (a and b in our example) will be separated by the string specified by the <code>UniquefierSeparator</code>
+        property.
+        </p>
+       <p>Author-year citations referring more than one entry will by default be sorted chronologically. If you wish them
+       to be sorted alphabetically, the citation property <code>MultiCiteChronological</code> should be set to <code>false.</code>.</p>
+        <p>The property <code>FormatCitations</code> determines whether the citation markers should be formatted with
+        regards to italics, boldness, superscript and subscript. If <code>FormatCitations</code> is false, no such formatting
+        will be done. If true, the citations will be italicized or not depending on the <code>ItalicCitations</code> property, set to bold
+        or not depending on the <code>BoldCitations</code> property, and similar for the <code>SuperscriptCitations</code> and
+        <code>SubscriptCitations</code> properties.</p>
+
+                         
+        <h3>Reference list layout</h3>
+        
+        <p>The <b>LAYOUT</b> section describes how the bibliography entry for each entry type in JabRef
+        should appear. Each line should start with either the name of a BibTeX entry type, or the word
+        <code>default</code>, followed by a '='. The <code>default</code> layout will be used for all
+        entry types for which an explicit layout hasn't been given.</p>
+        <p>The remainder of each line defines the layout, with normal text and spaces appearing literally
+        in the bibliography entry. Information from the BibTeX entry is inserted by adding <code>\field</code> markers
+        with the appropriate field name (e.g. <code>\author</code> for inserting the author names). Formatting
+        information for the field can be included here, following JabRef's standard export layout syntax.
+        Refer to <a href="http://jabref.sourceforge.net/help/CustomExports.php">JabRef's documentation on custom export filters</a>
+        for more information about which formatters are available.</p>
+        <p>If author-year citations are used, you have to explicitly specify the position of the "uniquefier" letter
+        that is added to distinguish similar-looking citations. This is done by including a marker for the virtual field
+        <code>uniq</code>, typically right after the year (as shown in the example style file). The <code>uniq</code>
+        field is automatically set correctly for each entry before its reference text is laid out.
+        </p>
+        <p>To indicate formatting in the bibliography, you can use the HTML-like tag pairs &lt;b&gt; &lt;/b&gt;,
+         &lt;i&gt; &lt;/i&gt;,  &lt;sup&gt; &lt;/sup&gt; and  &lt;sub&gt; &lt;/sub&gt; to specify bold text,
+         italic text, superscript and subscript, respectively.</p>
+        <p>If you are using numbered citations, the number for each entry will be automatically inserted at the start
+        of each entry in the reference list. By default, the numbers will be enclosed in the same brackets defined for
+        citations. The optional citation properties <code>BracketBeforeInList</code> and
+        <code>BracketAfterInList</code> override <code>BracketBefore</code> and <code>BracketAfter</code> if set. These
+        can be used if you want different types of brackets (or no brackets) in the reference list. Note that these need
+        not be brackets as such - they can be any combination of characters.</p>
+
+      <h2>Known issues</h2>
+
+      <ul>
+        <li>When running with JabRef versions older than 2.6, institutional authors wrapped in braces, e.g. <code>{World Bank}</code>, are handled as if no braces were added. This happens because the OO-specific formatter, which removes the braces, can only be run after (instead of before) all other formatters in JabRef 2.6 or newer.</li>
+        <li>Make sure to save your Writer document in OpenDocument format (odt). Saving to Word format will lose your reference marks.</li>
+        <li>There is currently no support for footnote based citations.</li>
+        <li>The cursor may be poorly positioned after inserting a citation.</li>
+        <li>Copy-pasting the example style file directly from this page can give an unparseable file. To avoid this, instead download the example file from the link in the download section.</li>
+      </ul>
+
+      <h2>Contact</h2>
+
+      <p>If you have tested this plugin, and want to give your feedback, or if you want to contribute to the development of the plugin, please contact me at the e-mail address mortenalver at users.sourceforge.net.</p>
+
+    </div>
+    <?php include("footer.php"); ?>
+  </div>
+
+</body>
+</html>
diff --git a/OOPlugin.html b/OOPlugin.html
deleted file mode 100755 (executable)
index dabb3ea..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-<h1>OpenOffice plugin for JabRef</h1>
-
-<h2>Introduction</h2>
-
-       <p><a href="http://jabref.sf.net">JabRef</a> is an open source BibTeX bibliography
-         manager.
-        <p>This plugin offers an interface for inserting citations and formatting a Bibliography in an
-        OpenOffice writer document from JabRef.</p>
-
-
-        <h2>How to use the plugin</h2>
-
-        <p>The plugin can be used with JabRef 2.4 or newer. If your JabRef version doesn't
-        have a plugin manager (versions 2.4.x), you need to put the plugin jar file
-        in a directory named <code>plugins</code> below the directory where the JabRef
-        jar file is installed (typically under <code>C:\Program files\Jabref 2.x</code>
-        if you are running under Windows). The plugin should be loaded next time you
-        start JabRef, and an item named <b>OpenOffice.org panel</b> should appear in
-        JabRef's <b>Plugins</b> menu.
-        <p>The plugin should work with OpenOffice versions 2.4.x and 3.x, provided it
-        is installed with Java support (this is usually the case on Windows, while in
-        some Linux distributions you need to install a separate package named
-        <code>openoffice.org-java-common</code> or something similar).</p>
-
-        <p><b>Updates:</b></p>
-        2010-05-11: Version 0.7.4: Added option to sort alphabetically for citations with multiple entries.<br>
-        2010-03-04: Version 0.7.3: Added support for &lt;smallcaps&gt; tag to indicate small caps in reference list. Several bug fixes.<br>
-        2010-02-02: Version 0.7.2: Added MaxAuthorsFirst property to override MaxAuthors the first time each citation appears.<br>
-        2009-10-07: Version 0.7.1: Several important bug fixes.<br>
-           2009-08-26: Version 0.7: BibTeX fields are now preprocessed to handle LaTeX \textit and \textbf commands and
-          character sequences. <b>NOTE: it is no longer necessary to run FormatChars on fields.</b><br>
-        2009-08-23: Version 0.6: Improved handling of undefined BibTeX keys. Added option to not sync automatically when adding citation.<br>
-        2009-08-05: Version 0.5: Fixed connection problem on Mac. Fixed bug in merge function.<br>
-        2009-06-03: Version 0.4: Added support for superscript/subscript tags in reference list, subscripted citations
-           and different brackets for numbering in the reference list.<br>
-           2009-05-17: Version 0.3: Added MinimumGroupingCount property. Some GUI changes.<br>
-        2009-04-02: Version 0.2.1: Fixed bug in sorting of reference list.<br>
-        2009-03-01: Version 0.2: Better sorting of citations in captions, tables and footnotes.<br> 
-        2009-02-25: Version 0.1.9: Added support for bold/italic citation markers, and for citations in table cells and footnotes.<br>
-        2008-12-21: Version 0.1.2: Added invisible citations. Merged citations are now sorted.<br>
-           2008-11-19: Version 0.1.1: Improved handling of OpenOffice shutdown and reconnect.<br>
-           2008-10-25: Version 0.1: User interface improvements. Can now select which Writer document to work with.<br>
-        2008-10-19: Version 0.0.9: Enabled connection to OpenOffice.org 3. Streamlined connection process.<br>
-        2008-09-03: Version 0.0.8: No major changes, but packaged with JabRef 2.4.<br>
-        2008-02-20: Version 0.0.7: New interface for style selection. Styles can now specify paragraph format.<br>
-        2008-02-13: Version 0.0.6: Sorting and grouping of number citation markers.<br>
-        2008-02-06: Version 0.0.5: Modified style file format. Fixed bug in handling names with elements like "van der".<br>
-        2008-01-09: Version 0.0.4: Style file is now automatically reloaded if modified.<br>
-        2007-12-17: Version 0.0.3: From this version, we bypass OO's built-in bibliographic system.<br>
-        2007-12-04: Version 0.0.2<br>
-        2007-12-01: Version 0.0.1<br>
-
-        <p><b>Downloads:</b></p>
-        <p><a href="net.sf.jabref.oo.ooplugin-0..jar">The plugin.</a></p>
-        <p><a href="JabRef-oo-0.6-src.zip">Plugin source code.</a> The source code tree includes four
-        OpenOffice.org jars and JabRef 2.5. The plugin is built using
-        an included Ant build file.</p>
-        <p><a href="example_style_file.jstyle">Example style file</a></p>
-
-        <p>The plugin is distributed under the terms of the GNU
-        <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">General Public License</a>,
-        version 2 or later.</p>
-
-        <h2>Using the OpenOffice interface</h2>
-
-        <p>To communicate with OpenOffice, the OO plugin must first connect to a running OpenOffice
-        instance. You need to start OpenOffice and enter your document before connecting from
-        JabRef. The plugin needs to know the location of your OpenOffice executable (<b>soffice.exe</b> on
-        Windows, and <b>soffice</b> on other platforms), and the directory where several OpenOffice
-        jar files reside. If you connect by clicking the <b>Connect</b> button, the plugin will try to
-        automatically determine these locations. If this does not work, you need to connect using the
-        <b>Manual connect</b> button, which will open a window asking you for the needed locations.</p>
-
-        <p>After the connection has been established, you can insert citations by selecting one or more
-        entries in JabRef and using the <b>Push to OpenOffice</b> button in the dropdown menu of JabRef's
-        toolbar, or by using the appropriate button in the OpenOffice plugin panel in the side pane. This
-        will insert citations for the selected entries at the current cursor position in the OpenOffice
-        document, and update the bibliography to contain the full reference.</p>
-
-        <p><b>Note:</b> JabRef does not use OpenOffice's built-in bibliography system, because of the
-        limitations of that system. A document containing citations inserted from JabRef will
-        not generally be compatible with other reference managers such as Bibus and Zotero.</p>
-
-        <p>Two different types of citations
-        can be inserted - either a citation in parenthesis, "(Author 2007)", or an in-text citation,
-        "Author (2007)". This distinction is only meaningful if author-year citations are used instead of
-        numbered citations, but the distinction will be preserved if you switch between the two styles.</p>
-
-        <p>If you modify entries in JabRef after inserting their citations into OpenOffice, you will
-        need to synchronize the bibliography. The <b>Sync OO bibliography</b> button will update all
-        entries of the bibliography, provided their BibTeX keys have not been altered (JabRef encodes the
-        BibTeX key into the reference name for each citation to keep track of which BibTeX key
-        the original JabRef entry has).</p>
-
-        <h3>The style file</h3>
-
-        You need to select a style file before connecting to OpenOffice - an external file which is selected
-        using a standard file dialog. The style file defines the
-        format of citations and the format of the bibliography. You can use standard JabRef export
-        formatters to process entry fields before they are sent to OpenOffice.
-        Through the style file, the intention is to give as much flexibility in citation styles as possible.
-        
-        <p>Here is an example style file:</p>
-        <code><pre>
-NAME
-Example style file for JabRef-oo plugin.
-
-JOURNALS
-Journal name 1
-Journal name 2
-
-PROPERTIES
-Title=References
-IsSortByPosition=false
-IsNumberEntries=false
-ReferenceParagraphFormat=Default
-ReferenceHeaderParagraphFormat=Heading 1
-
-CITATION
-AuthorField=author/editor
-YearField=year
-MaxAuthors=3
-MaxAuthorsFirst=6
-AuthorSeparator=,
-AuthorLastSeparator= &
-EtAlString= et al.
-YearSeparator=
-InTextYearSeparator=
-BracketBefore=[
-BracketAfter=]
-BracketBeforeInList=[
-BracketAfterInList=]
-CitationSeparator=;
-UniquefierSeparator=,
-GroupedNumbersSeparator=-
-MinimumGroupingCount=3
-FormatCitations=false
-ItalicCitations=false
-BoldCitations=false
-SuperscriptCitations=false
-SubscriptCitations=false
-
-
-LAYOUT
-article=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author} (&lt;b&gt;\year\uniq</b>). &lt;i&gt;\title</i>, \journal \volume\begin{pages} : \format[FormatPagesForHTML]{\pages}\end{pages}.
-
-book=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}\begin{editor}\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.)\end{editor}, &lt;b&gt;\year\uniq</b>. &lt;i&gt;\title</i>. \publisher, \address.
-
-incollection=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author} (&lt;b&gt;\year\uniq</b>). &lt;i&gt;\title</i>. In: \format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.), &lt;i&gt;\booktitle</i>, \publisher.
-
-inbook=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author} (&lt;b&gt;\year\uniq</b>). &lt;i&gt;\chapter</i>. In: \format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\editor} (Ed.), &lt;i&gt;\title</i>, \publisher.
-
-phdthesis=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author} (&lt;b&gt;\year\uniq</b>). &lt;i&gt;\title</i>, \school.
-
-default=\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author} (&lt;b&gt;\year\uniq</b>). &lt;i&gt;\title</i>, \journal \volume\begin{pages} : \format[FormatPagesForHTML]{\pages}\end{pages}.
-
-</pre>
-
-<p>(Note that the layout for each entry type must be constrained to a single line in the style file - above, the lines are broken up to improve readability.)</p>
-        </code>
-
-        <p>The <b>PROPERTIES</b> section describes global properties for the bibliography:
-            <ul><li><code>Title</code>: determines the header text for the bibliography.</li></ul>
-            <ul><li><code>IsSortByPosition</code>: determines how the bibliography is sorted. If true, the entries
-                will be sorted according to the order in which they are cited. If false, the entries will be
-                sorted alphabetically by authors.</li></ul>
-            <ul><li><code>IsNumberEntries</code>: determines the type of citations to use. If true, number
-                citations will be used. The citation numbers will be included in the bibliography as well.
-                If false, author-year citations will be used.</li></ul>
-        </p>
-
-        <p>The <b>CITATION</b> section describes the format of the citation markers inserted into the text.
-        If numbered entries are used, only the <code>BracketBefore</code> and <code>BracketAfter</code> properties
-        are relevant - they define which characters the citation number is wrapped in. The citation is composed
-        as follows:<br>
-            [BracketBefore][Number][BracketAfter]<br>
-        where [Number] is the number of the citation, determined according to the ordering of the bibliography and/or
-        the position of the citation in the text. If a citation refers to several entries, these will be separated
-        by the string given in the property <code>CitationSeparator</code> (for instance, if <code>CitationSeparator</code>=;,
-        the citation could look like <code>[2;4;6]</code>). If two or more of the entries have a series of consecutive
-        numbers, the numbers can be grouped (for instance <code>[2-4]</code> for 2, 3 and 4 or <code>[2;5-7]</code> for
-        2, 5, 6 and 7). The property <code>GroupedNumbersSeparator</code> (default <code>-</code>) determines which string separates the first and last
-        of the grouped numbers. The integer property <code>MinimumGroupingCount</code> (default 3) determines what number of
-        consecutive numbers are required before entries are grouped. If <code>MinimumGroupingCount</code>=3, the numbers
-        2 and 3 will not be grouped, while 2, 3, 4 will be. If <code>MinimumGroupingCount</code>=0, no grouping will be
-        done regardless of the number of consecutive numbers.
-        </p>
-        <p>If numbered entries are not used, author-year citations will be created based on the citation properties.
-        A parenthesis citation is composed as follows:<br>
-            [BracketBefore][Author][YearSeparator][Year][BracketAfter]<br>
-        where [Author] is the result of looking up the field or fields given in the <code>AuthorField</code> property,
-        and formatting a list of authors. The list can contain up to <code>MaxAuthors</code> names - if more are present,
-        the list will be composed as the first author plus the text specified in the property <code>EtAlString</code>.
-        If several, slash-separated, fields are given in the <code>AuthorField</code> property, they will be looked up
-        successively if the first field is empty for the given BibTeX entry. In the example above, the "author" field will
-        be used, but if empty, the "editor" field will be used as a backup.
-        <p>The names in the author list will be separated by the text given by the <code>AuthorSeparator</code>
-        property, except for the last two names, which will be separated by the text given by <code>AuthorLastSeparator</code>.
-        If the property <code>AuthorLastSeparatorInText</code> is given, it overrides the former for citations of the in-text
-        type. This makes it possible to get citations like <code>(Olsen & Jensen, 2008)</code> and <code>Olsen and Jensen (2008)</code>
-        for the same style.
-        </p>
-        <p>[Year] is the result of looking up the field or fields given in the [YearField] property.</p>
-        An in-text citation is composed as follows:<br>
-            [Author][InTextYearSeparator][BracketBefore][Year][BracketAfter]<br>
-        where [Author] and [Year] are resolved in exactly the same way as for the parenthesis citations.
-        </p>
-        <p>If two different cited sources have the same authors and publication year, and author-year citations are used,
-        their markers will need modification in order to be distinguishable. This is done automatically by appending a
-        letter after the year for
-        each of the publications; 'a' for the first cited reference, 'b' for the next, and so on.
-        For instance, if the author "Olsen" has two cited papers from 2005, the citation markers will be modified to
-        <code>(Olsen, 2005a)</code> and <code>(Olsen, 2005b)</code>. In the bibliography
-        layout, the placement of the "uniquefier" letter is indicated explicitly by inserting the virtual field
-        <code>uniq</code>.</p>
-        <p>If several entries that have been "uniquefied" are cited together, they will be grouped in the citation
-        marker. For instance, of the two entries in the example above are cited together, the citation marker will
-        be <code>(Olsen, 2005a, b)</code> rather than <code>Olsen, 2005a; Olsen, 2005b)</code>. The grouped uniquefier
-        letters (a and b in our example) will be separated by the string specified by the <code>UniquefierSeparator</code>
-        property.
-        </p>
-        <p>The property <code>FormatCitations</code> determines whether the citation markers should be formatted with
-        regards to italics, boldness, superscript and subscript. If <code>FormatCitations</code> is false, no such formatting
-        will be done. If true, the citations will be italicized or not depending on the <code>ItalicCitations</code> property, set to bold
-        or not depending on the <code>BoldCitations</code> property, and similar for the <code>SuperscriptCitations</code> and
-        <code>SubscriptCitations</code> properties.</p>
-        <p>The <b>LAYOUT</b> section describes how the bibliography entry for each entry type in JabRef
-        should appear. Each line should start with either the name of a BibTeX entry type, or the word
-        <code>default</code>, followed by a '='. The <code>default</code> layout will be used for all
-        entry types for which an explicit layout hasn't been given.</p>
-        <p>The remainder of each line defines the layout, with normal text and spaces appearing literally
-        in the bibliography entry. Information from the BibTeX entry is inserted by adding <code>\field</code> markers
-        with the appropriate field name (e.g. <code>\author</code> for inserting the author names). Formatting
-        information for the field can be included here, following JabRef's standard export layout syntax.
-        Refer to <a href="http://jabref.sourceforge.net/help/CustomExports.php">JabRef's documentation on custom export filters</a>
-        for more information about which formatters are available.</p>
-        <p>If author-year citations are used, you have to explicitly specify the position of the "uniquefier" letter
-        that is added to distinguish similar-looking citations. This is done by including a marker for the virtual field
-        <code>uniq</code>, typically right after the year (as shown in the example style file). The <code>uniq</code>
-        field is automatically set correctly for each entry before its reference text is laid out.
-        </p>
-        <p>To indicate formatting in the bibliography, you can use the HTML-like tag pairs &lt;b&gt; &lt;/b&gt;,
-         &lt;i&gt; &lt;/i&gt;,  &lt;sup&gt; &lt;/sup&gt; and  &lt;sub&gt; &lt;/sub&gt; to specify bold text,
-         italic text, superscript and subscript, respectively.</p>
-        <p>If you are using numbered citations, the number for each entry will be automatically inserted at the start
-        of each entry in the reference list. By default, the numbers will be enclosed in the same brackets defined for
-        citations. The optional citation properties <code>BracketBeforeInList</code> and
-        <code>BracketAfterInList</code> override <code>BracketBefore</code> and <code>BracketAfter</code> if set. These
-        can be used if you want different types of brackets (or no brackets) in the reference list. Note that these need
-        not be brackets as such - they can be any combination of characters.</p>
-
-<h2>Known issues</h2>
-
-<ul>
-  <li>Make sure to save your Writer document in OpenDocument format
-  (odt). Saving to Word format will lose your reference marks.</li>
-  <li>There is currently no support for footnote based citations.</li>
-  <li>The cursor may be poorly positioned after inserting a citation.</li>
-  <li>Copy-pasting the example style file directly from this page can give an unparseable
-    file. To avoid this, instead download the example file from the link in the download section.</li>
-</ul>
-
-<h2>Contact</h2>
-
-If you have tested this plugin, and want to give your feedback, or if you
-want to contribute to the development of the plugin, please contact me at the
-e-mail address mortenalver at users.sourceforge.net.
-
-        
index 712e5cbe0ca9bbb2ab0a2ce476bb1aa74ee8feb8..307b830b9594185f34273f6c0cf3e8b688e0e1a1 100755 (executable)
--- a/build.xml
+++ b/build.xml
@@ -12,7 +12,7 @@
 <project name="net.sf.jabref.oo.ooplugin" default="jar" basedir=".">
 
        <!-- Properties -->
-       <property name="version" value="0.7.4" />
+       <property name="version" value="0.8" />
        <property name="build.classes" value="classes" />
        <property name="jabref.build.dir" value="lib" />
     <property name="jar.dir" value="dist" />
index 975e0ecb15706761376c29ba8f83e6e236f6f173..e73961a775f86b2c9a9aad83a7b7786fa8ccfd72 100644 (file)
@@ -1,3 +1,9 @@
+jabref-plugin-oo (0.8+ds-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- gregor herrmann <gregoa@debian.org>  Wed, 09 Mar 2011 20:30:23 +0100
+
 jabref-plugin-oo (0.7.4+ds-4) unstable; urgency=low
 
   * debian/control: add Vcs-* fields.
index 7208ba8208cc8355c4dd0c47f2f3666c0f8d2d7e..dfe93ad39b231d595a90b5de288385f2776db99c 100755 (executable)
@@ -6,37 +6,37 @@ Journal name 1
 Journal name 2
 
 PROPERTIES
-Title=References
-IsSortByPosition=false
-IsNumberEntries=false
-ReferenceParagraphFormat=Text body
-ReferenceHeaderParagraphFormat=Heading 2
+Title="References"
+IsSortByPosition="false"
+IsNumberEntries="false"
+ReferenceParagraphFormat="Text body"
+ReferenceHeaderParagraphFormat="Heading 2"
 
 CITATION
-AuthorField=author/editor
-YearField=year
-MaxAuthors=2
-MaxAuthorsFirst=6
-AuthorSeparator=,
-AuthorLastSeparator= & 
-AuthorLastSeparatorInText= & 
-EtAlString= et al.
-YearSeparator= 
-InTextYearSeparator= 
-BracketBefore=[
-BracketAfter=]
-BracketBeforeInList=[
-BracketAfterInList=]
-CitationSeparator=
-UniquefierSeparator=,
-GroupedNumbersSeparator=-
-MinimumGroupingCount=3
-FormatCitations=false
-ItalicCitations=false
-BoldCitations=false
-SuperscriptCitations=false
-SubscriptCitations=false
-MultiCiteChronological=true
+AuthorField="author/editor"
+YearField="year"
+MaxAuthors="2"
+MaxAuthorsFirst="6"
+AuthorSeparator=","
+AuthorLastSeparator=" & " 
+AuthorLastSeparatorInText=" and "
+EtAlString=" et al."
+YearSeparator=" "
+InTextYearSeparator=" "
+BracketBefore="["
+BracketAfter="]"
+BracketBeforeInList="["
+BracketAfterInList="] "
+CitationSeparator="; "
+UniquefierSeparator=","
+GroupedNumbersSeparator="-"
+MinimumGroupingCount="3"
+FormatCitations="false"
+ItalicCitations="false"
+BoldCitations="false"
+SuperscriptCitations="false"
+SubscriptCitations="false"
+MultiCiteChronological="true"
 
 LAYOUT
 article=<b>\format[AuthorLastFirst,AuthorAbbreviator,AuthorAndsReplacer]{\author}</b> (<b>\year\uniq</b>). <i>\title</i>, \journal \volume\begin{pages} : \format[FormatPagesForHTML]{\pages}\end{pages}.
index 6fbc11d10eb347f6d2add01b749d9995c815d164..dffa92391c1dbec7b2645e7694be3d8a3fabce60 100755 (executable)
@@ -331,6 +331,14 @@ public class OOBibBase {
             names = sortedReferenceMarks;            
         }
 
+        // Remove all reference marks that don't look like JabRef citations:
+        ArrayList<String> tmp = new ArrayList<String>();
+        for (int i = 0; i < names.length; i++) {
+            if (citePattern.matcher(names[i]).find())
+                tmp.add(names[i]);
+        }
+        names = tmp.toArray(new String[tmp.size()]);
+
         HashMap<String,Integer> numbers = new HashMap<String, Integer>();
         //HashMap<S
         int lastNum = 0;
@@ -426,8 +434,10 @@ public class OOBibBase {
                 }
                 citMarkers[i] = citationMarker;
                 normCitMarkers[i] = normCitMarker;
+
             }
 
+
         }
 
         uniquefiers.clear();
@@ -820,7 +830,7 @@ public class OOBibBase {
             if (style.isNumberEntries()) {
                 int minGroupingCount = style.getIntCitProperty("MinimumGroupingCount");
                 OOUtil.insertTextAtCurrentLocation(text, cursor,
-                        style.getNumCitationMarker(new int[] {number++}, minGroupingCount, true)+" ",
+                        style.getNumCitationMarker(new int[] {number++}, minGroupingCount, true),
                         false, false, false, false, false, false);
             }
             Layout layout = style.getReferenceFormat(entry.getType().getName());
index 3cf8b4dd4bdc19e714abfc42d3156903dbc35404..4ee62a6e4d75b4c4b16a57311ec0b5af3b0bb733 100755 (executable)
@@ -62,6 +62,9 @@ public class OOBibStyle implements Comparable {
     private static long styleFileModificationTime = Long.MIN_VALUE;
     private String COMBINED_ENTRIES_SEPARATOR = "-";
 
+    //private Pattern quoted = Pattern.compile("\".*^\\\\\"");
+    private Pattern quoted = Pattern.compile("\".*\"");
+
     public OOBibStyle(File styleFile) throws Exception {
         this(new FileReader(styleFile));
         this.styleFile = styleFile;
@@ -277,6 +280,8 @@ public class OOBibStyle implements Comparable {
         if ((index > 0) && (index <= line.length()-1)) {
             String propertyName = line.substring(0, index).trim();
             String value = line.substring(index+1);
+            if ((value.trim().length() > 2) && quoted.matcher(value.trim()).matches())
+                value = value.trim().substring(1, value.trim().length()-1);
             Object toSet = value;
             if (numPattern.matcher(value).matches()) {
                 toSet = Integer.parseInt(value);
@@ -837,4 +842,6 @@ public class OOBibStyle implements Comparable {
     public boolean equals(Object o) {
         return styleFile.equals(((OOBibStyle)o).styleFile);
     }
+
+
 }
diff --git a/net/sf/jabref/oo/OOTestPanel.java b/net/sf/jabref/oo/OOTestPanel.java
new file mode 100755 (executable)
index 0000000..3b30b33
--- /dev/null
@@ -0,0 +1,838 @@
+package net.sf.jabref.oo;
+
+import com.jgoodies.forms.builder.ButtonBarBuilder;
+import com.jgoodies.forms.builder.ButtonStackBuilder;
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import net.sf.jabref.*;
+import net.sf.jabref.export.layout.Layout;
+import net.sf.jabref.export.layout.LayoutHelper;
+import net.sf.jabref.external.PushToApplication;
+import net.sf.jabref.plugin.SidePanePlugin;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * This test panel can be opened by reflection from JabRef, passing the JabRefFrame as an
+ * argument to the start() method. It displays buttons for testing interaction functions
+ * between JabRef and OpenOffice.
+ */
+public class OOTestPanel extends AbstractWorker implements SidePanePlugin, PushToApplication {
+
+    // This field indicates whether the running JabRef supports post formatters in Layout:
+    public static boolean postLayoutSupported;
+
+    static {
+        postLayoutSupported = true;
+        try {
+            Layout l = new LayoutHelper(new StringReader("")).
+                        getLayoutFromText(Globals.FORMATTER_PACKAGE);
+            l.setPostFormatter(null);
+        } catch (NoSuchMethodError ex) {
+            postLayoutSupported = false;
+        } catch (Exception ex) {
+
+        }
+
+    }
+
+    TestPanel comp;
+    JDialog diag;
+    static JButton
+        connect,
+        manualConnect,
+        selectDocument,
+        setStyleFile = new JButton(Globals.lang("Select style file")),
+        pushEntries = new JButton(Globals.lang("Cite")),
+        pushEntriesInt = new JButton(Globals.lang("Cite in-text")),
+        pushEntriesEmpty = new JButton(Globals.lang("Insert empty citation")),
+        focus = new JButton("Focus OO document"),
+        update,
+        insertFullRef = new JButton("Insert reference text"),
+        merge = new JButton(Globals.lang("Merge citations")),
+        settingsB = new JButton(Globals.lang("Settings")),
+        test = new JButton("Test");
+    JRadioButton inPar, inText;
+    private JPanel settings = null;
+    private static String styleFile = null;
+    private static OOBibBase ooBase;
+    private static JabRefFrame frame;
+    private SidePaneManager manager;
+    private static OOBibStyle style = null;
+    private StyleSelectDialog styleDialog = null;
+    private boolean dialogOkPressed = false, autoDetected = false;
+    private String sOffice = null;
+    private Exception connectException = null;
+
+
+    public OOTestPanel() {
+        ImageIcon connectImage = new ImageIcon(OOTestPanel.class.getResource("/images/connect_no.png"));
+
+        connect = new JButton(connectImage);
+        manualConnect = new JButton(connectImage);
+        connect.setToolTipText(Globals.lang("Connect"));
+        manualConnect.setToolTipText(Globals.lang("Manual connect"));
+        selectDocument = new JButton(GUIGlobals.getImage("open"));
+        selectDocument.setToolTipText(Globals.lang("Select Writer document"));
+        update = new JButton(GUIGlobals.getImage("refresh"));
+        update.setToolTipText(Globals.lang("Sync OO bibliography"));
+        String defExecutable, defJarsDir;
+        if (Globals.ON_WIN) {
+            Globals.prefs.putDefaultValue("ooPath", "C:\\Program Files\\OpenOffice.org 3");
+            Globals.prefs.putDefaultValue("ooExecutablePath", "C:\\Program Files\\OpenOffice.org 2.3\\program\\soffice.exe");
+            Globals.prefs.putDefaultValue("ooJarsPath", "C:\\Program Files\\OpenOffice.org 2.3\\program\\classes");
+        } else if (Globals.ON_MAC) {
+            Globals.prefs.putDefaultValue("ooExecutablePath", "/Applications/OpenOffice.org.app/Contents/MacOS/soffice.bin");
+            Globals.prefs.putDefaultValue("ooPath", "/Applications/OpenOffice.org.app");
+            Globals.prefs.putDefaultValue("ooJarsPath", "/Applications/OpenOffice.org.app/Contents/basis-link");
+        } else { // Linux
+            //Globals.prefs.putDefaultValue("ooPath", "/usr/lib/openoffice");
+            Globals.prefs.putDefaultValue("ooPath", "/opt/openoffice.org3");
+            Globals.prefs.putDefaultValue("ooExecutablePath", "/usr/lib/openoffice/program/soffice");
+            //Globals.prefs.putDefaultValue("ooJarsPath", "/usr/share/java/openoffice");
+            Globals.prefs.putDefaultValue("ooJarsPath", "/opt/openoffice.org/basis3.0");
+        }
+        Globals.prefs.putDefaultValue("connectToOO3", Boolean.TRUE);
+        
+        //Globals.prefs.putDefaultValue("ooStyleFileDirectories", System.getProperty("user.home")+";false");
+        Globals.prefs.putDefaultValue("ooStyleFileLastDir", System.getProperty("user.home"));
+        Globals.prefs.putDefaultValue("ooInParCitation", true);
+        Globals.prefs.putDefaultValue("syncOOWhenCiting", false);
+
+        
+        styleFile = Globals.prefs.get("ooBibliographyStyleFile");
+
+    }
+
+    public SidePaneComponent getSidePaneComponent() {
+        return comp;
+    }
+
+
+    public void init(JabRefFrame frame, SidePaneManager manager) {
+        this.frame = frame;
+        this.manager = manager;
+        comp = new TestPanel(manager, GUIGlobals.getIconUrl("openoffice"), Globals.lang("OpenOffice"));
+        try {
+            initPanel();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public JMenuItem getMenuItem() {
+        JMenuItem item = new JMenuItem("OpenOffice.org panel", GUIGlobals.getImage("openoffice"));
+        item.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                manager.show(getName());
+            }
+        });
+        return item;
+    }
+
+    public String getShortcutKey() {
+        return null;
+    }
+
+
+    private void initPanel() throws Exception {
+
+        connect.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                connect(true);
+            }
+        });
+        manualConnect.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                connect(false);
+            }
+        });
+        selectDocument.setToolTipText(Globals.lang("Select which open Writer document to work on"));
+        selectDocument.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                try {
+                    ooBase.selectDocument();
+                    frame.output(Globals.lang("Connected to document")+": "+ooBase.getCurrentDocumentTitle());
+                } catch (Exception ex) {
+                    JOptionPane.showMessageDialog(frame, ex.getMessage(), Globals.lang("Error"),
+                            JOptionPane.ERROR_MESSAGE);
+                }
+            }
+        });
+
+        setStyleFile.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if (styleDialog == null) {
+                    styleDialog = new StyleSelectDialog(frame, styleFile);
+                }
+                styleDialog.setVisible(true);
+                if (styleDialog.isOkPressed()) {
+                    style = styleDialog.getSelectedStyle();
+                    if (style != null) {
+                        styleFile = style.getFile().getPath();
+                        Globals.prefs.put("ooBibliographyStyleFile", styleFile);
+                    }
+                }
+            }
+        });
+
+        pushEntries.setToolTipText(Globals.lang("Cite selected entries"));
+        pushEntries.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                pushEntries(true, true);
+            }
+        });
+        pushEntries.setToolTipText(Globals.lang("Cite selected entries with in-text citation"));
+        pushEntriesInt.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                pushEntries(false, true);
+            }
+        });
+        pushEntriesEmpty.setToolTipText(Globals.lang("Insert a citation without text (the entry will appear in the reference list)"));
+        pushEntriesEmpty.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                pushEntries(false, false);
+            }
+        });
+
+        focus.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                ooBase.setFocus();
+            }
+        });
+        update.setToolTipText(Globals.lang("Ensure that the bibliography is up-to-date"));
+        update.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    style.ensureUpToDate();
+                    ooBase.updateSortedReferenceMarks();
+                    java.util.List<String> unresolvedKeys = ooBase.refreshCiteMarkers
+                            (frame.basePanel().database(), style);
+                    ooBase.rebuildBibTextSection(frame.basePanel().database(), style);
+                    //ooBase.sync(frame.basePanel().database(), style);
+                    if (unresolvedKeys.size() > 0) {
+                        JOptionPane.showMessageDialog(frame, Globals.lang("Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
+                            unresolvedKeys.get(0)), Globals.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE);
+                    }
+                } catch (UndefinedParagraphFormatException ex) {
+                    reportUndefinedParagraphFormat(ex);
+                } catch (ConnectionLostException ex) {
+                    showConnectionLostErrorMessage();
+                } catch (BibtexEntryNotFoundException ex) {
+                    JOptionPane.showMessageDialog(frame, Globals.lang("Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
+                            ex.getBibtexKey()), Globals.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE);
+                }
+                catch (Exception e1) {
+                    e1.printStackTrace();
+                }
+            }
+        });
+
+        insertFullRef.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                try {
+                    insertFullRefs();
+                } catch (Exception e1) {
+                    e1.printStackTrace();
+                }
+            }
+        });
+
+        merge.setToolTipText(Globals.lang("Combine pairs of citations that are separated by spaces only"));
+        merge.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                try {
+                    ooBase.combineCiteMarkers(frame.basePanel().database(), style);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+            }
+        });
+
+        settingsB.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                showSettingsPopup();
+            }
+        });
+
+        test.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                try {
+                    ooBase.testFrameHandling();
+                    //ooBase.combineCiteMarkers(frame.basePanel().database(), style);
+                    //insertUsingBST();
+                    //ooBase.testFootnote();
+                    //ooBase.refreshCiteMarkers(frame.basePanel().database(), style);
+                    //ooBase.createBibTextSection(true);
+                    //ooBase.clearBibTextSectionContent();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+            }
+        });
+
+        selectDocument.setEnabled(false);
+        pushEntries.setEnabled(false);
+        pushEntriesInt.setEnabled(false);
+        pushEntriesEmpty.setEnabled(false);
+        focus.setEnabled(false);
+        update.setEnabled(false);
+        insertFullRef.setEnabled(false);
+        merge.setEnabled(false);
+        test.setEnabled(false);
+        diag = new JDialog((JFrame)null, "OpenOffice panel", false);
+
+        DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow",
+                //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu"));
+                "p,p,p,p,p,p,p,p,p,p"));
+
+        //ButtonBarBuilder bb = new ButtonBarBuilder();
+        DefaultFormBuilder bb = new DefaultFormBuilder(new FormLayout
+                ("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
+                        +"1dlu, fill:pref:grow", ""));
+        bb.append(connect);
+        bb.append(manualConnect);
+        bb.append(selectDocument);
+        bb.append(update);
+
+        //b.append(connect);
+        //b.append(manualConnect);
+        //b.append(selectDocument);
+        b.append(bb.getPanel());
+        b.append(setStyleFile);
+        b.append(pushEntries);
+        b.append(pushEntriesInt);
+        b.append(pushEntriesEmpty);
+        b.append(merge);
+        b.append(settingsB);
+        //b.append(focus);
+        //b.append(update);
+
+        //b.append(insertFullRef);
+        //b.append(test);
+        //diag.getContentPane().add(b.getPanel(), BorderLayout.CENTER);
+
+        JPanel content = new JPanel();
+        comp.setContent(content);
+        content.setLayout(new BorderLayout());
+        content.add(b.getPanel(), BorderLayout.CENTER);
+        
+        //diag.pack();
+        //diag.setVisible(true);
+    }
+
+
+    public void connect(boolean auto) {
+        /*if (ooBase != null) {
+            try {
+                java.util.List<XTextDocument> list = ooBase.getTextDocuments();
+                // TODO: how to find the title of the documents?
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+            return;
+        }*/
+
+        String unoilDir, ooBaseDirectory;
+        if (auto) {
+            AutoDetectPaths adp = new AutoDetectPaths(diag);
+
+            if (adp.runAutodetection()) {
+                autoDetected = true;
+                dialogOkPressed = true;
+                diag.dispose();
+            } else if (!adp.cancelled()) {
+                JOptionPane.showMessageDialog(diag,
+                        Globals.lang("Autodetection failed"),
+                        Globals.lang("Autodetection failed"),
+                        JOptionPane.ERROR_MESSAGE);
+            }
+            if (!autoDetected)
+                return;
+
+            // User clicked Auto, and the system successfully detected paths:
+            unoilDir = Globals.prefs.get("ooUnoilPath");
+            ooBaseDirectory = Globals.prefs.get("ooJurtPath");
+            sOffice = Globals.prefs.get("ooExecutablePath");
+
+            //System.out.println("unoilDir: "+unoilDir);
+            //System.out.println("ooBaseDir: "+ooBaseDirectory);
+            //System.out.println("soffice: "+sOffice);
+
+        }
+        else { // Manual connect
+
+            showConnectDialog();
+            if (!dialogOkPressed)
+                return;
+
+            String ooPath = Globals.prefs.get("ooPath");
+            String ooJars = Globals.prefs.get("ooJarsPath");
+            sOffice = Globals.prefs.get("ooExecutablePath");
+
+            boolean openOffice3 = Globals.prefs.getBoolean("connectToOO3");
+            if (Globals.ON_WIN) {
+                if (openOffice3) {
+                    unoilDir = ooPath+"\\Basis\\program\\classes";
+                    ooBaseDirectory = ooPath+"\\URE\\java";
+                    sOffice = ooPath+"\\program\\soffice.exe";
+                }
+                else {
+                    unoilDir = ooPath+"\\program\\classes";
+                    ooBaseDirectory = unoilDir;
+                    sOffice = ooPath+"\\program\\soffice.exe";
+                }
+
+            }
+            else if (Globals.ON_MAC) {
+                if (openOffice3) {
+                    sOffice = ooPath+"/Contents/MacOS/soffice.bin";
+                    ooBaseDirectory = ooPath+"/Contents/basis-link/ure-link/share/java";
+                    unoilDir = ooPath+"/Contents/basis-link/program/classes"; 
+                }
+                else {
+                    sOffice = ooPath+"/Contents/MacOS/soffice.bin";
+                    ooBaseDirectory = ooPath+"/Contents/MacOS/classes";
+                    unoilDir = ooPath+"/Contents/MacOS/classes";
+                }
+            }
+            else {
+                // Linux:
+                if (openOffice3) {
+                    unoilDir = ooJars+"/program/classes";
+                    ooBaseDirectory = ooJars+"/ure-link/share/java";
+                    //sOffice = ooPath+"/program/soffice";
+                }
+                else {
+                    unoilDir = ooJars;
+                    ooBaseDirectory = ooJars;
+
+                }
+            }
+        }
+
+        //String unoilDir = "/opt/openoffice.org/basis3.0/program/classes";
+        //String ooBaseDirectory = Globals.prefs.get("ooJarsPath");//"/usr/share/java/openoffice";
+        //String sOffice = Globals.prefs.get("ooExecutablePath");
+        //System.getProperty( "os.name" ).startsWith( "Windows" ) ? "soffice.exe" : "soffice";
+
+        // Add OO jars to the classpath:
+        try {
+            URL[] jarList = new URL[] {
+                new File(unoilDir, "unoil.jar").toURI().toURL(),
+                new File(ooBaseDirectory, "jurt.jar").toURI().toURL(),
+                new File(ooBaseDirectory, "juh.jar").toURI().toURL(),
+                new File(ooBaseDirectory, "ridl.jar").toURI().toURL(),
+            };
+            addURL(jarList);
+            /*ClassLoader aCL = Thread.currentThread().getContextClassLoader();
+            loader = new URLClassLoader(jarList, aCL);
+            Thread.currentThread().setContextClassLoader(aUrlCL);
+            loader = new URLClassLoader(jarList);
+            */
+
+            if (styleFile == null) {
+                JOptionPane.showMessageDialog(diag, "You must choose a style file before you can connect.", "No style file selected", JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+
+            if (style == null)
+                readStyleFile();
+
+
+            // Show progress dialog:
+            final JDialog progDiag = (new AutoDetectPaths(diag)).showProgressDialog(diag, Globals.lang("Connecting"),
+                    Globals.lang("Please wait..."), false);
+            getWorker().run(); // Do the actual connection, using Spin to get off the EDT.
+            progDiag.dispose();
+            diag.dispose();
+            if (ooBase == null)
+                throw connectException;
+
+            if (ooBase.isConnectedToDocument())
+                frame.output(Globals.lang("Connected to document")+": "+ooBase.getCurrentDocumentTitle());
+
+            // Enable actions that depend on Connect:
+            selectDocument.setEnabled(true);
+            pushEntries.setEnabled(true);
+            pushEntriesInt.setEnabled(true);
+            pushEntriesEmpty.setEnabled(true);
+            focus.setEnabled(true);
+            update.setEnabled(true);
+            insertFullRef.setEnabled(true);
+            merge.setEnabled(true);
+            test.setEnabled(true);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            
+            JOptionPane.showMessageDialog(frame, Globals.lang("Could not connect to running OpenOffice.\n"
+                +"Make sure you have the UNO jars (unoil.jar, juh.jar, jurt.jar and ridl.jar) on your classpath,\n"
+                +"as well as the OpenOffice bin directory.\nError message: "+e.getMessage()));
+        }
+    }
+
+    public void run() {
+        try {
+            // Connect:
+            ooBase = new OOBibBase(sOffice, true);
+        } catch (Exception e) {
+            ooBase = null;
+            connectException = e;
+            //JOptionPane.showMessageDialog(frame, Globals.lang("Unable to connect"));
+        }
+    }
+
+    /**
+     * Read the style file. Record the last modified time of the file.
+     * @throws Exception
+     */
+    public void readStyleFile() throws Exception {
+
+        style = new OOBibStyle(new File(styleFile));
+    }
+
+
+
+
+    // The methods addFile and associated final Class[] parameters were gratefully copied from
+       // anthony_miguel @ http://forum.java.sun.com/thread.jsp?forum=32&thread=300557&tstart=0&trange=15
+       private static final Class[] parameters = new Class[]{URL.class};
+
+    public static void addURL(URL[] u) throws IOException {
+               URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+               Class sysclass = URLClassLoader.class;
+
+        try {
+                       Method method = sysclass.getDeclaredMethod("addURL",parameters);
+                       method.setAccessible(true);
+            for (int i=0; i<u.length; i++)
+                method.invoke(sysloader, u[i]);
+               } catch (Throwable t) {
+                       t.printStackTrace();
+                       throw new IOException("Error, could not add URL to system classloader");
+               }//end try catch
+       }//end method
+
+    public void setStyleFile() {
+        JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
+        int answer = jfc.showOpenDialog(null);
+        if (answer == JFileChooser.APPROVE_OPTION) {
+            styleFile = jfc.getSelectedFile().getPath();
+            Globals.prefs.put("ooBibliographyStyleFile", styleFile);
+            try {
+                style = new OOBibStyle(new FileReader(styleFile));
+            } catch (Exception e) {
+                e.printStackTrace();
+                JOptionPane.showMessageDialog(diag, e.getMessage());
+            }
+        }
+    }
+
+    public void updateConnectionParams(String ooPath, String ooExec, String ooJars, boolean oo3) {
+        Globals.prefs.put("ooPath", ooPath);
+        Globals.prefs.put("ooExecutablePath", ooExec);
+        Globals.prefs.put("ooJarsPath", ooJars);
+        Globals.prefs.putBoolean("connectToOO3", oo3);
+    }
+
+    public void showConnectDialog() {
+        dialogOkPressed = false;
+        final JDialog diag = new JDialog(frame, Globals.lang("Set connection parameters"), true);
+        final JTextField ooPath = new JTextField(30);
+        JButton browseOOPath = new JButton(Globals.lang("Browse"));
+        ooPath.setText(Globals.prefs.get("ooPath"));
+        final JTextField ooExec = new JTextField(30);
+        JButton browseOOExec = new JButton(Globals.lang("Browse"));
+        browseOOExec.addActionListener(new BrowseAction(null, ooExec, false));
+        final JTextField ooJars = new JTextField(30);
+        JButton browseOOJars = new JButton(Globals.lang("Browse"));
+        browseOOJars.addActionListener(new BrowseAction(null, ooJars, true));
+        ooExec.setText(Globals.prefs.get("ooExecutablePath"));
+        ooJars.setText(Globals.prefs.get("ooJarsPath"));
+        final JRadioButton oo2 = new JRadioButton("OpenOffice.org 2.x", !Globals.prefs.getBoolean("connectToOO3"));
+        final JRadioButton oo3 = new JRadioButton("OpenOffice.org 3.x", Globals.prefs.getBoolean("connectToOO3"));
+        ButtonGroup bg = new ButtonGroup();
+        bg.add(oo2);
+        bg.add(oo3);
+        DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", ""));
+        if (Globals.ON_WIN || Globals.ON_MAC) {
+            builder.append(Globals.lang("Path to OpenOffice directory"));
+            builder.append(ooPath);
+            builder.append(browseOOPath);
+            builder.nextLine();
+        }
+        else {
+            builder.append(Globals.lang("Path to OpenOffice executable"));
+            builder.append(ooExec);
+            builder.append(browseOOExec);
+            builder.nextLine();
+
+            builder.append(Globals.lang("Path to OpenOffice library dir"));
+            builder.append(ooJars);
+            builder.append(browseOOJars);
+            builder.nextLine();
+        }
+        builder.append(Globals.lang("Program version"));
+        builder.append(oo2); builder.nextLine();
+        builder.append(new JPanel());
+        builder.append(oo3); builder.nextLine();
+
+        ButtonBarBuilder bb = new ButtonBarBuilder();
+        JButton ok = new JButton(Globals.lang("Ok"));
+        JButton cancel = new JButton(Globals.lang("Cancel"));
+        //JButton auto = new JButton(Globals.lang("Autodetect"));
+        ActionListener tfListener = new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText(),
+                        oo3.isSelected());
+                diag.dispose();
+            }
+        };
+
+        ooPath.addActionListener(tfListener);
+        ooExec.addActionListener(tfListener);
+        ooJars.addActionListener(tfListener);
+        ok.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText(),
+                        oo3.isSelected());
+                dialogOkPressed = true;
+                diag.dispose();
+            }
+        });
+        cancel.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                diag.dispose();
+            }
+        });
+        bb.addGlue();
+        bb.addRelatedGap();
+        bb.addGridded(ok);
+        bb.addGridded(cancel);
+        bb.addGlue();
+        builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
+        diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
+        diag.pack();
+        diag.setLocationRelativeTo(frame);
+        diag.setVisible(true);
+        
+    }
+
+
+
+    public void pushEntries(boolean inParenthesis, boolean withText) {
+        if (!ooBase.isConnectedToDocument()) {
+            JOptionPane.showMessageDialog(frame, Globals.lang("Not connected to any Writer document. Please"
+                +" make sure a document is open, and use the 'Select Writer document' button to connect to it."),
+                    Globals.lang("Error"), JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+        BasePanel panel =frame.basePanel();
+        final BibtexDatabase database = panel.database();
+        if (panel != null) {
+            BibtexEntry[] entries = panel.getSelectedEntries();
+            if (entries.length > 0) {
+                try {
+                    ooBase.insertEntry(entries, database, style, inParenthesis, withText,
+                            Globals.prefs.getBoolean("syncOOWhenCiting"));
+                } catch (ConnectionLostException ex) {
+                    showConnectionLostErrorMessage();
+                } catch (UndefinedParagraphFormatException ex) {
+                   reportUndefinedParagraphFormat(ex);
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+
+        }
+
+    }
+
+    public void showConnectionLostErrorMessage() {
+        JOptionPane.showMessageDialog(frame, Globals.lang("Connection to OpenOffice has been lost. "
+            +"Please make sure OpenOffice is running, and try to reconnect."),
+            Globals.lang("Connection lost"), JOptionPane.ERROR_MESSAGE);
+    }
+
+    public void insertFullRefs() {
+        try {
+            // Create or clear bibliography:
+            /*boolean hadBib = ooBase.createBibTextSection(true);
+            if (hadBib)
+                ooBase.clearBibTextSectionContent();
+              */
+            BasePanel panel =frame.basePanel();
+            final BibtexDatabase database = panel.database();
+            if (panel != null) {
+                BibtexEntry[] entries = panel.getSelectedEntries();
+                ArrayList<BibtexEntry> el = new ArrayList<BibtexEntry>();
+                for (int i = 0; i < entries.length; i++) {
+                    el.add(entries[i]);
+                }
+
+                ooBase.insertFullReferenceAtViewCursor(database, el, style, "Default");
+            }
+        } catch (UndefinedParagraphFormatException ex) {
+            reportUndefinedParagraphFormat(ex);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+    }
+
+    private void reportUndefinedParagraphFormat(UndefinedParagraphFormatException ex) {
+        JOptionPane.showMessageDialog(frame, "<html>"+Globals.lang("Your style file specifies the paragraph format '%0', "
+            +"which is undefined in your current OpenOffice document.", ex.getFormatName())+"<br>"
+            +Globals.lang("The paragraph format is controlled by the property 'ReferenceParagraphFormat' or 'ReferenceHeaderParagraphFormat' in the style file.")
+            +"</html>",
+            Globals.lang(""), JOptionPane.ERROR_MESSAGE);
+    }
+
+
+    public void insertUsingBST() {
+        try {
+            BasePanel panel =frame.basePanel();
+            final BibtexDatabase database = panel.database();
+            if (panel != null) {
+                BibtexEntry[] entries = panel.getSelectedEntries();
+                ArrayList<BibtexEntry> el = new ArrayList<BibtexEntry>();
+                for (int i = 0; i < entries.length; i++) {
+                    el.add(entries[i]);
+                }
+
+                BstWrapper wrapper = new BstWrapper();
+                //wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/base/plain.bst"));
+                wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/ams/amsalpha.bst"));
+                Map<String,String> result = wrapper.processEntries(el, database);
+                for (String key : result.keySet()) {
+                    System.out.println("Key: "+key);
+                    System.out.println("Entry: "+result.get(key));
+                    ooBase.insertMarkedUpTextAtViewCursor(result.get(key), "Default");
+                }
+                //System.out.println(result);
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    public void showSettingsPopup() {
+        JPopupMenu menu = new JPopupMenu();
+        final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(
+                Globals.lang("Automatically sync bibliography when inserting citations"),
+                Globals.prefs.getBoolean("syncOOWhenCiting"));
+        autoSync.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                Globals.prefs.putBoolean("syncOOWhenCiting", autoSync.isSelected());
+            }
+        });
+        menu.add(autoSync);
+        menu.show(settingsB, 0, settingsB.getHeight());
+    }
+
+    public void pushEntries(boolean inParenthesis, BibtexEntry[] entries) {
+        final BibtexDatabase database = frame.basePanel().database();
+        if (entries.length > 0) {
+            try {
+                ooBase.insertEntry(entries, database, style, inParenthesis, true,
+                    Globals.prefs.getBoolean("syncOOWhenCiting"));
+            } catch (ConnectionLostException ex) {
+                showConnectionLostErrorMessage();
+            } catch (UndefinedParagraphFormatException ex) {
+               reportUndefinedParagraphFormat(ex);
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+    public String getName() {
+        return "Push to OpenOffice";
+    }
+
+    public String getApplicationName() {
+        return "OpenOffice";
+    }
+
+    public String getTooltip() {
+        return "Push selection to OpenOffice";
+    }
+
+    public Icon getIcon() {
+        return GUIGlobals.getImage("openoffice");
+    }
+
+    public String getKeyStrokeName() {
+        return null;
+    }
+
+    public JPanel getSettingsPanel() {
+        if (settings == null)
+            initSettingsPanel();
+        return settings;
+    }
+
+    private void initSettingsPanel() {
+        boolean inParen = Globals.prefs.getBoolean("ooInParCitation");
+        inPar = new JRadioButton(Globals.lang("Use in-parenthesis citation"), inParen);
+        inText = new JRadioButton(Globals.lang("Use in-text citation"), !inParen);
+        ButtonGroup bg = new ButtonGroup();
+        bg.add(inPar);
+        bg.add(inText);
+        settings = new JPanel();
+        settings.setLayout(new BorderLayout());
+        settings.add(inPar, BorderLayout.NORTH);
+        settings.add(inText, BorderLayout.SOUTH);
+    }
+
+    public void storeSettings() {
+        Globals.prefs.putBoolean("ooInParCitation", inPar.isSelected());
+    }
+
+    public void pushEntries(BibtexDatabase bibtexDatabase, BibtexEntry[] entries, String s, MetaData metaData) {
+        if (ooBase == null) {
+            connect(true);
+        }
+        if (ooBase != null) {
+            pushEntries(Globals.prefs.getBoolean("ooInParCitation"), entries);
+        }
+    }
+
+    public void operationCompleted(BasePanel basePanel) {
+
+    }
+
+    public boolean requiresBibtexKeys() {
+        return true;
+    }
+
+    class TestPanel extends SidePaneComponent {
+
+        public TestPanel(SidePaneManager sidePaneManager, URL url, String s) {
+            super(sidePaneManager, url, s);
+        }
+
+        public String getName() {
+            return OOTestPanel.this.getName();
+        }
+    }
+
+
+}
diff --git a/net/sf/jabref/oo/StyleDirectoriesPanel.java b/net/sf/jabref/oo/StyleDirectoriesPanel.java
new file mode 100755 (executable)
index 0000000..359d888
--- /dev/null
@@ -0,0 +1,273 @@
+package net.sf.jabref.oo;
+
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.SortedList;
+import ca.odell.glazedlists.gui.AdvancedTableFormat;
+import ca.odell.glazedlists.gui.WritableTableFormat;
+import ca.odell.glazedlists.swing.EventSelectionModel;
+import ca.odell.glazedlists.swing.EventTableModel;
+import com.jgoodies.forms.builder.ButtonStackBuilder;
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import net.sf.jabref.Globals;
+
+import javax.swing.*;
+import javax.swing.table.TableColumnModel;
+import javax.swing.filechooser.FileFilter;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Panel for setting up the list of directories and files to search for style files.
+ * Each directory entry can be set to be searched recursively or not.
+ */
+public class StyleDirectoriesPanel {
+
+    List<ActionListener> listeners = new ArrayList<ActionListener>();
+    EventList<DirElement> entries = new BasicEventList<DirElement>();
+    EventList<DirElement> sortedEntries;
+    EventTableModel<DirElement> tableModel;
+    EventSelectionModel<DirElement> selectionModel;
+    JPanel panel = new JPanel();
+    JButton addFile = new JButton(Globals.lang("Add file")),
+        addDir = new JButton(Globals.lang("Add directory")),
+        remove = new JButton(Globals.lang("Remove"));
+    FileFilter styleFileFilter = null;
+
+    static final int TABLE_VISIBLE_ROWS = 5;
+    private JDialog parent;
+
+    /**
+     *
+     * @param dirs A String array containing two elements per file/directory:
+     *   first the path, then the string "true" or "false", determining whether
+     *   the element should be handled recursively.
+     */
+    public StyleDirectoriesPanel(JDialog parent, String[] dirs) {
+        this.parent = parent;
+        sortedEntries = new SortedList<DirElement>(entries);
+        if (dirs != null)
+            setValues(dirs);
+        panel.setLayout(new BorderLayout());
+        tableModel = new EventTableModel<DirElement>(sortedEntries, new DirElementFormat());
+        selectionModel = new EventSelectionModel<DirElement>(sortedEntries);
+        JTable table = new JTable(tableModel);
+        table.setSelectionModel(selectionModel);
+        table.setPreferredScrollableViewportSize(new Dimension(
+            table.getPreferredScrollableViewportSize().width,
+            TABLE_VISIBLE_ROWS*table.getRowHeight()));
+        TableColumnModel cm = table.getColumnModel();
+        cm.getColumn(0).setPreferredWidth(200);
+        cm.getColumn(1).setPreferredWidth(40);
+
+        JScrollPane sp = new JScrollPane(table);
+        ButtonStackBuilder bb = new ButtonStackBuilder();
+        bb.addGridded(addFile);
+        bb.addGridded(addDir);
+        bb.addGridded(remove);
+        bb.addGlue();
+        DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow, 2dlu, fill:pref",
+                "pref, fill:pref"));
+        b.appendSeparator(Globals.lang("Directories and files"));
+        b.nextLine();
+        b.append(new JLabel("<html>"+Globals.lang("Here you set up which single files and directories (with or without subdirectories)<br>"
+                +" should be searched to build the list of available styles.")+"</html>"), 3);
+        b.nextLine();
+        b.append(sp);
+        b.append(bb.getPanel());
+        b.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        panel.add(b.getPanel(), BorderLayout.CENTER);
+
+        addFile.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                addEntry(false);
+            }
+        });
+        addDir.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                addEntry(true);
+            }
+        });
+        remove.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                removeSelected();
+            }
+        });
+    }
+
+    public JPanel getPanel() {
+        return panel;
+    }
+
+    private void addEntry(boolean directory) {
+        File initValue = new File(Globals.prefs.get("ooStyleFileLastDir"));
+        JFileChooser jfc = new JFileChooser(initValue);
+        if (directory)
+            jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+        else {
+            // Set file filter:
+            if (styleFileFilter == null) {
+                styleFileFilter = new FileFilter() {
+                    public boolean accept(File file) {
+                        return file.isDirectory() ||
+                                file.getName().endsWith(StyleSelectDialog.STYLE_FILE_EXTENSION);
+                    }
+                    public String getDescription() {
+                        return StyleSelectDialog.STYLE_FILE_EXTENSION;
+                    }
+                };
+            }
+            jfc.addChoosableFileFilter(styleFileFilter);
+        }
+        if (jfc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
+            Globals.prefs.put("ooStyleFileLastDir", jfc.getSelectedFile().getPath());
+            DirElement elm = new DirElement(jfc.getSelectedFile().getPath(), false, directory);
+            entries.getReadWriteLock().writeLock().lock();
+            if (!entries.contains(elm)) // prevent dupes
+                entries.add(elm);
+            entries.getReadWriteLock().writeLock().unlock();
+            notifyListeners();
+        }
+    }
+
+    private void removeSelected() {
+        entries.getReadWriteLock().writeLock().lock();
+        for (DirElement elm : selectionModel.getSelected()) {
+            entries.remove(elm);
+        }
+        entries.getReadWriteLock().writeLock().unlock();
+        notifyListeners();
+    }
+
+    /**
+     * Get a list of dir elements describing the current selection.
+     * @return
+     */
+    public List<DirElement> getDirElements() {
+        return Collections.unmodifiableList(entries);
+    }
+
+    private void setValues(String[] dirs) {
+        entries.getReadWriteLock().writeLock().lock();
+        entries.clear();
+        for (int i=0; i<dirs.length-1; i+=2) {
+            File tmp = new File(dirs[i]);
+            entries.add(new DirElement(dirs[i], Boolean.parseBoolean(dirs[i+1]),
+                    tmp.isDirectory()));
+        }
+        entries.getReadWriteLock().writeLock().unlock();
+    }
+
+    /**
+     * Get a String array describing the current selection.
+     * @return A String array containing two elements per file/directory:
+     *   first the path, then the string "true" or "false", determining whether
+     *   the element should be handled recursively.
+     */
+    public String[] getStringArray() {
+        entries.getReadWriteLock().readLock().lock();
+        String[] res = new String[entries.size()*2];
+        int i=0;
+        for (DirElement elm : entries) {
+            res[i++] = elm.path;
+            res[i++] = elm.recursive ? "true" : "false";
+        }
+        entries.getReadWriteLock().readLock().unlock();
+        return res;
+    }
+
+    /**
+     * Add a listener that will be notified that the directory setup has
+     * been changed.
+     * @param listener The listener.
+     */
+    public void addActionListener(ActionListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeActionListener(ActionListener listener) {
+        listeners.remove(listener);
+    }
+
+    private void notifyListeners() {
+        for (ActionListener listener : listeners)
+            listener.actionPerformed(new ActionEvent(StyleDirectoriesPanel.this, 0, "list change"));
+    }
+
+    /**
+     * Wrapper class for presenting the entries as a table with checkboxes for
+     * recursiveness.
+     */
+    public static class DirElement implements Comparable {
+        public String path;
+        public boolean recursive, canBeRecursive;
+        public DirElement(String path, boolean recursive, boolean canBeRecursive) {
+            this.path = path;
+            this.recursive = recursive;
+            this.canBeRecursive = canBeRecursive;
+        }
+
+        public int compareTo(Object o) {
+            DirElement other = (DirElement)o;
+            return path.compareToIgnoreCase(other.path);
+        }
+
+        public boolean equals(Object o) {
+            DirElement other = (DirElement)o;
+            return other.path.equals(path);
+        }
+    }
+
+    class DirElementFormat implements WritableTableFormat<DirElement>,
+            AdvancedTableFormat<DirElement> {
+
+        public Class getColumnClass(int i) {
+            if (i == 0) return String.class;
+            else return Boolean.class;
+        }
+
+        public Comparator getColumnComparator(int i) {
+            return null;
+        }
+
+        public int getColumnCount() {
+            return 2;
+        }
+
+        public String getColumnName(int i) {
+            if (i == 0)
+                return Globals.lang("Directory or file");
+            else return Globals.lang("Include subdirectories");
+        }
+
+        public Object getColumnValue(DirElement dirElement, int i) {
+            if (i == 0) return dirElement.path;
+            else return dirElement.recursive;
+        }
+
+        public boolean isEditable(DirElement elm, int i) {
+            return (i == 1) && (elm.canBeRecursive);
+        }
+
+        public DirElement setColumnValue(DirElement elm, Object o, int col) {
+            if (col == 1) {
+                elm.recursive = (Boolean)o;
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        notifyListeners();
+                    }
+                });
+            }
+            return elm;
+        }
+
+    }
+
+}
diff --git a/net/sf/jabref/oo/StyleSelectDialog.java b/net/sf/jabref/oo/StyleSelectDialog.java
new file mode 100755 (executable)
index 0000000..33b9ddf
--- /dev/null
@@ -0,0 +1,387 @@
+package net.sf.jabref.oo;
+
+import ca.odell.glazedlists.BasicEventList;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.SortedList;
+import ca.odell.glazedlists.event.ListEvent;
+import ca.odell.glazedlists.event.ListEventListener;
+import ca.odell.glazedlists.gui.TableFormat;
+import ca.odell.glazedlists.swing.EventSelectionModel;
+import ca.odell.glazedlists.swing.EventTableModel;
+import com.jgoodies.forms.builder.ButtonBarBuilder;
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.uif_lite.component.UIFSplitPane;
+import net.sf.jabref.*;
+import net.sf.jabref.external.ExternalFileType;
+import net.sf.jabref.external.UnknownExternalFileType;
+
+import javax.swing.*;
+import javax.swing.table.TableColumnModel;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * This class produces a dialog box for choosing a style file.
+ */
+public class StyleSelectDialog {
+
+    public static final String STYLE_FILE_EXTENSION = ".jstyle";
+    private JabRefFrame frame;
+    private EventList<OOBibStyle> styles, sortedStyles;
+    private JDialog diag;
+    private JTable table;
+    private UIFSplitPane contentPane = new UIFSplitPane(UIFSplitPane.VERTICAL_SPLIT);
+    private EventTableModel tableModel;
+    private EventSelectionModel<OOBibStyle> selectionModel;
+    private JPopupMenu popup = new JPopupMenu();
+    private JMenuItem edit = new JMenuItem(Globals.lang("Edit"));
+
+    PreviewPanel preview;
+    StyleDirectoriesPanel dirsPanel;
+
+    private Rectangle toRect = new Rectangle(0, 0, 1, 1);
+    private JButton ok = new JButton(Globals.lang("Ok")),
+        cancel = new JButton(Globals.lang("Cancel"));
+    private BibtexEntry prevEntry = new BibtexEntry(Util.createNeutralId());
+
+    private boolean okPressed = false;
+    private String initSelection;
+
+    public StyleSelectDialog(JabRefFrame frame, String initSelection) {
+
+        this.frame = frame;
+        setupPrevEntry();
+        init(initSelection);
+    }
+
+    private void init(String initSelection) {
+        this.initSelection = initSelection;
+
+        popup.add(edit);
+        // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor:
+        edit.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                int i = table.getSelectedRow();
+                if (i == -1)
+                    return;
+                ExternalFileType type = Globals.prefs.getExternalFileTypeByExt("jstyle");
+                String link = ((OOBibStyle)tableModel.getElementAt(i)).getFile().getPath();
+                try {
+                    if (type != null)
+                        Util.openExternalFileAnyFormat(new MetaData(), link, type);
+                    else
+                        Util.openExternalFileUnknown(frame, null, new MetaData(), link,
+                                new UnknownExternalFileType("jstyle"));
+                } catch (IOException e) {
+                    e.printStackTrace();
+
+                }
+            }
+        });
+
+        diag = new JDialog(frame, Globals.lang("Styles"), true);
+        dirsPanel = new StyleDirectoriesPanel(diag, Globals.prefs.getStringArray("ooStyleFileDirectories"));
+        // The dirs panel is used to change the list of files and directories to include.
+        // We register an ActionListener to update the style table when the list changes:
+        dirsPanel.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                readStyles();
+            }
+        });
+        styles = new BasicEventList<OOBibStyle>();
+        sortedStyles = new SortedList<OOBibStyle>(styles);
+
+        // Create a preview panel for previewing styles:
+        preview = new PreviewPanel(null, new MetaData(), "");
+        // Use the test entry from the Preview settings tab in Preferences:
+        preview.setEntry(prevEntry);//PreviewPrefsTab.getTestEntry());
+
+
+        tableModel = new EventTableModel<OOBibStyle>(sortedStyles, new StyleTableFormat());
+        table = new JTable(tableModel);
+        TableColumnModel cm = table.getColumnModel();
+        cm.getColumn(0).setPreferredWidth(100);
+        cm.getColumn(1).setPreferredWidth(200);
+        cm.getColumn(2).setPreferredWidth(80);
+        selectionModel = new EventSelectionModel<OOBibStyle>(sortedStyles);
+        table.setSelectionModel(selectionModel);
+        table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        table.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mousePressed(MouseEvent mouseEvent) {
+                if (mouseEvent.isPopupTrigger())
+                    tablePopup(mouseEvent);
+            }
+
+            @Override
+            public void mouseReleased(MouseEvent mouseEvent) {
+                if (mouseEvent.isPopupTrigger())
+                    tablePopup(mouseEvent);
+            }
+        });
+        selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
+        contentPane.setTopComponent(new JScrollPane(table));
+        contentPane.setBottomComponent(preview);
+
+        readStyles();
+        
+
+        DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:1dlu:grow",//""));
+                //"fill:1dlu:grow,
+                 "fill:pref, fill:pref, fill:270dlu:grow"));
+        b.appendSeparator(Globals.lang("Select style"));
+        b.nextLine();
+        b.append(new JLabel("<html>"+Globals.lang("This is the list of available styles. Select the one you want to use.")+"</html>"));
+        b.nextLine();
+        b.append(contentPane);
+        b.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        diag.add(b.getPanel(), BorderLayout.CENTER);
+        diag.add(dirsPanel.getPanel(), BorderLayout.NORTH);
+
+        ok.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                okPressed = true;
+                storeSettings();
+                diag.dispose();
+            }
+        });
+        Action cancelListener = new AbstractAction() {
+            public void actionPerformed(ActionEvent event) {
+                diag.dispose();
+            }
+        };
+        cancel.addActionListener(cancelListener);
+
+        ButtonBarBuilder bb = new ButtonBarBuilder();
+        bb.addGlue();
+        bb.addGridded(ok);
+        bb.addGridded(cancel);
+        bb.addGlue();
+        bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        diag.add(bb.getPanel(), BorderLayout.SOUTH);
+
+        ActionMap am = bb.getPanel().getActionMap();
+        InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
+        im.put(Globals.prefs.getKey("Close dialog"), "close");
+        am.put("close", cancelListener);
+        
+        diag.pack();
+        diag.setLocationRelativeTo(frame);
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                contentPane.setDividerLocation(contentPane.getSize().height-150);
+            }
+        });
+
+    }
+
+    public void setVisible(boolean visible) {
+        okPressed = false;
+        diag.setVisible(visible);
+    }
+
+    /**
+     * Read all style files or directories of style files indicated by the current
+     * settings, and add the styles to the list of styles.
+     */
+    private void readStyles() {
+        table.clearSelection();
+
+        styles.getReadWriteLock().writeLock().lock();
+        styles.clear();
+        for (StyleDirectoriesPanel.DirElement elm : dirsPanel.getDirElements()) {
+            addStyles(elm.path, elm.recursive);
+        }
+        styles.getReadWriteLock().writeLock().unlock();
+
+        selectLastUsed();
+    }
+
+    /**
+     * This method scans the current list of styles, and looks for the styles
+     * that was last used. If found, that style is selected. If not found,
+     * the first style is selected provided there are >0 styles.
+     */
+    private void selectLastUsed() {
+        // Set the initial selection of the table:
+        if (initSelection != null) {
+            boolean found = false;
+            for (int i=0; i < table.getRowCount(); i++) {
+                if (((OOBibStyle)tableModel.getElementAt(i)).getFile().getPath().
+                        equals(initSelection)) {
+                    table.setRowSelectionInterval(i,i);
+                    found = true;
+                    break;
+                }
+            }
+            if (!found && (table.getRowCount() > 0))
+                table.setRowSelectionInterval(0,0);
+        }
+        else {
+            if (table.getRowCount() > 0)
+                table.setRowSelectionInterval(0,0);
+        }
+    }
+
+    /**
+     * If the string dir indicates a file, parse it and add it to the list of styles if
+     * successful. If the string dir indicates a directory, parse all files looking like
+     * style files, and add them. The parameter recurse determines whether we should
+     * recurse into subdirectories.
+     * @param dir the directory or file to handle.
+     * @param recurse true indicates that we should recurse into subdirectories.
+     */
+    private void addStyles(String dir, boolean recurse) {
+        File dirF = new File(dir);
+        if (dirF.isDirectory()) {
+            File[] files = dirF.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                File file = files[i];
+                // If the file looks like a style file, parse it:
+                if (!file.isDirectory() && (file.getName().endsWith(STYLE_FILE_EXTENSION))) {
+                    addSingleFile(file);
+                }
+                // If the file is a directory, and we should recurse, do:
+                else if (file.isDirectory() && recurse) {
+                    addStyles(file.getPath(), recurse);
+                }
+            }
+        }
+        else {
+            // The file wasn't a directory, so we simply parse it:
+            addSingleFile(dirF);
+        }
+    }
+
+    /**
+     * Parse a single file, and add it to the list of styles if parse was successful.
+     * @param file the file to parse.
+     */
+    private void addSingleFile(File file) {
+        try {
+            OOBibStyle style = new OOBibStyle(file);
+            // Check if the parse was successful before adding it:
+            if (style.isValid() && !styles.contains(style))
+                styles.add(style);
+        } catch (Exception e) {
+            System.out.println("Unable to read style file: '"+file.getPath()+"'");
+            e.printStackTrace();
+        }
+    }
+
+    public void storeSettings() {
+        String[] dirs = dirsPanel.getStringArray();
+        Globals.prefs.putStringArray("ooStyleFileDirectories", dirs);
+        OOBibStyle selected = getSelectedStyle();
+        if (selected != null)
+            Globals.prefs.put("ooBibliographyStyleFile", selected.getFile().getPath());
+    }
+
+    /**
+     * Get the currently selected style.
+     * @return the selected style, or null if no style is selected.
+     */
+    public OOBibStyle getSelectedStyle() {
+        if (selectionModel.getSelected().size() > 0)
+            return selectionModel.getSelected().get(0);
+        else
+            return null;
+    }
+
+
+    private void setupPrevEntry() {
+        prevEntry.setField("author", "Smith, Bill and Jones, Bob and Williams, Jeff");
+        prevEntry.setField("editor", "Taylor, Phil");
+        prevEntry.setField("title", "Title of the test entry for reference styles");
+        prevEntry.setField("volume", "34");
+        prevEntry.setField("year", "2008");
+        prevEntry.setField("journal", "BibTeX journal");
+        prevEntry.setField("publisher", "JabRef publishing");
+        prevEntry.setField("address", "Trondheim");
+        prevEntry.setField("www", "http://jabref.sf.net");
+    }
+
+    static class StyleTableFormat implements TableFormat<OOBibStyle> {
+
+        public int getColumnCount() {
+            return 3;
+        }
+
+        public String getColumnName(int i) {
+            switch (i) {
+                case 0:
+                    return Globals.lang("Name");
+                case 1:
+                    return Globals.lang("Journals");
+                case 2:
+                    return Globals.lang("File");
+                default:
+                    return "";
+            }
+        }
+
+        public Object getColumnValue(OOBibStyle style, int i) {
+            switch (i) {
+                case 0:
+                    return style.getName();
+                case 1:
+                    return formatJournals(style.getJournals());
+                case 2:
+                    return style.getFile().getName();
+                default:
+                    return "";
+            }
+        }
+
+
+        private String formatJournals(Set<String> journals) {
+            StringBuilder sb = new StringBuilder("");
+            for (Iterator<String> i = journals.iterator(); i.hasNext();) {
+                sb.append(i.next());
+                if (i.hasNext())
+                    sb.append(", ");
+            }
+            return sb.toString();    
+        }
+    }
+
+    public boolean isOkPressed() {
+        return okPressed;
+    }
+
+    protected void tablePopup(MouseEvent e) {
+        popup.show(e.getComponent(), e.getX(), e.getY());
+    }
+
+    /**
+     * The listener for the Glazed list monitoring the current selection.
+     * When selection changes, we need to update the preview panel.
+     */
+    class EntrySelectionListener implements ListEventListener<OOBibStyle> {
+
+        public void listChanged(ListEvent<OOBibStyle> listEvent) {
+            if (listEvent.getSourceList().size() == 1) {
+                OOBibStyle style = listEvent.getSourceList().get(0);
+                initSelection = style.getFile().getPath();
+                preview.setLayout(style.getReferenceFormat("default"));
+                // Update the preview's entry:
+                contentPane.setDividerLocation(contentPane.getSize().height-150); 
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        preview.update();
+                        preview.scrollRectToVisible(toRect);
+                    }
+                });
+            }
+        }
+    }
+
+}
index 5f967c60ebdc05fe15b4531c5ddf0ae59333b6cc..ca356dca79e78c5d5ceb3f0075c3cbb16747047d 100755 (executable)
@@ -1,6 +1,6 @@
 <?xml version="1.0" ?>
 <!DOCTYPE plugin PUBLIC "-//JPF//Java Plug-in Manifest 1.0" "http://jpf.sourceforge.net/plugin_1_0.dtd">
-<plugin id="net.sf.jabref.oo.ooplugin" version="0.7.4">
+<plugin id="net.sf.jabref.oo.ooplugin" version="0.8">
 
        <requires>
                <import plugin-id="net.sf.jabref.core"/>