|
14 | 14 | */
|
15 | 15 | public class EditAction extends SimpleCommand {
|
16 | 16 |
|
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; |
20 | 20 |
|
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; |
25 | 25 |
|
26 |
| - this.executable.bind(ActionHelper.needsEntriesSelected(stateManager)); |
27 |
| - } |
| 26 | + this.executable.bind(ActionHelper.needsEntriesSelected(stateManager)); |
| 27 | + } |
28 | 28 |
|
29 |
| - @Override |
30 |
| - public String toString() { |
31 |
| - return this.action.toString(); |
32 |
| - } |
| 29 | + @Override |
| 30 | + public String toString() { |
| 31 | + return this.action.toString(); |
| 32 | + } |
33 | 33 |
|
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 |
55 | 58 |
|
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); |
73 | 75 | }
|
| 76 | + } |
74 | 77 | });
|
75 | 78 | }
|
76 | 79 | }
|
0 commit comments