Search in sources :

Example 1 with TableModelListener

use of javax.swing.event.TableModelListener in project ACS by ACS-Community.

the class LogLevelSelectorPanel method initLogLevelsPanel.

/**
	 * Initialize the log level panel (i.e. the table)
	 * 
	 * @return The panel with the table of log levels
	 * 
	 * @throws LogLvlSelNotSupportedException If the configurable does not support selection
	 */
private JComponent initLogLevelsPanel() throws AcsJCORBAProblemEx {
    LogLevelHelper[] levels = loggersLbl();
    model = new LogLevelModel(levels);
    model.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            applyBtn.setEnabled(userChangedLogLevels());
        }
    });
    table = new LogLevelTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 2 with TableModelListener

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

the class AbstractTableView method initializeTable.

protected final void initializeTable() {
    myTable.setModelAndUpdateColumns(myTableModel);
    if (getEmptyPaneText() != null) {
        final CardLayout cardLayout = ((CardLayout) myInnerPanel.getLayout());
        myTable.getModel().addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                cardLayout.show(myInnerPanel, myTable.getRowCount() == 0 ? EMPTY_PANE : TREE);
            }
        });
    }
    tuneTable(myTable);
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 3 with TableModelListener

use of javax.swing.event.TableModelListener 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();
            }
        }
    });
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) TableColumn(javax.swing.table.TableColumn)

Example 4 with TableModelListener

use of javax.swing.event.TableModelListener 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;
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) JBTable(com.intellij.ui.table.JBTable) TableColumn(javax.swing.table.TableColumn) JavaCodeFragmentTableCellEditor(com.intellij.refactoring.ui.JavaCodeFragmentTableCellEditor) Project(com.intellij.openapi.project.Project) TableModelListener(javax.swing.event.TableModelListener) StringTableCellEditor(com.intellij.refactoring.ui.StringTableCellEditor)

Example 5 with TableModelListener

use of javax.swing.event.TableModelListener in project libgdx by libgdx.

the class DynamicsInfluencerPanel method initializeComponents.

protected void initializeComponents() {
    super.initializeComponents();
    JPanel velocitiesPanel = new JPanel();
    velocitiesPanel.setLayout(new GridBagLayout());
    {
        JPanel sideButtons = new JPanel(new GridBagLayout());
        velocitiesPanel.add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        {
            sideButtons.add(velocityBox = new JComboBox(new DefaultComboBoxModel()), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton newButton = new JButton("New");
            sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            newButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    createVelocity(velocityBox.getSelectedItem());
                }
            });
        }
        {
            JButton deleteButton = new JButton("Delete");
            sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            deleteButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    deleteVelocity();
                }
            });
        }
    }
    JScrollPane scroll = new JScrollPane();
    velocitiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    velocityTable = new JTable() {

        public Class getColumnClass(int column) {
            return column == 1 ? Boolean.class : super.getColumnClass(column);
        }

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension dim = super.getPreferredScrollableViewportSize();
            dim.height = getPreferredSize().height;
            return dim;
        }
    };
    velocityTable.getTableHeader().setReorderingAllowed(false);
    velocityTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scroll.setViewportView(velocityTable);
    velocityTableModel = new DefaultTableModel(new String[0][0], new String[] { "Velocity", "Active" });
    velocityTable.setModel(velocityTableModel);
    velocityTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            velocitySelected();
        }
    });
    velocityTableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent event) {
            if (event.getColumn() != 1)
                return;
            velocityChecked(event.getFirstRow(), (Boolean) velocityTable.getValueAt(event.getFirstRow(), 1));
        }
    });
    //Velocity values
    emptyPanel = new ParticleValuePanel(editor, "", "", true, false);
    strengthVelocityPanel = new StrengthVelocityPanel(editor, null, "Life", "", "");
    angularVelocityPanel = new AngularVelocityPanel(editor, null, "Life", "", "");
    strengthVelocityPanel.setVisible(false);
    angularVelocityPanel.setVisible(false);
    emptyPanel.setVisible(false);
    strengthVelocityPanel.setIsAlwayShown(true);
    angularVelocityPanel.setIsAlwayShown(true);
    emptyPanel.setIsAlwayShown(true);
    emptyPanel.setValue(null);
    //Assemble
    int i = 0;
    addContent(i++, 0, velocitiesPanel);
    addContent(i++, 0, strengthVelocityPanel);
    addContent(i++, 0, angularVelocityPanel);
    addContent(i++, 0, emptyPanel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) TableModelEvent(javax.swing.event.TableModelEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener)

Aggregations

TableModelListener (javax.swing.event.TableModelListener)69 TableModelEvent (javax.swing.event.TableModelEvent)55 JScrollPane (javax.swing.JScrollPane)11 Iterator (java.util.Iterator)9 JTable (javax.swing.JTable)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ActionEvent (java.awt.event.ActionEvent)8 ListSelectionListener (javax.swing.event.ListSelectionListener)8 Dimension (java.awt.Dimension)7 ActionListener (java.awt.event.ActionListener)7 JButton (javax.swing.JButton)7 JPanel (javax.swing.JPanel)7 DefaultTableModel (javax.swing.table.DefaultTableModel)6 TableColumn (javax.swing.table.TableColumn)6 ArrayList (java.util.ArrayList)5 GridBagConstraints (java.awt.GridBagConstraints)4 KeyShortcut (com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut)3 BorderLayout (java.awt.BorderLayout)3 Insets (java.awt.Insets)3 MouseAdapter (java.awt.event.MouseAdapter)3