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

WIP: Improve reversibility rebased 03 #496

Draft
wants to merge 1,077 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
1077 commits
Select commit Hold shift + click to select a range
8c8a671
update OOBibStyleTest, act on errors
antalk2 May 23, 2021
06b85c7
CitedKey fields are mostly private
antalk2 May 23, 2021
4f358da
drop getNumCitationMarker2 from Lists
antalk2 May 23, 2021
aad92df
format, comments
antalk2 May 23, 2021
cce3f3c
move CitationMarkerNumericEntryImpl.fromRaw to OOBibStyleTest.java
antalk2 May 23, 2021
09c9b22
move CitationMarkerNumericEntryImpl into OOBibStyleTest.java
antalk2 May 23, 2021
351edd2
CitationGroups.unresolvedKeys() can work without a bibliography
antalk2 May 24, 2021
99c1fe8
comment on Consistency
antalk2 May 24, 2021
1c93f08
Support direct lookup of citations, but use old version
antalk2 May 24, 2021
a6b752a
comments
antalk2 May 24, 2021
241039c
afterCreateCitationGroup resets bibliography
antalk2 May 24, 2021
014fb0f
drop some unused methods
antalk2 May 24, 2021
0364418
OOFrontend.getMarkRange accepts CitationGroup
antalk2 May 24, 2021
015e63b
OOFrontend.getFillCursorForCitationGroup accepts CitationGroup
antalk2 May 24, 2021
5047767
OOFrontend.createCitationGroup returns CitationGroup
antalk2 May 24, 2021
080c9fe
OOFrontend.cleanFillCursorForCitationGroup accepts CitationGroup
antalk2 May 24, 2021
bc67c96
use getCitationGroupsInGlobalOrder()
antalk2 May 24, 2021
dfc03a0
getCitationGroupIDsSortedWithinPartitions returns List<CitationGroup>
antalk2 May 24, 2021
d5a9e67
rename methods according their result types
antalk2 May 24, 2021
30ffb53
check attempt to cite in protected parts
antalk2 May 24, 2021
db53c86
reorder OOError, drop fromJabRefException
antalk2 May 24, 2021
bfc1be4
getBibliographyRange(doc) again beore removing initial para
antalk2 May 25, 2021
0ee4d5b
comments
antalk2 May 25, 2021
c2d40ca
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 May 25, 2021
91d0dc8
comments
antalk2 May 25, 2021
ab9523f
CitedKey.where can be a List
antalk2 May 25, 2021
fdd00f4
comments
antalk2 May 25, 2021
6785712
add PageInfo.java
antalk2 May 25, 2021
9fe181c
use OOListUtil.map
antalk2 May 25, 2021
23a1fcb
requireNonNull
antalk2 May 25, 2021
0055832
comments
antalk2 May 25, 2021
fa1d1b6
bring public methods forward
antalk2 May 26, 2021
737828d
rename: InTextCitationType -> CitationType
antalk2 May 26, 2021
8c73d5a
rename: createNormalizedCitationMarkersForNormalStyle -> createNormal…
antalk2 May 26, 2021
d66bf79
rename: OOBibStyle.getCitationMarker2 -> createCitationMarker
antalk2 May 26, 2021
9407ec0
format
antalk2 May 26, 2021
24ee74e
srip unused methods: zipWith, zip3
antalk2 May 26, 2021
77ac5a5
Tuple3 is only used in OOBibStyleTest.java
antalk2 May 26, 2021
b9836a7
comment
antalk2 May 26, 2021
9d46033
rename: CitationGroupID.asString -> citationGroupIdAsString
antalk2 May 26, 2021
e111d82
rename: CitationGroupID -> CitationGroupId
antalk2 May 26, 2021
539e4b8
comment
antalk2 May 26, 2021
8c95a83
use this instead of cgs
antalk2 May 26, 2021
7d2f050
move model/openoffice/Pair.java to model/oostyle/OOPair.java
antalk2 May 26, 2021
c6865dd
prefix Result and VoidResult -> OOResult, OOVoidResult
antalk2 May 26, 2021
8edb556
drop unused: flatListOfValues
antalk2 May 26, 2021
ab5b6fe
RangeKeyedMapList.partitions is private
antalk2 May 26, 2021
afbc9bf
comments
antalk2 May 26, 2021
0600163
comments
antalk2 May 26, 2021
155f75e
RangeSortEntry fields are private
antalk2 May 26, 2021
cae3ac0
bring public methods to the front
antalk2 May 26, 2021
f979fdf
add OOListUtil.flatMap
antalk2 May 26, 2021
fc0faa6
use OOListUtil.flatMap and map
antalk2 May 26, 2021
ed3f5c5
rename: ps -> propertySet, xPropertyContainer -> container, psi -> pr…
antalk2 May 26, 2021
8da865e
rename: psi -> propertySetInfo
antalk2 May 26, 2021
754e8a4
use longer names
antalk2 May 26, 2021
2eb3766
drop local variable 'l'
antalk2 May 26, 2021
b07c757
format
antalk2 May 26, 2021
118067b
use longer names
antalk2 May 26, 2021
638c0ff
use longer names
antalk2 May 26, 2021
46d653b
rename: kv -> pair
antalk2 May 26, 2021
f80447c
drop OOListUtil.flatMap
antalk2 May 26, 2021
42463e8
use OOListUtil.map
antalk2 May 26, 2021
8c971a2
move model.oostyle to model.openoffice.style
antalk2 May 26, 2021
77eb551
drop unused insertTextAtCurrentLocation
antalk2 May 26, 2021
a504eb9
move insertParagraphBreak where it is used
antalk2 May 26, 2021
46e6c06
move OOListUtil to model/openoffice/util
antalk2 May 26, 2021
b056fc3
move OOPair to model/openoffice/util
antalk2 May 26, 2021
982ebf7
move comment
antalk2 May 26, 2021
8a909b0
move OOResult, OOVoidResult to util
antalk2 May 26, 2021
5f060e5
add model/openoffice/rangesort
antalk2 May 26, 2021
3d47c16
model/openoffice/rangeoverlap model/openoffice/uno
antalk2 May 26, 2021
0b226e4
model/openoffice/backend
antalk2 May 26, 2021
4cd88ae
OOBibStyleTest.java : Tuple23 class is static
antalk2 May 26, 2021
a277835
logic/openoffice/style
antalk2 May 26, 2021
cffdf3c
logic/openoffice/uno
antalk2 May 26, 2021
f85b2f7
logic/openoffice/backend
antalk2 May 26, 2021
50f1438
rename OOUtil -> backend/GetContext
antalk2 May 26, 2021
dba71e3
adjust test and test/resources
antalk2 May 26, 2021
abb0b0e
logic/openoffice/action
antalk2 May 26, 2021
410e005
logic/openoffice/frontend
antalk2 May 26, 2021
3d827b4
move UpdateCitationMarkers and UpdateBibliography to frontend
antalk2 May 26, 2021
66c4076
OOBibBase2, ootext
antalk2 May 27, 2021
2a02b6c
model/frontend
antalk2 May 27, 2021
030fd4e
move all of uno to model
antalk2 May 27, 2021
57084d0
move all of ootext to model
antalk2 May 27, 2021
46d2882
FunctionalTextViewCursor.java now does not depend on JabRef
antalk2 May 27, 2021
9e6e083
move rangesort stuff to model
antalk2 May 27, 2021
a29a8b0
rename OOBibStyleTest OOBibStyleTest2
antalk2 May 27, 2021
1cf5c9a
restore OOBibStyleTest
antalk2 May 27, 2021
85b6c1d
uncomment old stuff
antalk2 May 27, 2021
0513919
OOBibStyleTest.java only has additions now
antalk2 May 27, 2021
5a3e3e5
correction: getCitationMarker2 is static
antalk2 May 28, 2021
2b8dea3
ootext comments
antalk2 May 28, 2021
6a6e258
review rangesort
antalk2 May 28, 2021
9957449
insert (now commented out) "-Xlint:unchecked"
antalk2 May 28, 2021
5f0dd88
-Xlint:unchecked
antalk2 May 28, 2021
8744443
comment type back from oobranch
antalk2 May 28, 2021
4f4ba21
do not call checkRangeOverlaps twice (too slow)
antalk2 May 28, 2021
7769b36
format
antalk2 May 28, 2021
a91e5e5
lock screen refresh in EditInsert
antalk2 May 29, 2021
9c32217
Speed up cursor vs protected-range checking
antalk2 May 29, 2021
e8a4b64
add TimeLap.java
antalk2 May 29, 2021
9c4a99f
visualSort throws on ControllersLocked
antalk2 May 29, 2021
f4dd60e
rename Tuple3 -> OOTuple3
antalk2 May 31, 2021
fa0061b
RangeSort.java
antalk2 May 31, 2021
1d59771
checkstyle
antalk2 May 31, 2021
fbfbc70
use RangeSort.partitionAndSortRanges, drop RangeKeyedMapList
antalk2 May 31, 2021
e2b2fb9
timelap format
antalk2 May 31, 2021
c4c4025
use Collections.sort
antalk2 May 31, 2021
c8926f8
handle padded integers in OOBibStyle parser
antalk2 May 31, 2021
becb2f2
EditMerge was eating character after last merged
antalk2 May 31, 2021
9d248be
try to speed up applyNewCitationMarkers
antalk2 May 31, 2021
2d04713
remove TimeLap calls
antalk2 Jun 1, 2021
05dd8e8
delNamesArray size correction
antalk2 Jun 1, 2021
57d4369
cleanup OOBibStyle
antalk2 Jun 3, 2021
122d513
adjust OOBibStyleTest.java
antalk2 Jun 4, 2021
f31f11a
Revert "adjust OOBibStyleTest.java"
antalk2 Jun 6, 2021
7ff80d0
Revert "cleanup OOBibStyle"
antalk2 Jun 6, 2021
63338b1
add Makefile
antalk2 Jun 6, 2021
b727d12
JabRef 5.3 already exists, rename 'future version' to JabRef60
antalk2 Jun 6, 2021
5bc534b
cleanup for checkstyle on tests
antalk2 Jun 6, 2021
be723d6
describe OOTuple3
antalk2 Jun 6, 2021
1dc82bb
apply requested changes to OOResult
antalk2 Jun 6, 2021
8766098
rename JabRef53 -> JabRef60 continued
antalk2 Jun 6, 2021
4a41c11
use LOGGER.debug instead of debugThisFun
antalk2 Jun 6, 2021
cc8e606
rename s to ootext
antalk2 Jun 6, 2021
bcda697
use LOGGER.debug. debugThisFun still needed
antalk2 Jun 6, 2021
9a116f0
links to openoffice/README.md
antalk2 Jun 6, 2021
326d226
prefer map(Class::method)
antalk2 Jun 7, 2021
ce64bdf
renamed OOText.toString -> OOText.asString
antalk2 Jun 7, 2021
af846a3
docs/openoffice/
antalk2 Jun 7, 2021
cebd8ab
prefer filter(Class::method)
antalk2 Jun 7, 2021
26f2126
add .PHONY targets
antalk2 Jun 7, 2021
5558455
overview.md
antalk2 Jun 7, 2021
1c9df55
add .dir-locals.el
antalk2 Jun 8, 2021
1aad247
use less linebreaks
antalk2 Jun 8, 2021
cde024d
com.sun.star.uno.Exception
antalk2 Jun 8, 2021
8999f6e
drop group comments
antalk2 Jun 8, 2021
463ffdf
renamed asString -> toString
antalk2 Jun 8, 2021
14f406a
merge with H
antalk2 Jun 8, 2021
efa4a0d
merge bach to H
antalk2 Jun 8, 2021
10d2fee
Makefile
antalk2 Jun 10, 2021
0582d56
build.gradle
antalk2 Jun 10, 2021
f63d8cf
Short(short) is deprecated
antalk2 Jun 10, 2021
4e8f1ee
cleanup tempfiles
antalk2 Jun 10, 2021
0a25497
Exception -> com.sun.star.uno.Exception
antalk2 Jun 10, 2021
8a3a446
Exception -> com.sun.star.uno.Exception
antalk2 Jun 11, 2021
6914b63
rename optUnoQI -> cast, drop unoQI
antalk2 Jun 11, 2021
e28a22c
no need to import from java.lang
antalk2 Jun 11, 2021
79b165b
do not throw RuntimeException, review exceptions thrown in model/open…
antalk2 Jun 11, 2021
ddac1bf
description in docs
antalk2 Jun 12, 2021
fed0952
add figure, more markup
antalk2 Jun 13, 2021
e6afe6f
more markup
antalk2 Jun 13, 2021
d664f1e
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Jun 18, 2021
e97c9bf
drop duplicate 'add' in comment
antalk2 Jun 18, 2021
0fd7eb8
use UnoTextRange.compareXXXUnsafe
antalk2 Jun 18, 2021
92f4014
format (use longer lines), comments
antalk2 Jun 18, 2021
50dc9f2
reviewed RangeHolder.getRange() use
antalk2 Jun 18, 2021
5930444
adjust dir-locals (it should set fill-column)
antalk2 Jun 18, 2021
f96b1f9
add comment on RangeSet.add costs
antalk2 Jun 18, 2021
aa05917
add alternative implementation to footnoteMarkRanges
antalk2 Jun 18, 2021
34147ff
use longer lines in OOFrontend.java
antalk2 Jun 18, 2021
355f111
use longer lines in OOTextIntoOO.java
antalk2 Jun 18, 2021
505dfce
x
antalk2 Jun 19, 2021
2a019b5
undo changes to src/main/java/org/jabref/gui/openoffice/OOBibBase.java
antalk2 Jun 19, 2021
e74a5c7
do not use RangeSet
antalk2 Jun 19, 2021
f52e68d
deleted src/main/java/org/jabref/model/openoffice/rangesort/RangeS…
antalk2 Jun 19, 2021
51c3d1e
try to make markdown-lint happy (happier)
antalk2 Jun 20, 2021
5038421
use StringUtil.isNullOrEmpty
antalk2 Jun 22, 2021
694fd9e
no natural order for ComparableMark, use compareTopToBottomLeftToRigh…
antalk2 Jun 22, 2021
69f7be4
add docs/openoffice/ooresult-*.md
antalk2 Jun 23, 2021
9712162
copy docs/openoffice from J (for markdown lint changes)
antalk2 Jul 1, 2021
fe5a4bc
in response to review
antalk2 Jul 7, 2021
f14e5f3
use {@code } to avoid &lt; &gt;
antalk2 Jul 9, 2021
16034ed
make HolderComparatorWithinPartition private
antalk2 Jul 9, 2021
9e8d5b5
throw explicitly
antalk2 Jul 9, 2021
71c332d
use List.sort
antalk2 Jul 9, 2021
12c4538
format
antalk2 Jul 9, 2021
a6ff50a
avoid raw generics
antalk2 Jul 9, 2021
591c31b
add pmd rule to Makefile
antalk2 Jul 9, 2021
04883ee
PMD on TimeLap
antalk2 Jul 9, 2021
ad8f576
PMD on model/backend
antalk2 Jul 9, 2021
0b60594
PMD on model/ootext
antalk2 Jul 9, 2021
53dba25
PMD on model/rangesort
antalk2 Jul 9, 2021
2354dae
PMD on model/style
antalk2 Jul 9, 2021
3057824
PMD on logic/action
antalk2 Jul 9, 2021
26ccf7e
PMD on logic/backend
antalk2 Jul 9, 2021
9aaf742
PMD on logic/frontend
antalk2 Jul 9, 2021
66d3301
PMD on logic/style
antalk2 Jul 9, 2021
e4b5ca0
drop unused LOGGER
antalk2 Jul 9, 2021
ff92514
pmd rule in Makefile
antalk2 Jul 9, 2021
ab275fc
cleanup: redundant throws clause (based on IntelliJ Idea)
antalk2 Jul 9, 2021
5fae212
restore UnoTextRange.java
antalk2 Jul 9, 2021
835e8f1
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Jul 13, 2021
2ea5c5d
replaced single-character names in OOBibStyle.java (in changed part)
antalk2 Jul 18, 2021
8e5ae38
some longer names in OOBibStyleGetCitationMarker.java
antalk2 Jul 18, 2021
d57caa6
drop normalizePageInfos, use 'preferred' and 'fallback' in getAuthorL…
antalk2 Jul 18, 2021
bed4893
checkstyle
antalk2 Jul 18, 2021
73a0a0e
use putIfAbsent
antalk2 Jul 18, 2021
5ecbb9d
use "{}" with LOGGER
antalk2 Jul 18, 2021
7c7e8ab
use Objects.hash and Objects.equals in CitationLookupResult
antalk2 Jul 18, 2021
77fbf1e
simplified CitedKey.getBibEntry
antalk2 Jul 18, 2021
8a04b8d
more use of "{}" in LOGGER
antalk2 Jul 18, 2021
9efc942
more use of "{}" in LOGGER
antalk2 Jul 18, 2021
18ee999
more use of "{}" in LOGGER
antalk2 Jul 18, 2021
4015e8d
Citation.lookup: use streams
antalk2 Jul 24, 2021
8396620
Citation.lookup: Optional::get before findFirst
antalk2 Jul 24, 2021
163394c
removed catch RuntimeException around UnoCursor.getViewCursor
antalk2 Aug 2, 2021
6297879
drop unused message
antalk2 Aug 2, 2021
89b0968
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Aug 2, 2021
8e4b2e2
putIfAbsent returns null for new entry
antalk2 Aug 2, 2021
c5613e6
What is 52 in Backend52
antalk2 Aug 3, 2021
e7675e2
using orElseThrow
antalk2 Aug 18, 2021
ddb3c78
using StringBuilder
antalk2 Aug 18, 2021
364dac5
refMarkName renamed to markName
antalk2 Aug 18, 2021
3c6ef98
import StringBuilder is not needed
antalk2 Aug 19, 2021
4ca55aa
orElseThrow correction (now without message)
antalk2 Aug 19, 2021
7ace25f
renamed cgid to groupId
antalk2 Aug 19, 2021
1a0a991
orElseThrow correction
antalk2 Aug 19, 2021
cd67df5
renamed cg to group
antalk2 Aug 19, 2021
3762c9a
drop message not understandable by end user
antalk2 Aug 19, 2021
b284c3e
reorganized reference mark name generation
antalk2 Aug 19, 2021
632d9df
renamed nCitations to numberOfCitations and totalCitations
antalk2 Aug 19, 2021
9af060e
format
antalk2 Aug 19, 2021
b17f0e2
insert dummy case JabRef60: branch
antalk2 Aug 19, 2021
0210909
indent case-label in model/style
antalk2 Aug 19, 2021
ef9645a
indent case-label in gui
antalk2 Aug 19, 2021
4a35342
indent case-label in logic/backend
antalk2 Aug 19, 2021
b4b1ec0
indent case-label in logic/frontend
antalk2 Aug 19, 2021
4a085b6
indent case-label in model/ootext
antalk2 Aug 19, 2021
88f8e0b
rname cgPageInfos tro pageInfos
antalk2 Aug 19, 2021
17b314b
renamed cgPageInfo to singlePageInfo
antalk2 Aug 19, 2021
b3c53f4
replace Collectors.toSet() with new HashSet<>()
antalk2 Aug 19, 2021
d86eb42
use method reference
antalk2 Aug 19, 2021
0bd3587
drop two comments
antalk2 Aug 19, 2021
7821283
use String.join
antalk2 Aug 19, 2021
dd4fe78
remove nr/nrm prefixes from NamedRange and NamedRangeManager methods
antalk2 Aug 19, 2021
cb13256
align dots
antalk2 Aug 20, 2021
76b21b9
add config/emacs/lsp-java
antalk2 Aug 22, 2021
eed6be1
make PMD happier with longer names
antalk2 Aug 22, 2021
f2b86a5
fontend -> frontend
antalk2 Aug 22, 2021
ae9abcc
ignore some PMD output
antalk2 Aug 22, 2021
3de1a6e
rename ofr to frontend
antalk2 Aug 22, 2021
9a8c4a3
drop config/emacs/lsp-java/
antalk2 Aug 22, 2021
72cc38d
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Aug 22, 2021
771e8d3
follow some PMD suggestions
antalk2 Aug 23, 2021
dd15159
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Sep 2, 2021
708590a
Merge remote-tracking branch 'upstream/main' into improve-reversibili…
antalk2 Nov 9, 2021
2b91d2b
apply suggested changes
antalk2 Nov 9, 2021
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.logic.openoffice.CitationEntry;
import org.jabref.model.openoffice.CitationEntry;

public class CitationEntryViewModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.logic.JabRefException;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.strings.StringUtil;

Expand Down Expand Up @@ -56,7 +57,7 @@ public ManageCitationsDialogView(OOBibBase ooBase) {
}

@FXML
private void initialize() throws NoSuchElementException, WrappedTargetException, UnknownPropertyException {
private void initialize() throws NoSuchElementException, WrappedTargetException, UnknownPropertyException, JabRefException {

viewModel = new ManageCitationsDialogViewModel(ooBase, dialogService);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package org.jabref.gui.openoffice;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;

import org.jabref.gui.DialogService;
import org.jabref.logic.JabRefException;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.CitationEntry;
import org.jabref.logic.openoffice.CreationException;
import org.jabref.logic.openoffice.NoDocumentException;
import org.jabref.model.openoffice.CitationEntry;

import com.sun.star.beans.IllegalTypeException;
import com.sun.star.beans.NotRemoveableException;
import com.sun.star.beans.PropertyExistException;
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
import org.slf4j.Logger;
Expand All @@ -31,33 +33,37 @@ public class ManageCitationsDialogViewModel {
private final OOBibBase ooBase;
private final DialogService dialogService;

public ManageCitationsDialogViewModel(OOBibBase ooBase, DialogService dialogService) throws NoSuchElementException, WrappedTargetException, UnknownPropertyException {
public ManageCitationsDialogViewModel(OOBibBase ooBase, DialogService dialogService)
throws
NoSuchElementException,
WrappedTargetException,
UnknownPropertyException,

Choose a reason for hiding this comment

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

Are these needed?

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean the line breaks, or the exceptions?
The line breaks technically no.

Some of these exceptions mentioned here I caught below,
(UnknownPropertyException, WrappedTargetException)
but not all.

The contructor itself is called from ManageCitationsDialogView.initialize()

    @FXML
    private void initialize() throws NoSuchElementException, WrappedTargetException, UnknownPropertyException, JabRefException {

There is no visible call to initialize() in the class body, presumably accessed through the @FXML magic,
I guess it is called as an event handler or action.

I have no definit answer to "where should these exceptions be caught": should we catch them all
here, or pass them all up (to initialize? or above that?), or something in between. We are probably choosing between
calling a dialog box from an event handler and throwing exception from one.

Those I caught were probably caught here, because this is where they reached
the GUI level. I may have seen UnknownPropertyException and caught it here,
I am not sure I have ever seen a WrappedTargetException. Maybe.

Summary: I do not know where should they be caught.

Moved them to the catch below, then dropped NoSuchElementException,
since the compiler now noticed it is not thrown anyway.

Choose a reason for hiding this comment

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

Do you mean the line breaks, or the exceptions?

Exceptions.

There is no visible call to initialize() in the class body, presumably accessed through the @FXML magic,
I guess it is called as an event handler or action.

I haven't spent that much time with JavaFX, but pretty much

Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 May 10, 2021

Choose a reason for hiding this comment

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

I have no definit answer to "where should these exceptions be caught": should we catch them all
here, or pass them all up (to initialize? or above that?), or something in between. We are probably choosing between
calling a dialog box from an event handler and throwing exception from one.

I'd say catch them all here, or latest in the View. If appropriate do some action (although in this case, I am not sure if you can do all that much more than display an error dialog to the user). I'll try to update the documentation when I have time.

I'll comment in the code what I think of each and why but quite frankly, some of them I have no idea what to do with either (WrappedTargetException would be one of those).


As a general rule can't think of any reason to make a JabRefException (or any other) bubble up past the View. I'd say that most of them (all?) should be handled latest in the ViewModel. This would be one of those I'd appreciate a second opinion on @Siedlerchr 😛

JabRefException {
this.ooBase = ooBase;
this.dialogService = dialogService;

XNameAccess nameAccess = ooBase.getReferenceMarks();
List<String> names = ooBase.getJabRefReferenceMarks(nameAccess);
for (String name : names) {

CitationEntry entry = new CitationEntry(name,
ooBase.getCitationContext(nameAccess, name, 30, 30, true),
ooBase.getCustomProperty(name));

CitationEntryViewModel itemViewModelEntry = new CitationEntryViewModel(entry);
citations.add(itemViewModelEntry);
try {
List<CitationEntry> cts = ooBase.getCitationEntries();
for (CitationEntry entry : cts) {
CitationEntryViewModel itemViewModelEntry = new CitationEntryViewModel(entry);
citations.add(itemViewModelEntry);
}
} catch (UnknownPropertyException
| WrappedTargetException
| NoDocumentException
| PropertyVetoException
| CreationException ex) {
LOGGER.warn("Problem collecting citations", ex);
dialogService.showErrorDialogAndWait(Localization.lang("Problem collecting citations"), ex);
}
}

public void storeSettings() {
List<CitationEntry> ciationEntries = citations.stream().map(CitationEntryViewModel::toCitationEntry).collect(Collectors.toList());
try {
for (CitationEntry entry : ciationEntries) {
Optional<String> pageInfo = entry.getPageInfo();
if (pageInfo.isPresent()) {
ooBase.setCustomProperty(entry.getRefMarkName(), pageInfo.get());
}
}
ooBase.applyCitationEntries(ciationEntries);
} catch (UnknownPropertyException | NotRemoveableException | PropertyExistException | IllegalTypeException |
NoDocumentException | WrappedTargetException |
IllegalArgumentException ex) {
LOGGER.warn("Problem modifying citation", ex);
dialogService.showErrorDialogAndWait(Localization.lang("Problem modifying citation"), ex);
Expand Down
Loading