use of javax.swing.table.TableCellEditor in project intellij-community by JetBrains.
the class BindToNewBeanStep method _commit.
public void _commit(boolean finishChosen) throws CommitStepException {
// Stop editing if any
final TableCellEditor cellEditor = myTable.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
// Check that all included fields are bound to valid bean properties
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myData.myProject);
for (int i = 0; i < myData.myBindings.length; i++) {
final FormProperty2BeanProperty binding = myData.myBindings[i];
if (binding.myBeanProperty == null) {
continue;
}
if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)) {
throw new CommitStepException(UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName));
}
}
myData.myGenerateIsModified = myChkIsModified.isSelected();
}
use of javax.swing.table.TableCellEditor in project intellij-plugins by JetBrains.
the class AddRemoveTableRowsDialog method doOKAction.
protected void doOKAction() {
final TableCellEditor cellEditor = myTable.getCellEditor();
if (cellEditor != null) {
// apply currently edited value if any
cellEditor.stopCellEditing();
}
super.doOKAction();
}
use of javax.swing.table.TableCellEditor in project intellij-plugins by JetBrains.
the class OsmorcFacetJAREditorTab method onRemoveAdditionalJarContent.
private void onRemoveAdditionalJarContent() {
int row = myAdditionalJARContentsTable.convertRowIndexToModel(myAdditionalJARContentsTable.getSelectedRow());
int editingCol = myAdditionalJARContentsTable.getEditingColumn();
int editingRow = myAdditionalJARContentsTable.getEditingRow();
if (editingCol != -1 && editingRow != -1) {
TableCellEditor editor = myAdditionalJARContentsTable.getCellEditor(editingRow, editingCol);
editor.cancelCellEditing();
}
myAdditionalJARContentsTableModel.deleteAdditionalJARContent(row);
}
use of javax.swing.table.TableCellEditor in project jdk8u_jdk by JetBrains.
the class bug6711682 method createAndShowGUI.
private static void createAndShowGUI() {
editorCb = new JCheckBox();
rendererCb = new JCheckBox();
JFrame f = new JFrame("Table with CheckBox");
Container p = f.getContentPane();
p.setLayout(new BorderLayout());
table = new JTable(new Object[][] { { false }, { false }, { false } }, new Object[] { "CheckBox" });
TableCellEditor editor = new TableCellEditor() {
int editedRow;
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.editedRow = row;
editorCb.setSelected(Boolean.TRUE.equals(value));
editorCb.setBackground(UIManager.getColor("Table.selectionBackground"));
return editorCb;
}
public void addCellEditorListener(CellEditorListener l) {
}
public void cancelCellEditing() {
}
public Object getCellEditorValue() {
return editorCb.isSelected();
}
public boolean isCellEditable(EventObject anEvent) {
return true;
}
public void removeCellEditorListener(CellEditorListener l) {
}
public boolean shouldSelectCell(EventObject anEvent) {
return true;
}
public boolean stopCellEditing() {
table.getModel().setValueAt(editorCb.isSelected(), editedRow, 0);
return true;
}
};
table.getColumnModel().getColumn(0).setCellEditor(editor);
TableCellRenderer renderer = new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
rendererCb.setSelected(Boolean.TRUE.equals(value));
return rendererCb;
}
};
table.getColumnModel().getColumn(0).setCellRenderer(renderer);
p.add(table, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class AutomatTableDataModel method setColumnToHoldButton.
/**
* Service method to setup a column so that it will hold a button for it's
* values
*
* @param table the table in which to configure the column
* @param column the position of the configured column
* @param sample typical button, used for size
*/
void setColumnToHoldButton(JTable table, int column, JButton sample) {
TableColumnModel tcm = table.getColumnModel();
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
table.setRowHeight(sample.getPreferredSize().height);
table.getColumnModel().getColumn(column).setPreferredWidth(sample.getPreferredSize().width);
}
Aggregations