mirror of https://github.com/rusefi/rusefi.git
only:refactoring: extract method
This commit is contained in:
parent
653b0a5f67
commit
c6401b447b
|
@ -1,7 +1,6 @@
|
|||
package com.rusefi.ui.lua;
|
||||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -100,9 +99,7 @@ public class TextEditor {
|
|||
document.addUndoableEditListener(e -> undoManager.addEdit(e.getEdit()));
|
||||
|
||||
// Map undo action
|
||||
textArea.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
|
||||
.put(undoKeyStroke, "undoKeyStroke");
|
||||
textArea.getActionMap().put("undoKeyStroke", new AbstractAction() {
|
||||
installKeyAction(undoKeyStroke, "undoKeyStroke", textArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
|
@ -113,9 +110,7 @@ public class TextEditor {
|
|||
}
|
||||
});
|
||||
// Map redo action
|
||||
textArea.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
|
||||
.put(redoKeyStroke, "redoKeyStroke");
|
||||
textArea.getActionMap().put("redoKeyStroke", new AbstractAction() {
|
||||
installKeyAction(redoKeyStroke, "redoKeyStroke", textArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
|
@ -127,6 +122,12 @@ public class TextEditor {
|
|||
});
|
||||
}
|
||||
|
||||
public static void installKeyAction(KeyStroke undoKeyStroke, String actionName, JComponent control, AbstractAction action) {
|
||||
control.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
|
||||
.put(undoKeyStroke, actionName);
|
||||
control.getActionMap().put(actionName, action);
|
||||
}
|
||||
|
||||
public JComponent getControl() {
|
||||
return area;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue