<properties/>
<border type="none"/>
<children>
- <scrollpane id="90774" class="com.intellij.ui.components.JBScrollPane" binding="myScrollPane">
+ <scrollpane id="90774" class="com.intellij.ui.components.JBScrollPane" binding="myScrollPane" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.table.JBTable;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import javax.swing.table.DefaultTableModel;
+import java.awt.*;
/**
* @author amarch
private JPanel myFormatPanel;
private JPanel myMainPanel;
public JBTable myTable;
+ private PyViewArrayAction.MyDialog myParentDialog;
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(){
+ public ArrayTableForm(PyViewArrayAction.MyDialog dialog) {
+ myParentDialog = dialog;
}
private void createUIComponents() {
};
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
myTable.setRowSelectionAllowed(false);
+
+ myScrollPane = new JBScrollPane();
+ JTable rowTable = new RowNumberTable(myTable) {
+ @Override
+ protected void paintComponent(@NotNull Graphics g) {
+ getEmptyText().setText("");
+ super.paintComponent(g);
+ }
+ };
+ myScrollPane.setRowHeaderView(rowTable);
+ myScrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER,
+ rowTable.getTableHeader());
}
public JTextField getSliceTextField() {
return myFormatTextField;
}
- public JBTable getTable() {
+ public JTable getTable() {
return myTable;
}
return myColoredCheckbox;
}
- private void setSpinnerText(String text) {
- DefaultTableModel model = new DefaultTableModel(1, 1) {
- @Override
- public boolean isCellEditable(int row, int column) {
- return false;
- }
- };
- myTable.setModel(model);
- myTable.setValueAt(text, 0, 0);
- }
-
- public void setDefaultSpinnerText() {
- setSpinnerText(DATA_LOADING_IN_PROCESS);
+ public void setDefaultStatus() {
+ myTable.getEmptyText().setText(DATA_LOADING_IN_PROCESS);
}
- public void setErrorSpinnerText(Exception e) {
- setSpinnerText(e.getMessage());
+ public void setErrorText(Exception e) {
+ setErrorText(e.getMessage());
}
- public void setErrorSpinnerText(String message) {
- setSpinnerText(message);
+ public void setErrorText(String message) {
+ myParentDialog.setError(message);
}
-
- public void setNotApplicableSpinner(XValueNodeImpl node) {
- setSpinnerText(NOT_APPLICABLE + node.getName());
+ public void setNotApplicableStatus(XValueNodeImpl node) {
+ myTable.getEmptyText().setText(NOT_APPLICABLE + node.getName());
}
public JComponent getMainPanel() {
private String mySlicePresentation;
private NumpyArrayValueProvider myValueProvider;
private DataEvaluator myDataEvaluator;
+ private int myRows = 0;
+ private int myColumns = 0;
+ private int myRowsOffset = 0;
+ private int myColumnsOffset = 0;
public Numpy2DArraySlice(@NotNull String valueName,
@NotNull List<Pair<Integer, Integer>> fullSlice,
if (!consistent) {
throw new IllegalStateException("Illegal slice shape.");
}
+
+ int size = myFullSlice.size();
+ myRows = myFullSlice.get(size - 2).getSecond() - myFullSlice.get(size - 2).getFirst();
+ myColumns = myFullSlice.get(size - 1).getSecond() - myFullSlice.get(size - 1).getFirst();
+ myRowsOffset = myFullSlice.get(size - 2).getFirst();
+ myColumnsOffset = myFullSlice.get(size - 1).getFirst();
}
public String getPresentation() {
for (int index = 0; index < myFullSlice.size() - 2; index++) {
mySlicePresentation += "[" + myFullSlice.get(index).getFirst() + "]";
}
- int size = myFullSlice.size();
- mySlicePresentation += "[" +
- myFullSlice.get(size - 2).getFirst() +
- ":" +
- myFullSlice.get(size - 2).getSecond() +
- ", " +
- myFullSlice.get(size - 1).getFirst() +
- ":" +
- myFullSlice.get(size - 1).getSecond() +
- "]";
+ mySlicePresentation +=
+ "[" + myRowsOffset + ":" + (myRowsOffset + myRows) + ", " + myColumnsOffset + ":" + (myColumnsOffset + myColumns) + "]";
}
public void startFillData(Runnable callback) {
private class DataEvaluator {
private Object[][] myData;
- private int myRows = 0;
private int myFilledRows = 0;
private int nextRow = 0;
public void evaluateData(final Runnable callback) {
final XDebuggerEvaluator.XEvaluationCallback computeChildrenCallback = new XDebuggerEvaluator.XEvaluationCallback() {
@Override
- public void evaluated(@NotNull XValue result) {
- String name = ((PyDebugValue)result).getName();
- final XValueNodeImpl node = new XValueNodeImpl(myValueProvider.getTree(), null, name, result);
+ public void evaluated(@NotNull final XValue result) {
+ final String name = ((PyDebugValue)result).getName();
DebuggerUIUtil.invokeLater(new Runnable() {
@Override
public void run() {
+ XValueNodeImpl node = new XValueNodeImpl(myValueProvider.getTree(), null, name, result);
node.startComputingChildren();
}
});
}
myFilledRows += 1;
}
- if (myFilledRows == myRows + myFullSlice.get(myFullSlice.size() - 2).getFirst()) {
+ if (myFilledRows == myRows) {
node.getTree().removeTreeListener(this);
callback.run();
}
}
};
- int size = myFullSlice.size();
myData =
- new Object[myFullSlice.get(size - 2).getSecond() - myFullSlice.get(size - 2).getFirst()]
- [myFullSlice.get(size - 1).getSecond() - myFullSlice.get(size - 1).getFirst()];
+ new Object[myRows][myColumns];
myRows = myData.length;
myValueProvider.getTree().addTreeListener(treeListener);
- nextRow = myFullSlice.get(size - 2).getFirst();
+ nextRow = myRowsOffset;
startEvalNextRow(computeChildrenCallback);
}
evalRowCommand += "[" + nextRow + "]";
}
evalRowCommand +=
- "[" + myFullSlice.get(myFullSlice.size() - 1).getFirst() + ":" + myFullSlice.get(myFullSlice.size() - 1).getSecond() + "])";
+ "[" + myColumnsOffset + ":" + (myColumnsOffset + myColumns) + "])";
myValueProvider.getEvaluator().evaluate(evalRowCommand, callback, null);
}
private String myDtypeKind;
private int[] myShape;
- private final static int COLUMNS_IN_DEFAULT_SLICE = 100;
- private final static int ROWS_IN_DEFAULT_SLICE = 100;
+ private final static int COLUMNS_IN_DEFAULT_SLICE = 50;
+ private final static int ROWS_IN_DEFAULT_SLICE = 50;
public NumpyArrayValueProvider(@NotNull XValueNode node, @NotNull ArrayTableForm component, @NotNull Project project) {
super(node);
@Override
public void errorOccurred(@NotNull String errorMessage) {
- myComponent.setErrorSpinnerText(errorMessage);
+ myComponent.setErrorText(errorMessage);
}
}, null);
super.doOKAction();
}
private void showError(String message) {
- myComponent.setErrorSpinnerText(message);
+ myComponent.setErrorText(message);
}
public String getFormat() {
dialog.show();
}
-
- private class MyDialog extends DialogWrapper {
+ protected class MyDialog extends DialogWrapper {
public JTable myTable;
private Project myProject;
private ArrayTableForm myComponent;
myProject = project;
- myComponent = new ArrayTableForm();
+ myComponent = new ArrayTableForm(this);
myTable = myComponent.getTable();
init();
}
-
public void setValue(XValueNodeImpl node) {
if (node.getValueContainer() instanceof PyDebugValue) {
PyDebugValue debugValue = (PyDebugValue)node.getValueContainer();
if ("ndarray".equals(debugValue.getType())) {
- myComponent.setDefaultSpinnerText();
+ myComponent.setDefaultStatus();
final NumpyArrayValueProvider valueProvider = new NumpyArrayValueProvider(node, myComponent, myProject);
try {
valueProvider.startFillTable();
}
catch (Exception e) {
- myComponent.setErrorSpinnerText(e);
+ myComponent.setErrorText(e);
}
}
else {
- myComponent.setNotApplicableSpinner(node);
+ myComponent.setNotApplicableStatus(node);
//this.close(CLOSE_EXIT_CODE);
}
}
}
+ public void setError(String text){
+ //todo: think about this usage
+ setErrorText(text);
+ }
+
@Override
@NotNull
protected Action[] createActions() {
*/
package com.jetbrains.python.actions.view.array;
+import com.intellij.ui.table.JBTable;
+
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
* This table must be added to the row header of the scrollpane that
* contains the main table.
*/
-public class RowNumberTable extends JTable
+public class RowNumberTable extends JBTable
implements ChangeListener, PropertyChangeListener, TableModelListener {
private JTable main;