use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ParamInfo in project intellij-community by JetBrains.
the class DynamicMethodDialog method setupParameterList.
private void setupParameterList(List<ParamInfo> arguments) {
final ListTableModel<ParamInfo> dataModel = new ListTableModel<>(new NameColumnInfo(), new TypeColumnInfo());
dataModel.setItems(arguments);
myParametersTable.setModel(dataModel);
if (arguments.isEmpty())
return;
String max0 = arguments.get(0).name;
String max1 = arguments.get(0).type;
for (ParamInfo argument : arguments) {
if (argument.name.length() > max0.length())
max0 = argument.name;
if (argument.type.length() > max1.length())
max1 = argument.type;
}
final FontMetrics metrics = myParametersTable.getFontMetrics(myParametersTable.getFont());
final TableColumn column0 = myParametersTable.getColumnModel().getColumn(0);
column0.setPreferredWidth(metrics.stringWidth(max0 + " "));
final TableColumn column1 = myParametersTable.getColumnModel().getColumn(1);
column1.setPreferredWidth(metrics.stringWidth(max1 + " "));
}
use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ParamInfo in project intellij-community by JetBrains.
the class DynamicMethodDialog method setupParameterTable.
private void setupParameterTable(final List<ParamInfo> pairs) {
MySuggestedNameCellEditor suggestedNameCellEditor = new MySuggestedNameCellEditor(QuickfixUtil.getArgumentsNames(pairs));
myParametersTable.setDefaultEditor(String.class, suggestedNameCellEditor);
suggestedNameCellEditor.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
final int editingColumn = myParametersTable.getSelectedColumn();
if (editingColumn != 0)
return;
final int editingRow = myParametersTable.getSelectedRow();
if (editingRow < 0 || editingRow >= pairs.size())
return;
String newNameValue = ((MySuggestedNameCellEditor) e.getSource()).getCellEditorValue();
final ParamInfo editingPair = pairs.get(editingRow);
editingPair.name = newNameValue;
}
@Override
public void editingCanceled(ChangeEvent e) {
}
});
}
Aggregations