Search in sources :

Example 51 with TableModelListener

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

the class MarkersList 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)

Example 52 with TableModelListener

use of javax.swing.event.TableModelListener in project cytoscape-impl by cytoscape.

the class PreviewTablePanel method getPreviewTable.

public JTable getPreviewTable() {
    if (previewTable == null) {
        previewTable = new JTable(new PreviewTableModel(new Vector<Vector<String>>(), new Vector<String>(), false));
        previewTable.setShowGrid(false);
        previewTable.setCellSelectionEnabled(false);
        previewTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        previewTable.setDefaultEditor(Object.class, null);
        if (importType == NETWORK_IMPORT) {
            final TableCellRenderer netRenderer = new PreviewTableCellRenderer();
            previewTable.setDefaultRenderer(Object.class, netRenderer);
        } else {
            previewTable.setDefaultRenderer(Object.class, new PreviewTableCellRenderer());
        }
        final JTableHeader hd = previewTable.getTableHeader();
        hd.setReorderingAllowed(false);
        hd.setDefaultRenderer(new PreviewTableHeaderRenderer());
        final TableColumnModelListener colModelListener = new TableColumnModelListener() {

            @Override
            public void columnMoved(TableColumnModelEvent e) {
                disposeEditDialog();
            }

            @Override
            public void columnMarginChanged(ChangeEvent e) {
                disposeEditDialog();
            }

            @Override
            public void columnSelectionChanged(ListSelectionEvent e) {
            }

            @Override
            public void columnRemoved(TableColumnModelEvent e) {
            }

            @Override
            public void columnAdded(TableColumnModelEvent e) {
            }
        };
        hd.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(final MouseEvent e) {
                final TableColumnModel columnModel = previewTable.getColumnModel();
                final int newColIdx = columnModel.getColumnIndexAtX(e.getX());
                final int idx = editDialog != null ? editDialog.index : -1;
                disposeEditDialog();
                if (idx != newColIdx)
                    showEditDialog(newColIdx);
                // Do not show editor dialog when the user is resizing the columns
                previewTable.getColumnModel().removeColumnModelListener(colModelListener);
                previewTable.getColumnModel().addColumnModelListener(colModelListener);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                previewTable.getColumnModel().removeColumnModelListener(colModelListener);
            }
        });
        // Also close the editor dialog when the table changes
        previewTable.getModel().addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                disposeEditDialog();
            }
        });
    }
    return previewTable;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) MouseEvent(java.awt.event.MouseEvent) TableModelEvent(javax.swing.event.TableModelEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener) Vector(java.util.Vector)

Example 53 with TableModelListener

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

the class Track method fireTableDataChanged.

private void fireTableDataChanged() {
    if (tableListeners == null) {
        return;
    }
    TableModelEvent tme = new TableModelEvent(this);
    for (Iterator iter = tableListeners.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)

Example 54 with TableModelListener

use of javax.swing.event.TableModelListener in project cytoscape-impl by cytoscape.

the class CellEditorEventHandler method switchMappingType.

private VisualMappingFunction<?, ?> switchMappingType(final VizMapperProperty<?, ?, ?> prop, final VisualProperty<?> vp, final VisualMappingFunctionFactory oldFactory, final VisualMappingFunctionFactory newFactory, final String controllingAttrName, final PropertySheetPanel propertySheetPanel) {
    // This is the currently selected Visual Style.
    final VisualStyle style = servicesUtil.get(VisualMappingManager.class).getCurrentVisualStyle();
    final VisualMappingFunction<?, ?> mapping = style.getVisualMappingFunction(vp);
    VisualMappingFunction<?, ?> newMapping = mapping;
    final Class<?> newMappingType = newFactory.getMappingFunctionType();
    if (mapping == null || mapping.getClass() != newMappingType || !mapping.getMappingColumnName().equals(controllingAttrName)) {
        final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
        final CyNetwork currentNet = appMgr.getCurrentNetwork();
        if (currentNet == null)
            return newMapping;
        // Mapping does not exist. Need to create new one.
        final AttributeSet attrSet = attrProxy.getAttributeSet(currentNet, vp.getTargetDataType());
        Class<?> attributeDataType = attrSet.getAttrMap().get(controllingAttrName);
        if (attributeDataType == null) {
            JOptionPane.showMessageDialog(null, "The current table does not have the selected column (\"" + controllingAttrName + "\").\nPlease select another column.", "Invalid Column.", JOptionPane.WARNING_MESSAGE);
            prop.setValue(oldFactory);
            return newMapping;
        }
        if (newMappingType == ContinuousMapping.class) {
            if (!Number.class.isAssignableFrom(attributeDataType)) {
                JOptionPane.showMessageDialog(null, "Selected column data type is not Number.\nPlease select a numerical column type.", "Incompatible Column Type.", JOptionPane.WARNING_MESSAGE);
                prop.setValue(oldFactory);
                return newMapping;
            }
        } else if (newMappingType == DiscreteMapping.class) {
            if (attributeDataType == List.class)
                attributeDataType = String.class;
        }
        // Create new mapping
        newMapping = newFactory.createVisualMappingFunction(controllingAttrName, attributeDataType, vp);
        // Keep old mapping values if the new mapping has the same type
        if (oldFactory != null && oldFactory.getMappingFunctionType() == newMappingType)
            copyMappingValues(mapping, newMapping);
    }
    // Disable listeners to avoid unnecessary updates
    final PropertySheetTableModel model = (PropertySheetTableModel) propertySheetPanel.getTable().getModel();
    final TableModelListener[] modelListeners = model.getTableModelListeners();
    for (final TableModelListener tm : modelListeners) model.removeTableModelListener(tm);
    vizMapPropertyBuilder.createMappingProperties(newMapping, propertySheetPanel, newFactory);
    // Restore listeners
    for (final TableModelListener tm : modelListeners) model.addTableModelListener(tm);
    return newMapping;
}
Also used : DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) AttributeSet(org.cytoscape.view.vizmap.gui.internal.model.AttributeSet) PropertySheetTableModel(com.l2fprod.common.propertysheet.PropertySheetTableModel) TableModelListener(javax.swing.event.TableModelListener) List(java.util.List) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager)

Example 55 with TableModelListener

use of javax.swing.event.TableModelListener in project elki by elki-project.

the class MiniGUI method setupParameterTable.

/**
 * Setup the parameter table
 */
private void setupParameterTable() {
    // Setup parameter storage and table model
    this.parameters = new DynamicParameters();
    ParametersModel parameterModel = new ParametersModel(parameters);
    parameterModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            // logger.debug("Change event.");
            updateParameterTable();
        }
    });
    // Create parameter table
    parameterTable = new ParameterTable(frame, parameterModel, parameters);
    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(parameterTable);
    // Add the scroll pane to this panel.
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    panel.add(scrollPane, constraints);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) ParametersModel(de.lmu.ifi.dbs.elki.gui.util.ParametersModel) ParameterTable(de.lmu.ifi.dbs.elki.gui.util.ParameterTable) TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) DynamicParameters(de.lmu.ifi.dbs.elki.gui.util.DynamicParameters)

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