mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix reslice and reformat on enter.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.jetbrains.python.debugger.array;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
@@ -31,6 +33,7 @@ import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
/**
|
||||
* @author amarch
|
||||
@@ -46,23 +49,41 @@ public class ArrayTableForm {
|
||||
private JTable myTable;
|
||||
private JBTable myBusyTable;
|
||||
private final Project myProject;
|
||||
private KeyListener myResliceCallback;
|
||||
private KeyListener myReformatCallback;
|
||||
|
||||
|
||||
private static final String DATA_LOADING_IN_PROCESS = "Please wait, load array data.";
|
||||
private static final String NOT_APPLICABLE = "View not applicable for ";
|
||||
|
||||
public ArrayTableForm(@NotNull Project project) {
|
||||
public ArrayTableForm(@NotNull Project project, KeyListener resliceCallback, KeyListener reformatCallback) {
|
||||
myProject = project;
|
||||
myResliceCallback = resliceCallback;
|
||||
myReformatCallback = reformatCallback;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
mySliceTextField = new EditorTextField("", myProject, PythonFileType.INSTANCE);
|
||||
mySliceTextField = new EditorTextField("", myProject, PythonFileType.INSTANCE) {
|
||||
@Override
|
||||
protected EditorEx createEditor() {
|
||||
EditorEx editor = super.createEditor();
|
||||
editor.getContentComponent().addKeyListener(myResliceCallback);
|
||||
return editor;
|
||||
}
|
||||
};
|
||||
|
||||
myTable = new JBTableWithRowHeaders();
|
||||
|
||||
myScrollPane = ((JBTableWithRowHeaders)myTable).getScrollPane();
|
||||
|
||||
myFormatTextField = new EditorTextField("", myProject, PythonFileType.INSTANCE);
|
||||
myFormatTextField = new EditorTextField("", myProject, PythonFileType.INSTANCE) {
|
||||
@Override
|
||||
protected EditorEx createEditor() {
|
||||
EditorEx editor = super.createEditor();
|
||||
editor.getContentComponent().addKeyListener(myReformatCallback);
|
||||
return editor;
|
||||
}
|
||||
};
|
||||
|
||||
myBusyTable = new JBTable(new DefaultTableModel());
|
||||
myBusyTable.getEmptyText().setText("");
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -76,7 +77,21 @@ public class NumpyArrayTable {
|
||||
@NotNull PyViewArrayAction.ViewArrayDialog dialog, @NotNull PyDebugValue value) {
|
||||
myValue = value;
|
||||
myDialog = dialog;
|
||||
myComponent = new ArrayTableForm(project);
|
||||
myComponent = new ArrayTableForm(project, new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
doReslice(getSliceText(), null);
|
||||
}
|
||||
}
|
||||
}, new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
doApplyFormat();
|
||||
}
|
||||
}
|
||||
});
|
||||
myTable = myComponent.getTable();
|
||||
myProject = project;
|
||||
myEvaluator = new PyDebuggerEvaluator(project, getDebugValue().getFrameAccessor());
|
||||
@@ -127,9 +142,6 @@ public class NumpyArrayTable {
|
||||
});
|
||||
}
|
||||
|
||||
// add slice actions
|
||||
initSliceFieldActions();
|
||||
|
||||
//make value name read-only
|
||||
myComponent.getSliceTextField().addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
@@ -145,9 +157,6 @@ public class NumpyArrayTable {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//add format actions
|
||||
initFormatFieldActions();
|
||||
}
|
||||
|
||||
public void disableColor() {
|
||||
@@ -166,28 +175,6 @@ public class NumpyArrayTable {
|
||||
});
|
||||
}
|
||||
|
||||
private void initSliceFieldActions() {
|
||||
myComponent.getSliceTextField().addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
doReslice(getSliceText(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initFormatFieldActions() {
|
||||
myComponent.getFormatTextField().addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
doApplyFormat();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PyDebugValue getDebugValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user