Search in sources :

Example 36 with TableCellEditor

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();
}
Also used : PsiNameHelper(com.intellij.psi.PsiNameHelper) CommitStepException(com.intellij.ide.wizard.CommitStepException) TableCellEditor(javax.swing.table.TableCellEditor)

Example 37 with TableCellEditor

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();
}
Also used : TableCellEditor(javax.swing.table.TableCellEditor)

Example 38 with TableCellEditor

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);
}
Also used : TableCellEditor(javax.swing.table.TableCellEditor)

Example 39 with TableCellEditor

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);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) EventObject(java.util.EventObject) CellEditorListener(javax.swing.event.CellEditorListener) TableCellEditor(javax.swing.table.TableCellEditor) EventObject(java.util.EventObject)

Example 40 with TableCellEditor

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);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Aggregations

TableCellEditor (javax.swing.table.TableCellEditor)62 JButton (javax.swing.JButton)37 ButtonEditor (jmri.util.table.ButtonEditor)33 ButtonRenderer (jmri.util.table.ButtonRenderer)33 TableColumnModel (javax.swing.table.TableColumnModel)23 JLabel (javax.swing.JLabel)14 JTable (javax.swing.JTable)13 ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)9 BoxLayout (javax.swing.BoxLayout)9 JPanel (javax.swing.JPanel)9 JScrollPane (javax.swing.JScrollPane)9 TableColumn (javax.swing.table.TableColumn)9 TableCellRenderer (javax.swing.table.TableCellRenderer)8 FlowLayout (java.awt.FlowLayout)6 MouseEvent (java.awt.event.MouseEvent)6 XTableColumnModel (jmri.util.swing.XTableColumnModel)6 Container (java.awt.Container)5 JTextField (javax.swing.JTextField)5 JmriJFrame (jmri.util.JmriJFrame)5