use of javax.swing.table.TableCellEditor in project jmeter-plugins by undera.
the class CopyRowAction method actionPerformed.
public void actionPerformed(ActionEvent e) {
if (grid.isEditing()) {
TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn());
cellEditor.stopCellEditing();
}
final int selectedRow = grid.getSelectedRow();
if (tableModel.getRowCount() == 0 || selectedRow < 0) {
return;
}
tableModel.addRow(tableModel.getRowData(selectedRow));
tableModel.fireTableDataChanged();
// Enable DELETE (which may already be enabled, but it won't hurt)
deleteRowButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = selectedRow + 1;
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
sender.updateUI();
}
use of javax.swing.table.TableCellEditor in project jmeter-plugins by undera.
the class DeleteRowAction method actionPerformed.
public void actionPerformed(ActionEvent e) {
if (grid.isEditing()) {
TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn());
cellEditor.cancelCellEditing();
}
int rowSelected = grid.getSelectedRow();
if (rowSelected >= 0) {
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
// Disable DELETE if there are no rows in the table to delete.
if (tableModel.getRowCount() == 0) {
deleteRowButton.setEnabled(false);
} else // Table still contains one or more rows, so highlight (select)
// the appropriate one.
{
int rowToSelect = rowSelected;
if (rowSelected >= tableModel.getRowCount()) {
rowToSelect = rowSelected - 1;
}
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
sender.updateUI();
}
}
use of javax.swing.table.TableCellEditor in project jmeter-plugins by undera.
the class MergeResultsGui method actionPerformed.
public void actionPerformed(ActionEvent action) {
String command = action.getActionCommand();
if (grid.isEditing()) {
TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn());
cellEditor.stopCellEditing();
}
switch(command) {
case ACTION_ADD:
{
tableModel.addRow(defaultValues);
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() >= MAX_FILE_HANDLES) {
addRowButton.setEnabled(false);
copyRowButton.setEnabled(false);
}
// Enable DELETE and MERGE
deleteRowButton.setEnabled(true);
mergeButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
if (rowToSelect < grid.getRowCount()) {
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
updateUI();
break;
}
case ACTION_COPY:
{
final int selectedRow = grid.getSelectedRow();
if (tableModel.getRowCount() == 0 || selectedRow < 0) {
return;
}
tableModel.addRow(tableModel.getRowData(selectedRow));
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() >= MAX_FILE_HANDLES) {
addRowButton.setEnabled(false);
copyRowButton.setEnabled(false);
}
// Enable DELETE and MERGE
deleteRowButton.setEnabled(true);
mergeButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = selectedRow + 1;
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
updateUI();
break;
}
case ACTION_DELETE:
final int rowSelected = grid.getSelectedRow();
if (rowSelected >= 0) {
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() < MAX_FILE_HANDLES) {
addRowButton.setEnabled(true);
copyRowButton.setEnabled(true);
}
// table to delete.
if (tableModel.getRowCount() == 0) {
deleteRowButton.setEnabled(false);
mergeButton.setEnabled(false);
} else // Table still contains one or more rows, so highlight
// (select) the appropriate one.
{
int rowToSelect = rowSelected;
if (rowSelected >= tableModel.getRowCount()) {
rowToSelect = rowSelected - 1;
}
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
updateUI();
}
break;
case ACTION_MERGE:
String output = getFile();
if (output.isEmpty()) {
GuiPackage.showErrorMessage("Error merging results files - empty output filename", "Output file error");
return;
}
boolean isSuccess = loadFilesFromTable((CorrectedResultCollector) collector);
if (isSuccess) {
mergeService = new MergeResultsService();
collector.setFilename(output);
mergeService.mergeSamples((CorrectedResultCollector) collector, samples);
}
samples.clear();
break;
case ACTION_SAVE_CONFIG:
SavePropertyDialog d = new SavePropertyDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("sample_result_save_configuration"), true, collector.getSaveConfig());
d.pack();
ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), d);
d.setVisible(true);
break;
}
}
use of javax.swing.table.TableCellEditor in project cytoscape-impl by cytoscape.
the class GUIJobDialog method initUI.
public void initUI() {
// Create table of jobs
jobTableModel = new JobTableModel(this);
JTable table = new JTable(jobTableModel);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
// Put in JScrollPane
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(500, 100));
// Set up our button renderer
TableCellRenderer buttonRenderer = new JTableButtonRenderer();
table.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JCheckBox());
table.setDefaultEditor(JButton.class, buttonEditor);
table.setRowHeight(30);
// Create bottom panel
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), null, closeButton.getAction());
// add to dialog
setLayout(new BorderLayout());
add(scrollPane, BorderLayout.CENTER);
add(bottomPanel, BorderLayout.SOUTH);
}
use of javax.swing.table.TableCellEditor in project cytoscape-impl by cytoscape.
the class BrowserTable method editCellAt.
@Override
public boolean editCellAt(int row, int column, EventObject e) {
if (cellEditor != null && !cellEditor.stopCellEditing())
return false;
if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount())
return false;
if (!isCellEditable(row, column))
return false;
if (editorRemover == null) {
KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
editorRemover = new CellEditorRemover(fm);
fm.addPropertyChangeListener("permanentFocusOwner", editorRemover);
}
TableCellEditor editor = getCellEditor(row, column);
// remember the table row, because tableModel will disappear if
// user click on open space on canvas, so we have to remember it before it is gone
BrowserTableModel model = (BrowserTableModel) this.getModel();
CyRow cyRow = model.getCyRow(convertRowIndexToModel(row));
String columnName = model.getColumnName(convertColumnIndexToModel(column));
editorRemover.setCellData(cyRow, columnName);
if ((editor != null) && editor.isCellEditable(e)) {
// Do this first so that the bounds of the JTextArea editor will be correct.
setEditingRow(row);
setEditingColumn(column);
setCellEditor(editor);
editor.addCellEditorListener(this);
editorComp = prepareEditor(editor, row, column);
if (editorComp == null) {
removeEditor();
return false;
}
Rectangle cellRect = getCellRect(row, column, false);
if (editor instanceof MultiLineTableCellEditor) {
Dimension prefSize = editorComp.getPreferredSize();
((JComponent) editorComp).putClientProperty(MultiLineTableCellEditor.UPDATE_BOUNDS, Boolean.TRUE);
editorComp.setBounds(cellRect.x, cellRect.y, Math.max(cellRect.width, prefSize.width), Math.max(cellRect.height, prefSize.height));
((JComponent) editorComp).putClientProperty(MultiLineTableCellEditor.UPDATE_BOUNDS, Boolean.FALSE);
} else {
editorComp.setBounds(cellRect);
}
add(editorComp);
editorComp.validate();
return true;
}
return false;
}
Aggregations