Search in sources :

Example 11 with TableModelListener

use of javax.swing.event.TableModelListener in project sldeditor by robward-scisys.

the class DataSourceConfigPanel method createTable.

/**
 * Creates the table.
 *
 * @return the component
 */
private Component createTable() {
    final UndoActionInterface parentObj = this;
    dataModel = new DataSourceAttributeModel();
    dataModel.addTableModelListener(new TableModelListener() {

        /**
         * Table changed.
         *
         * @param arg0 the arg0
         */
        @Override
        public void tableChanged(TableModelEvent arg0) {
            if (!isPopulatingTable()) {
                dataChanged = true;
                updateButtonState();
            }
        }
    });
    table = new JTable();
    table.setModel(dataModel);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent arg0) {
            updateButtonState();
        }
    });
    TableColumn tmpColum = table.getColumnModel().getColumn(1);
    JComboBox<String> comboBox = new JComboBox<String>(dataModel.getTypeData());
    DefaultCellEditor defaultCellEditor = new DefaultCellEditor(comboBox);
    tmpColum.setCellEditor(defaultCellEditor);
    tmpColum.setCellRenderer(new ComboBoxCellRenderer(comboBox));
    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
    flowLayout.setHgap(1);
    flowLayout.setAlignment(FlowLayout.TRAILING);
    add(buttonPanel, BorderLayout.SOUTH);
    btnDisconnect = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.disconnect"));
    btnDisconnect.setEnabled(false);
    btnDisconnect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SLDEditorFile.getInstance().getSLDData().setDataSourceProperties(DataSourceConnectorFactory.getNoDataSource());
            applyData(parentObj);
        }
    });
    buttonPanel.add(btnDisconnect);
    btnAddField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.add"));
    btnAddField.setEnabled(false);
    btnAddField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addNewField();
        }
    });
    buttonPanel.add(btnAddField);
    btnRemoveField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.remove"));
    btnRemoveField.setEnabled(false);
    btnRemoveField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            removeField();
        }
    });
    buttonPanel.add(btnRemoveField);
    btnApply = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.apply"));
    btnApply.setEnabled(false);
    btnApply.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            applyData(parentObj);
        }
    });
    buttonPanel.add(btnApply);
    btnCancel = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.cancel"));
    btnCancel.setEnabled(false);
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            cancelData();
        }
    });
    buttonPanel.add(btnCancel);
    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) TableModelEvent(javax.swing.event.TableModelEvent) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) TableColumn(javax.swing.table.TableColumn) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ListSelectionListener(javax.swing.event.ListSelectionListener) DefaultCellEditor(javax.swing.DefaultCellEditor) ActionListener(java.awt.event.ActionListener) TableModelListener(javax.swing.event.TableModelListener) JTable(javax.swing.JTable)

Example 12 with TableModelListener

use of javax.swing.event.TableModelListener in project Spark by igniterealtime.

the class OTRPrefPanel method loadRemoteKeys.

private void loadRemoteKeys() {
    for (RosterEntry entry : Roster.getInstanceFor(SparkManager.getConnection()).getEntries()) {
        SessionID curSession = new SessionID(SparkManager.getConnection().getUser(), entry.getUser(), "Scytale");
        String remoteKey = _keyManager.getRemoteFingerprint(curSession);
        if (remoteKey != null) {
            boolean isVerified = _keyManager.isVerified(curSession);
            _keytable.addEntry(entry.getUser(), remoteKey, isVerified);
        }
    }
    _keytable.addTableChangeListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            int col = e.getColumn();
            int row = e.getFirstRow();
            if (col == 2) {
                boolean selection = (Boolean) _keytable.getValueAt(row, col);
                String JID = (String) _keytable.getValueAt(row, 0);
                SessionID curSelectedSession = new SessionID(SparkManager.getConnection().getUser(), JID, "Scytale");
                if (!selection) {
                    _keyManager.verify(curSelectedSession);
                } else {
                    _keyManager.unverify(curSelectedSession);
                }
            }
        }
    });
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) RosterEntry(org.jivesoftware.smack.roster.RosterEntry) SessionID(net.java.otr4j.session.SessionID)

Example 13 with TableModelListener

use of javax.swing.event.TableModelListener in project blue by kunstmusik.

the class OpcodeList method fireTableDataChanged.

private void fireTableDataChanged() {
    if (listeners == null) {
        return;
    }
    TableModelEvent tme = new TableModelEvent(this);
    for (Iterator<TableModelListener> iter = listeners.iterator(); iter.hasNext(); ) {
        TableModelListener listener = iter.next();
        listener.tableChanged(tme);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 14 with TableModelListener

use of javax.swing.event.TableModelListener in project blue by kunstmusik.

the class TrackList method fireTableModelEvent.

private void fireTableModelEvent(TableModelEvent tme) {
    if (listeners != null) {
        for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
            TableModelListener listener = (TableModelListener) iter.next();
            listener.tableChanged(tme);
        }
    }
}
Also used : TableModelListener(javax.swing.event.TableModelListener) Iterator(java.util.Iterator)

Example 15 with TableModelListener

use of javax.swing.event.TableModelListener in project blue by kunstmusik.

the class PatternObject method fireTableDataChanged.

private void fireTableDataChanged() {
    if (listeners == null) {
        return;
    }
    TableModelEvent tme = new TableModelEvent(this);
    for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
        TableModelListener listener = (TableModelListener) iter.next();
        listener.tableChanged(tme);
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) Iterator(java.util.Iterator)

Aggregations

TableModelListener (javax.swing.event.TableModelListener)68 TableModelEvent (javax.swing.event.TableModelEvent)54 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