Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Made possible to make the OO/LO panel a bit more narrow #1652

Merged
merged 2 commits into from
Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import net.sf.jabref.logic.openoffice.OOBibStyle;
import net.sf.jabref.logic.openoffice.OOPreFormatter;
import net.sf.jabref.logic.openoffice.OOUtil;
import net.sf.jabref.logic.openoffice.UndefinedBibtexEntry;
import net.sf.jabref.logic.openoffice.UndefinedParagraphFormatException;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -229,8 +230,8 @@ public void selectDocument() throws UnknownPropertyException, WrappedTargetExcep
}

private XDesktop simpleBootstrap(String pathToExecutable)
throws IOException, IllegalAccessException, InvocationTargetException, BootstrapException,
CreationException {
throws IllegalAccessException, InvocationTargetException, BootstrapException,
CreationException, IOException {

ClassLoader loader = ClassLoader.getSystemClassLoader();
if (loader instanceof URLClassLoader) {
Expand Down Expand Up @@ -306,9 +307,7 @@ public Optional<String> getCustomProperty(String property) throws UnknownPropert
}

public void updateSortedReferenceMarks() throws WrappedTargetException, NoSuchElementException {
XReferenceMarksSupplier supplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
XNameAccess nameAccess = supplier.getReferenceMarks();
sortedReferenceMarks = getSortedReferenceMarks(nameAccess);
sortedReferenceMarks = getSortedReferenceMarks(getReferenceMarks());
}

/**
Expand Down Expand Up @@ -444,10 +443,6 @@ public List<String> refreshCiteMarkers(List<BibDatabase> databases, OOBibStyle s
}
}

public XNameAccess getReferenceMarks() {
XReferenceMarksSupplier supplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
return supplier.getReferenceMarks();
}

public List<String> getJabRefReferenceMarks(XNameAccess nameAccess) {
String[] names = nameAccess.getElementNames();
Expand All @@ -465,7 +460,7 @@ public List<String> getJabRefReferenceMarks(XNameAccess nameAccess) {

private List<String> refreshCiteMarkersInternal(List<BibDatabase> databases, OOBibStyle style)
throws WrappedTargetException, IllegalArgumentException, NoSuchElementException,
UndefinedCharacterFormatException, UnknownPropertyException, PropertyVetoException, IOException,
UndefinedCharacterFormatException, UnknownPropertyException, PropertyVetoException,
CreationException, BibEntryNotFoundException {

List<String> cited = findCitedKeys();
Expand Down Expand Up @@ -827,9 +822,13 @@ public void rebuildBibTextSection(List<BibDatabase> databases, OOBibStyle style)
populateBibTextSection(entries, style);
}

private String getUniqueReferenceMarkName(String bibtexKey, int type) {
public XNameAccess getReferenceMarks() {
XReferenceMarksSupplier supplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
XNameAccess xNamedRefMarks = supplier.getReferenceMarks();
return supplier.getReferenceMarks();
}

private String getUniqueReferenceMarkName(String bibtexKey, int type) {
XNameAccess xNamedRefMarks = getReferenceMarks();
int i = 0;
String name = OOBibBase.BIB_CITATION + '_' + type + '_' + bibtexKey;
while (xNamedRefMarks.hasByName(name)) {
Expand Down Expand Up @@ -862,9 +861,7 @@ private Map<BibEntry, BibDatabase> findCitedEntries(List<BibDatabase> databases,
}

private List<String> findCitedKeys() throws NoSuchElementException, WrappedTargetException {

XReferenceMarksSupplier supplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
XNameAccess xNamedMarks = supplier.getReferenceMarks();
XNameAccess xNamedMarks = getReferenceMarks();
String[] names = xNamedMarks.getElementNames();
List<String> keys = new ArrayList<>();
for (String name1 : names) {
Expand Down Expand Up @@ -1037,7 +1034,7 @@ private void insertFullReferenceAtCursor(XTextCursor cursor, Map<BibEntry, BibDa
}

private void createBibTextSection2(boolean end)
throws IOException, IllegalArgumentException, CreationException {
throws IllegalArgumentException, CreationException {

XTextCursor mxDocCursor = text.createTextCursor();
if (end) {
Expand All @@ -1060,8 +1057,8 @@ private void createBibTextSection2(boolean end)

}

private void clearBibTextSectionContent2() throws IOException, NoSuchElementException, WrappedTargetException,
IllegalArgumentException, CreationException {
private void clearBibTextSectionContent2()
throws NoSuchElementException, WrappedTargetException, IllegalArgumentException, CreationException {

// Check if the section exists:
XTextSectionsSupplier supp = UnoRuntime.queryInterface(XTextSectionsSupplier.class, mxDoc);
Expand All @@ -1078,7 +1075,7 @@ private void clearBibTextSectionContent2() throws IOException, NoSuchElementExce
}

private void populateBibTextSection(Map<BibEntry, BibDatabase> entries, OOBibStyle style)
throws IOException, NoSuchElementException, WrappedTargetException, PropertyVetoException,
throws NoSuchElementException, WrappedTargetException, PropertyVetoException,
UnknownPropertyException, UndefinedParagraphFormatException, IllegalArgumentException, CreationException {
XTextSectionsSupplier supp = UnoRuntime.queryInterface(XTextSectionsSupplier.class, mxDoc);
XTextSection section = (XTextSection) ((Any) supp.getTextSections().getByName(OOBibBase.BIB_SECTION_NAME))
Expand Down Expand Up @@ -1112,7 +1109,7 @@ private XTextContent insertBookMark(String name, XTextCursor position)
}

private void insertReferenceMark(String name, String citationText, XTextCursor position, boolean withText,
OOBibStyle style) throws IOException, UnknownPropertyException, WrappedTargetException,
OOBibStyle style) throws UnknownPropertyException, WrappedTargetException,
PropertyVetoException, IllegalArgumentException, UndefinedCharacterFormatException, CreationException {

// Check if there is "page info" stored for this citation. If so, insert it into
Expand Down Expand Up @@ -1188,9 +1185,9 @@ private void italicizeOrBold(XTextCursor position, boolean italicize, int start,
}

private void removeReferenceMark(String name) throws NoSuchElementException, WrappedTargetException {
XReferenceMarksSupplier xSupplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
if (xSupplier.getReferenceMarks().hasByName(name)) {
Object o = xSupplier.getReferenceMarks().getByName(name);
XNameAccess nameAccess = getReferenceMarks();
if (nameAccess.hasByName(name)) {
Object o = nameAccess.getByName(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to have a more speaking name for Object o?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more speaking name for the nameAcces, maybe xNamedRefMarks, or similar as in the getBookmarkRange method, would be nice, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure it is possible. I just left it as is (and have no real idea what it does since I didn't consider that part of the code). While it looks like added code, it is just a consequence of the diff algorithm not really working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. yeah, it looked like you changed it. If it is too much effort then leave it as is.

Copy link
Contributor Author

@oscargus oscargus Aug 1, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@oscargus oscargus Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 111 hits for Object o. Some are probably OK as they are in equals, but it may be better to make a major overhaul for that issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then I would suggest making this in a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated most variable names that were a bit short in OOBibBase.

XTextContent bm = UnoRuntime.queryInterface(XTextContent.class, o);
text.removeTextContent(bm);
}
Expand All @@ -1204,9 +1201,7 @@ private void removeReferenceMark(String name) throws NoSuchElementException, Wra
* @throws NoSuchElementException
*/
private XTextRange getBookmarkRange(String name) throws NoSuchElementException, WrappedTargetException {
// query XBookmarksSupplier from document model and get bookmarks collection
XBookmarksSupplier xBookmarksSupplier = UnoRuntime.queryInterface(XBookmarksSupplier.class, xCurrentComponent);
XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
XNameAccess xNamedBookmarks = getBookmarks();

// retrieve bookmark by name
if (!xNamedBookmarks.hasByName(name)) {
Expand All @@ -1217,12 +1212,18 @@ private XTextRange getBookmarkRange(String name) throws NoSuchElementException,
return xFoundBookmark.getAnchor();
}

private XNameAccess getBookmarks() {
// query XBookmarksSupplier from document model and get bookmarks collection
XBookmarksSupplier xBookmarksSupplier = UnoRuntime.queryInterface(XBookmarksSupplier.class, xCurrentComponent);
XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
return xNamedBookmarks;
}

public void combineCiteMarkers(List<BibDatabase> databases, OOBibStyle style)
throws IOException, WrappedTargetException, NoSuchElementException, IllegalArgumentException,
UndefinedCharacterFormatException, UnknownPropertyException, PropertyVetoException, CreationException,
BibEntryNotFoundException {
XReferenceMarksSupplier supplier = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xCurrentComponent);
XNameAccess nameAccess = supplier.getReferenceMarks();
XNameAccess nameAccess = getReferenceMarks();
// TODO: doesn't work for citations in footnotes/tables
List<String> names = getSortedReferenceMarks(nameAccess);

Expand Down
19 changes: 13 additions & 6 deletions src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package net.sf.jabref.gui.openoffice;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
Expand Down Expand Up @@ -106,7 +107,7 @@ public class OpenOfficePanel extends AbstractWorker {
private final JButton update;
private final JButton merge = new JButton(Localization.lang("Merge citations"));
private final JButton manageCitations = new JButton(Localization.lang("Manage citations"));
private final JButton exportCitations = new JButton(Localization.lang("Generate new BIB database"));
private final JButton exportCitations = new JButton(Localization.lang("Export cited"));
private final JButton settingsB = new JButton(Localization.lang("Settings"));
private final JButton help = new HelpAction(Localization.lang("OpenOffice/LibreOffice integration"),
HelpFile.OPENOFFICE_LIBREOFFICE).getHelpButton();
Expand All @@ -132,10 +133,15 @@ private OpenOfficePanel() {
manualConnect = new JButton(connectImage);
connect.setToolTipText(Localization.lang("Connect"));
manualConnect.setToolTipText(Localization.lang("Manual connect"));
connect.setPreferredSize(new Dimension(24, 24));
manualConnect.setPreferredSize(new Dimension(24, 24));

selectDocument = new JButton(IconTheme.JabRefIcon.OPEN.getSmallIcon());
selectDocument.setToolTipText(Localization.lang("Select Writer document"));
selectDocument.setPreferredSize(new Dimension(24, 24));
update = new JButton(IconTheme.JabRefIcon.REFRESH.getSmallIcon());
update.setToolTipText(Localization.lang("Sync OpenOffice/LibreOffice bibliography"));
update.setPreferredSize(new Dimension(24, 24));
preferences = new OpenOfficePreferences(Globals.prefs);
loader = new StyleLoader(preferences,
LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader),
Expand Down Expand Up @@ -311,8 +317,9 @@ public void actionPerformed(ActionEvent e) {
.layout(new FormLayout("fill:pref:grow", "p,p,p,p,p,p,p,p,p,p,p"));

FormBuilder topRowBuilder = FormBuilder.create()
.layout(new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
+ "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", "pref"));
.layout(new FormLayout(
"fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref",
"pref"));
topRowBuilder.add(connect).xy(1, 1);
topRowBuilder.add(manualConnect).xy(3, 1);
topRowBuilder.add(selectDocument).xy(5, 1);
Expand Down Expand Up @@ -403,11 +410,11 @@ private void connect(boolean auto) {
autoDetected = true;
dialogOkPressed = true;
diag.dispose();
} else if (!adp.canceled()) {
} else if (adp.canceled()) {
frame.setStatus(Localization.lang("Operation canceled."));
} else {
JOptionPane.showMessageDialog(diag, Localization.lang("Autodetection failed"),
Localization.lang("Autodetection failed"), JOptionPane.ERROR_MESSAGE);
} else {
frame.setStatus(Localization.lang("Operation canceled."));
}
if (!autoDetected) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref.gui.openoffice;
package net.sf.jabref.logic.openoffice;

import net.sf.jabref.logic.openoffice.OOBibStyle;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.model.entry.IdGenerator;
Expand All @@ -24,7 +23,7 @@
* Subclass of BibEntry for representing entries referenced in a document that can't
* be found in JabRef's current database.
*/
class UndefinedBibtexEntry extends BibEntry {
public class UndefinedBibtexEntry extends BibEntry {

private final String key;

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1715,5 +1715,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2434,5 +2434,6 @@ Error_occured_while_executing_the_command_\"%0\".=Während_der_Ausführung_des_B
Reformat_ISSN=


Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ Latest_version=Latest_version
Online_help_forum=Online_help_forum
Custom=Custom

Generate_new_BIB_database=Generate_new_BIB_database
Export_cited=Export_cited
Unable_to_generate_new_database=Unable_to_generate_new_database

Open_console=Open_console
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1617,5 +1617,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2403,5 +2403,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1661,5 +1661,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1636,5 +1636,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1736,5 +1736,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2381,5 +2381,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2412,5 +2412,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2808,5 +2808,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1630,5 +1630,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2380,5 +2380,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_sv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1573,5 +1573,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1649,5 +1649,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2404,5 +2404,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1643,5 +1643,6 @@ Error_occured_while_executing_the_command_\"%0\".=

Reformat_ISSN=

Generate_new_BIB_database=
Unable_to_generate_new_database=

Export_cited=