Skip to content

Commit 288747a

Browse files
committed
Update EditAction.java
Fix the bug JabRef#6421
1 parent a5412b3 commit 288747a

File tree

1 file changed

+54
-51
lines changed

1 file changed

+54
-51
lines changed

src/main/java/org/jabref/gui/edit/EditAction.java

+54-51
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,66 @@
1414
*/
1515
public class EditAction extends SimpleCommand {
1616

17-
private final JabRefFrame frame;
18-
private final StandardActions action;
19-
private final StateManager stateManager;
17+
private final JabRefFrame frame;
18+
private final StandardActions action;
19+
private final StateManager stateManager;
2020

21-
public EditAction(StandardActions action, JabRefFrame frame, StateManager stateManager) {
22-
this.action = action;
23-
this.frame = frame;
24-
this.stateManager = stateManager;
21+
public EditAction(StandardActions action, JabRefFrame frame, StateManager stateManager) {
22+
this.action = action;
23+
this.frame = frame;
24+
this.stateManager = stateManager;
2525

26-
this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
27-
}
26+
this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
27+
}
2828

29-
@Override
30-
public String toString() {
31-
return this.action.toString();
32-
}
29+
@Override
30+
public String toString() {
31+
return this.action.toString();
32+
}
3333

34-
@Override
35-
public void execute() {
36-
stateManager.getFocusOwner().ifPresent(focusOwner -> {
37-
if (focusOwner instanceof TextInputControl) {
38-
// Focus is on text field -> copy/paste/cut selected text
39-
TextInputControl textInput = (TextInputControl) focusOwner;
40-
switch (action) {
41-
case COPY:
42-
textInput.copy();
43-
break;
44-
case CUT:
45-
textInput.cut();
46-
break;
47-
case PASTE:
48-
// handled by FX in TextInputControl#paste
49-
break;
50-
default:
51-
throw new IllegalStateException("Only cut/copy/paste supported in TextInputControl but got " + action);
52-
}
53-
} else {
54-
// Not sure what is selected -> copy/paste/cut selected entries
34+
@Override
35+
public void execute() {
36+
stateManager.getFocusOwner().ifPresent(focusOwner -> {
37+
if (focusOwner instanceof TextInputControl) {
38+
// Focus is on text field -> copy/paste/cut selected text
39+
TextInputControl textInput = (TextInputControl) focusOwner;
40+
switch (action) {
41+
case COPY:
42+
textInput.copy();
43+
break;
44+
case CUT:
45+
textInput.cut();
46+
break;
47+
case PASTE:
48+
// handled by FX in TextInputControl#paste
49+
break;
50+
case DELETE_ENTRY:
51+
// DELETE_ENTRY in text field should do forward delete
52+
textInput.deleteNextChar();
53+
default:
54+
throw new IllegalStateException("Only cut/copy/paste supported in TextInputControl but got " + action);
55+
}
56+
} else {
57+
// Not sure what is selected -> copy/paste/cut selected entries
5558

56-
// ToDo: Should be handled by BibDatabaseContext instead of BasePanel
57-
switch (action) {
58-
case COPY:
59-
frame.getCurrentBasePanel().copy();
60-
break;
61-
case CUT:
62-
frame.getCurrentBasePanel().cut();
63-
break;
64-
case PASTE:
65-
frame.getCurrentBasePanel().paste();
66-
break;
67-
case DELETE_ENTRY:
68-
frame.getCurrentBasePanel().delete(false);
69-
break;
70-
default:
71-
throw new IllegalStateException("Only cut/copy/paste supported but got " + action);
72-
}
59+
// ToDo: Should be handled by BibDatabaseContext instead of BasePanel
60+
switch (action) {
61+
case COPY:
62+
frame.getCurrentBasePanel().copy();
63+
break;
64+
case CUT:
65+
frame.getCurrentBasePanel().cut();
66+
break;
67+
case PASTE:
68+
frame.getCurrentBasePanel().paste();
69+
break;
70+
case DELETE_ENTRY:
71+
frame.getCurrentBasePanel().delete(false);
72+
break;
73+
default:
74+
throw new IllegalStateException("Only cut/copy/paste supported but got " + action);
7375
}
76+
}
7477
});
7578
}
7679
}

0 commit comments

Comments
 (0)