use of javax.swing.event.TableModelEvent in project jmeter by apache.
the class PowerTableModel method moveRow.
@Override
public void moveRow(int start, int end, int to) {
ArrayList<Object[]> rows = new ArrayList<>();
for (int i = 0; i < getRowCount(); i++) {
rows.add(getRowData(i));
}
List<Object[]> subList = new ArrayList<>(rows.subList(start, end));
for (int x = end - 1; x >= start; x--) {
rows.remove(x);
}
rows.addAll(to, subList);
for (int i = 0; i < rows.size(); i++) {
setRowValues(i, rows.get(i));
}
super.fireTableChanged(new TableModelEvent(this));
}
use of javax.swing.event.TableModelEvent in project jmeter by apache.
the class TableModelEventBacker method assertEvents.
/**
* Checks each event assertion against each backed event in order. Event storage is cleared after it.
* @param assertions a collection if {@link EventAssertion}s to check
*/
public void assertEvents(EventAssertion... assertions) {
try {
assertEquals("event count", assertions.length, events.size());
int i = 0;
for (TableModelEvent event : events) {
assertions[i].assertEvent(event, i++);
}
} finally {
events.clear();
}
}
use of javax.swing.event.TableModelEvent in project intellij-community by JetBrains.
the class JavaChangeSignatureDialog method customizeParametersTable.
@Override
protected void customizeParametersTable(TableView<ParameterTableModelItemBase<ParameterInfoImpl>> table) {
final JTable t = table.getComponent();
final TableColumn defaultValue = t.getColumnModel().getColumn(2);
final TableColumn varArg = t.getColumnModel().getColumn(3);
t.removeColumn(defaultValue);
t.removeColumn(varArg);
t.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.INSERT) {
t.getModel().removeTableModelListener(this);
final TableColumnAnimator animator = new TableColumnAnimator(t);
animator.setStep(48);
animator.addColumn(defaultValue, (t.getWidth() - 48) / 3);
animator.addColumn(varArg, 48);
animator.startAndDoWhenDone(() -> t.editCellAt(t.getRowCount() - 1, 0));
animator.start();
}
}
});
}
use of javax.swing.event.TableModelEvent 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 javax.swing.event.TableModelEvent in project jdk8u_jdk by JetBrains.
the class TableSorter method sortByColumn.
public void sortByColumn(int column, boolean ascending) {
this.ascending = ascending;
sortingColumns.clear();
sortingColumns.add(column);
sort(this);
super.tableChanged(new TableModelEvent(this));
}
Aggregations