use of com.intellij.refactoring.ui.StringTableCellEditor in project intellij-community by JetBrains.
the class ChangeClassSignatureDialog method createCenterPanel.
protected JComponent createCenterPanel() {
myTable = new JBTable(myTableModel);
myTable.setStriped(true);
TableColumn nameColumn = myTable.getColumnModel().getColumn(NAME_COLUMN);
TableColumn boundColumn = myTable.getColumnModel().getColumn(BOUND_VALUE_COLUMN);
TableColumn valueColumn = myTable.getColumnModel().getColumn(DEFAULT_VALUE_COLUMN);
Project project = myClass.getProject();
nameColumn.setCellRenderer(new MyCellRenderer());
nameColumn.setCellEditor(new StringTableCellEditor(project));
boundColumn.setCellRenderer(new MyCodeFragmentTableCellRenderer());
boundColumn.setCellEditor(new JavaCodeFragmentTableCellEditor(project));
valueColumn.setCellRenderer(new MyCodeFragmentTableCellRenderer());
valueColumn.setCellEditor(new JavaCodeFragmentTableCellEditor(project));
myTable.setPreferredScrollableViewportSize(new Dimension(210, myTable.getRowHeight() * 4));
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.getSelectionModel().setSelectionInterval(0, 0);
myTable.setSurrendersFocusOnKeystroke(true);
myTable.setCellSelectionEnabled(true);
myTable.setFocusCycleRoot(true);
if (myHideDefaultValueColumn) {
final TableColumn defaultValue = myTable.getColumnModel().getColumn(DEFAULT_VALUE_COLUMN);
myTable.removeColumn(defaultValue);
myTable.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.INSERT) {
myTable.getModel().removeTableModelListener(this);
final TableColumnAnimator animator = new TableColumnAnimator(myTable);
animator.setStep(20);
animator.addColumn(defaultValue, myTable.getWidth() / 2);
animator.startAndDoWhenDone(() -> myTable.editCellAt(myTable.getRowCount() - 1, 0));
animator.start();
}
}
});
}
final JPanel panel = new JPanel(new BorderLayout());
panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title"), myTable), BorderLayout.NORTH);
panel.add(ToolbarDecorator.createDecorator(myTable).createPanel(), BorderLayout.CENTER);
return panel;
}
use of com.intellij.refactoring.ui.StringTableCellEditor in project intellij-community by JetBrains.
the class AutomaticRenamingDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myTable.setModel(myTableModel);
myTableModel.getSpaceAction().register();
myTableModel.addTableModelListener(e -> handleChanges());
myTable.addMouseListener(new PopupHandler() {
@Override
public void invokePopup(Component comp, int x, int y) {
final int[] selectionRows = myTable.getSelectedRows();
if (selectionRows != null) {
compoundPopup().show(comp, x, y);
}
}
});
final TableColumnModel columnModel = myTable.getColumnModel();
columnModel.getColumn(CHECK_COLUMN).setCellRenderer(new BooleanTableCellRenderer());
TableUtil.setupCheckboxColumn(columnModel.getColumn(CHECK_COLUMN));
columnModel.getColumn(NEW_NAME_COLUMN).setCellEditor(new StringTableCellEditor(myProject));
mySelectAllButton.addActionListener(e -> {
for (int i = 0; i < myShouldRename.length; i++) {
myShouldRename[i] = true;
}
fireDataChanged();
});
myUnselectAllButton.addActionListener(e -> {
for (int i = 0; i < myShouldRename.length; i++) {
myShouldRename[i] = false;
}
fireDataChanged();
});
myListSelectionListener = e -> {
myUsageFileLabel.setText("");
int index = myTable.getSelectionModel().getLeadSelectionIndex();
if (index != -1) {
PsiNamedElement element = myRenames[index];
UsageInfo usageInfo = new UsageInfo(element);
myUsagePreviewPanel.updateLayout(Collections.singletonList(usageInfo));
final PsiFile containingFile = element.getContainingFile();
if (containingFile != null) {
final VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile != null) {
myUsageFileLabel.setText(virtualFile.getName());
}
}
} else {
myUsagePreviewPanel.updateLayout(null);
}
};
myTable.getSelectionModel().addListSelectionListener(myListSelectionListener);
myPanelForPreview.add(myUsagePreviewPanel, BorderLayout.CENTER);
myUsagePreviewPanel.updateLayout(null);
myPanelForPreview.add(myUsageFileLabel, BorderLayout.NORTH);
mySplitPane.setDividerLocation(0.5);
GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
if (myTableModel.getRowCount() != 0) {
myTable.getSelectionModel().addSelectionInterval(0, 0);
}
return myPanel;
}
Aggregations