Search in sources :

Example 6 with CellEditorListener

use of javax.swing.event.CellEditorListener in project cytoscape-api by cytoscape.

the class AbstractCellEditorTest method testAddCellEditorListener.

@Test
public void testAddCellEditorListener() {
    CellEditorListener l = mock(CellEditorListener.class);
    editor.addCellEditorListener(l);
    assertEquals(1, editor.listenerList.getListenerCount());
    editor.removeCellEditorListener(l);
    assertEquals(0, editor.listenerList.getListenerCount());
}
Also used : CellEditorListener(javax.swing.event.CellEditorListener) Test(org.junit.Test)

Example 7 with CellEditorListener

use of javax.swing.event.CellEditorListener in project intellij-community by JetBrains.

the class DynamicMethodDialog method setupParameterTable.

private void setupParameterTable(final List<ParamInfo> pairs) {
    MySuggestedNameCellEditor suggestedNameCellEditor = new MySuggestedNameCellEditor(QuickfixUtil.getArgumentsNames(pairs));
    myParametersTable.setDefaultEditor(String.class, suggestedNameCellEditor);
    suggestedNameCellEditor.addCellEditorListener(new CellEditorListener() {

        @Override
        public void editingStopped(ChangeEvent e) {
            final int editingColumn = myParametersTable.getSelectedColumn();
            if (editingColumn != 0)
                return;
            final int editingRow = myParametersTable.getSelectedRow();
            if (editingRow < 0 || editingRow >= pairs.size())
                return;
            String newNameValue = ((MySuggestedNameCellEditor) e.getSource()).getCellEditorValue();
            final ParamInfo editingPair = pairs.get(editingRow);
            editingPair.name = newNameValue;
        }

        @Override
        public void editingCanceled(ChangeEvent e) {
        }
    });
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) CellEditorListener(javax.swing.event.CellEditorListener) ParamInfo(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ParamInfo)

Example 8 with CellEditorListener

use of javax.swing.event.CellEditorListener in project jdk8u_jdk by JetBrains.

the class XTextFieldEditor method fireEditingStopped.

protected void fireEditingStopped() {
    CellEditorListener listener;
    Object[] listeners = evtListenerList.getListenerList();
    for (int i = 0; i < listeners.length; i++) {
        if (listeners[i] == CellEditorListener.class) {
            listener = (CellEditorListener) listeners[i + 1];
            listener.editingStopped(changeEvent);
        }
    }
}
Also used : CellEditorListener(javax.swing.event.CellEditorListener) EventObject(java.util.EventObject)

Example 9 with CellEditorListener

use of javax.swing.event.CellEditorListener 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 10 with CellEditorListener

use of javax.swing.event.CellEditorListener in project JMRI by JMRI.

the class ValueEditor method fireEditingStopped.

protected void fireEditingStopped() {
    if (log.isDebugEnabled()) {
        log.debug("fireEditingStopped");
    }
    Vector<CellEditorListener> local;
    synchronized (listeners) {
        local = new Vector<CellEditorListener>(listeners);
    }
    ChangeEvent ce = new ChangeEvent(this);
    for (int i = local.size() - 1; i >= 0; i--) {
        local.elementAt(i).editingStopped(ce);
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) CellEditorListener(javax.swing.event.CellEditorListener)

Aggregations

CellEditorListener (javax.swing.event.CellEditorListener)12 ChangeEvent (javax.swing.event.ChangeEvent)6 EventObject (java.util.EventObject)3 TableCellRenderer (javax.swing.table.TableCellRenderer)3 Test (org.junit.Test)3 ActionEvent (java.awt.event.ActionEvent)2 TableCellEditor (javax.swing.table.TableCellEditor)2 PackageEntry (com.intellij.psi.codeStyle.PackageEntry)1 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)1 RefactoringElementListenerProvider (com.intellij.refactoring.listeners.RefactoringElementListenerProvider)1 JBTable (com.intellij.ui.table.JBTable)1 ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)1 TreeTableTree (com.intellij.ui.treeStructure.treetable.TreeTableTree)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ColumnInfo (com.intellij.util.ui.ColumnInfo)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 AbstractAction (javax.swing.AbstractAction)1 Action (javax.swing.Action)1 InputMap (javax.swing.InputMap)1