Skip to content

Commit 5668f5b

Browse files
committed
Merge branch 'main' into fix-index
2 parents f4ba710 + cc464e8 commit 5668f5b

File tree

8 files changed

+20
-159
lines changed

8 files changed

+20
-159
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
4242
- We fixed an issue where a new entry was not added to the selected group [#8933](https://github.com/JabRef/jabref/issues/8933)
4343
- We fixed an issue where the horizontal position of the Entry Preview inside the entry editor was not remembered across restarts [#11281](https://github.com/JabRef/jabref/issues/11281)
4444
- We fixed an issue where the search index was not updated after linking PDF files. [#11317](https://github.com/JabRef/jabref/pull/11317)
45+
- We fixed an issue where the entry editor context menu was not shown correctly when JabRef is opened on a second, extended screen [#11323](https://github.com/JabRef/jabref/issues/11323), [#11174](https://github.com/JabRef/jabref/issues/11174)
4546

4647
### Removed
4748

src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public void initContextMenu(final Supplier<List<MenuItem>> items) {
4242
setOnContextMenuRequested(event -> {
4343
contextMenu.getItems().setAll(EditorContextAction.getDefaultContextMenuItems(this, Globals.getKeyPrefs()));
4444
contextMenu.getItems().addAll(0, items.get());
45-
46-
TextInputControlBehavior.showContextMenu(this, contextMenu, event);
45+
contextMenu.show(this, event.getScreenX(), event.getScreenY());
4746
});
4847
}
4948

src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public void initContextMenu(final Supplier<List<MenuItem>> items) {
3838
setOnContextMenuRequested(event -> {
3939
contextMenu.getItems().setAll(EditorContextAction.getDefaultContextMenuItems(this, Globals.getKeyPrefs()));
4040
contextMenu.getItems().addAll(0, items.get());
41-
42-
TextInputControlBehavior.showContextMenu(this, contextMenu, event);
41+
contextMenu.show(this, event.getScreenX(), event.getScreenY());
4342
});
4443
}
4544

src/main/java/org/jabref/gui/fieldeditors/OptionEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public OptionEditor(OptionEditorViewModel<T> viewModel) {
3636
comboBox.getEditor().setOnContextMenuRequested(event -> {
3737
ContextMenu contextMenu = new ContextMenu();
3838
contextMenu.getItems().setAll(EditorContextAction.getDefaultContextMenuItems(comboBox.getEditor(), Globals.getKeyPrefs()));
39-
TextInputControlBehavior.showContextMenu(comboBox.getEditor(), contextMenu, event);
39+
contextMenu.show(comboBox, event.getScreenX(), event.getScreenY());
4040
});
4141
}
4242

src/main/java/org/jabref/gui/fieldeditors/TextInputControlBehavior.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

src/main/java/org/jabref/gui/util/component/TemporalAccessorPicker.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import javafx.util.StringConverter;
2020

2121
import org.jabref.gui.Globals;
22-
import org.jabref.gui.fieldeditors.TextInputControlBehavior;
2322
import org.jabref.gui.fieldeditors.contextmenu.EditorContextAction;
2423
import org.jabref.gui.util.BindingsHelper;
2524
import org.jabref.model.entry.Date;
@@ -28,18 +27,18 @@
2827
/**
2928
* A date picker with configurable datetime format where both date and time can be changed via the text field and the
3029
* date can additionally be changed via the JavaFX default date picker. Also supports incomplete dates.
31-
*
30+
* <p>
3231
* First recall how the date picker normally works: - The user selects a date in the popup, which sets {@link
3332
* #valueProperty()} to the selected date. - The converter ({@link #converterProperty()}) is used to transform the date
3433
* to a string representation and display it in the text field.
35-
*
34+
* <p>
3635
* The idea is now to intercept the process and add an additional step: - The user selects a date in the popup, which
3736
* sets {@link #valueProperty()} to the selected date. - The date is converted to a {@link TemporalAccessor} (i.e,
3837
* enriched by a time component) using {@link #addCurrentTime(LocalDate)} - The string converter ({@link
3938
* #stringConverterProperty()}) is used to transform the temporal accessor to a string representation and display it in
4039
* the text field.
41-
*
42-
* Inspiration taken from https://github.com/edvin/tornadofx-controls/blob/master/src/main/java/tornadofx/control/DateTimePicker.java
40+
* <p>
41+
* Inspiration taken from <a href="https://github.com/edvin/tornadofx-controls/blob/master/src/main/java/tornadofx/control/DateTimePicker.java">Controlsfx DateTimePicker</a>
4342
*/
4443
public class TemporalAccessorPicker extends DatePicker {
4544
private final ObjectProperty<TemporalAccessor> temporalAccessorValue = new SimpleObjectProperty<>(null);
@@ -58,7 +57,7 @@ public TemporalAccessorPicker() {
5857
getEditor().setOnContextMenuRequested(event -> {
5958
ContextMenu contextMenu = new ContextMenu();
6059
contextMenu.getItems().setAll(EditorContextAction.getDefaultContextMenuItems(getEditor(), Globals.getKeyPrefs()));
61-
TextInputControlBehavior.showContextMenu(getEditor(), contextMenu, event);
60+
contextMenu.show(this, event.getScreenX(), event.getScreenY());
6261
});
6362
}
6463

src/main/java/org/jabref/logic/bst/BstFunctions.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -711,12 +711,9 @@ void bstSubstring(BstVMVisitor visitor, ParserRuleContext ctx) {
711711
length = Integer.MAX_VALUE / 2;
712712
}
713713

714-
if (start > (Integer.MAX_VALUE / 2)) {
715-
start = Integer.MAX_VALUE / 2;
716-
}
717-
718-
if (start < (Integer.MIN_VALUE / 2)) {
719-
start = -Integer.MIN_VALUE / 2;
714+
if ((start > string.length()) || (start < -string.length())) {
715+
stack.push("");
716+
return;
720717
}
721718

722719
if (start < 0) {
@@ -726,7 +723,12 @@ void bstSubstring(BstVMVisitor visitor, ParserRuleContext ctx) {
726723
}
727724

728725
int zeroBasedStart = start - 1;
729-
String result = string.substring(zeroBasedStart, Math.min(zeroBasedStart + length, string.length()));
726+
int zeroBasedEnd = Math.min(zeroBasedStart + length, string.length());
727+
728+
// Sanitize too large start values
729+
zeroBasedStart = Math.min(zeroBasedStart, zeroBasedEnd);
730+
731+
String result = string.substring(zeroBasedStart, zeroBasedEnd);
730732

731733
LOGGER.trace("substring$(s, start, len): ({}, {}, {})={}", string, start, length, result);
732734
stack.push(result);

src/test/java/org/jabref/logic/bst/BstFunctionsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ public void substring() throws RecognitionException {
213213
"abc, abcd, -2, 2147483647",
214214
"b, abcd, -3, 1",
215215
"a, abcd, -4, 1",
216-
"'', abcd, -5, 1" // invalid number -5
216+
"'', abcd, -5, 1", // invalid number -5
217+
"'', abcd, -2147483647, 2147483647", // invalid number
217218
})
218219
void substringPlain(String expected, String full, Integer start, Integer length) {
219220
BstVMContext bstVMContext = new BstVMContext(List.of(), new BibDatabase(), Path.of("404.bst"));

0 commit comments

Comments
 (0)