Search in sources :

Example 46 with TableModelListener

use of javax.swing.event.TableModelListener in project processdash by dtuma.

the class DefectImportForm method createButtonBox.

private Box createButtonBox() {
    JButton cancelButton = new JButton(resources.getString("Cancel"));
    cancelButton.addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "cancel"));
    final JButton importButton = new JButton(resources.getString("Import_Button"));
    importButton.addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "doImport"));
    importButton.setEnabled(false);
    final BoundDefectData data = BoundDefectData.getDefectData(this);
    data.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            importButton.setEnabled(data.hasSelectedDefects());
        }
    });
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(Box.createHorizontalGlue());
    buttonBox.add(cancelButton);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(importButton);
    buttonBox.setBorder(new EmptyBorder(10, 10, 10, 10));
    return buttonBox;
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) JButton(javax.swing.JButton) Box(javax.swing.Box) EmptyBorder(javax.swing.border.EmptyBorder)

Example 47 with TableModelListener

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

the class MLogicalStyleController method getConditionalStyleModelAsTableModel.

public TableModel getConditionalStyleModelAsTableModel(final MapModel map, final ConditionalStyleModel conditionalStyleModel) {
    return new TableModel() {

        private final TableModel tableModel = conditionalStyleModel.asTableModel();

        public void addTableModelListener(TableModelListener l) {
            tableModel.addTableModelListener(l);
        }

        public Class<?> getColumnClass(int columnIndex) {
            return tableModel.getColumnClass(columnIndex);
        }

        public int getColumnCount() {
            return tableModel.getColumnCount();
        }

        public String getColumnName(int columnIndex) {
            return tableModel.getColumnName(columnIndex);
        }

        public int getRowCount() {
            return tableModel.getRowCount();
        }

        public Object getValueAt(int rowIndex, int columnIndex) {
            return tableModel.getValueAt(rowIndex, columnIndex);
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return tableModel.isCellEditable(rowIndex, columnIndex);
        }

        public void removeTableModelListener(TableModelListener l) {
            tableModel.removeTableModelListener(l);
        }

        public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) {
            final Object oldValue = tableModel.getValueAt(rowIndex, columnIndex);
            if (aValue == oldValue || aValue != null && aValue.equals(oldValue)) {
                return;
            }
            IActor actor = new IActor() {

                public String getDescription() {
                    return "set conditional style table cell value";
                }

                public void act() {
                    tableModel.setValueAt(aValue, rowIndex, columnIndex);
                }

                public void undo() {
                    tableModel.setValueAt(oldValue, rowIndex, columnIndex);
                }
            };
            Controller.getCurrentModeController().execute(actor, map);
        }
    };
}
Also used : TableModelListener(javax.swing.event.TableModelListener) IActor(org.freeplane.core.undo.IActor) TableModel(javax.swing.table.TableModel)

Example 48 with TableModelListener

use of javax.swing.event.TableModelListener in project jmeter-plugins by undera.

the class ChartRowsTable method initializeTableModel.

private void initializeTableModel() {
    ObjectTableModel model = new ObjectTableModel(new String[] { "(Un)Check All", "Legend Color", "Row Name" }, AbstractGraphRow.class, new Functor[] { new Functor("isDrawOnChart"), new Functor("getColor"), new Functor("getLabel") }, new Functor[] { new Functor("setDrawOnChart"), null, null }, new Class[] { Boolean.class, Color.class, String.class });
    model.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            if (parentContainer != null) {
                parentContainer.refreshPreview();
            }
        }
    });
    setModel(model);
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) Functor(org.apache.jorphan.reflect.Functor)

Example 49 with TableModelListener

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

the class LineView method editPoints.

private void editPoints() {
    TableView<LinePoint> table = new TableView<>();
    TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
    TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
    table.getColumns().setAll(xCol, yCol);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(getSelectedLine().getObservableList());
    table.setEditable(true);
    xCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("x"));
    xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    xCol.setOnEditCommit(te -> {
        LinePoint lp = te.getRowValue();
        if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
            return;
        }
        lp.setX(Utils.clamp(0.0, te.getNewValue(), 1.0));
    });
    xCol.setEditable(true);
    yCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("y"));
    yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    yCol.setOnEditCommit(te -> {
        te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
    });
    yCol.setEditable(true);
    Dialog<ButtonType> d = new Dialog<>();
    d.initOwner(getScene().getWindow());
    d.initModality(Modality.APPLICATION_MODAL);
    d.getDialogPane().setContent(new ScrollPane(table));
    d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
    d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
    d.setTitle("Edit Points");
    TableModelListener tml = tme -> {
        repaint();
    };
    getSelectedLine().addTableModelListener(tml);
    Optional<ButtonType> res = d.showAndWait();
    getSelectedLine().removeTableModelListener(tml);
}
Also used : DoubleStringConverter(javafx.util.converter.DoubleStringConverter) NumberUtilities(blue.utility.NumberUtilities) ButtonType(javafx.scene.control.ButtonType) LineList(blue.components.lines.LineList) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableModelListener(javax.swing.event.TableModelListener) LinePoint(blue.components.lines.LinePoint) TableColumn(javafx.scene.control.TableColumn) DragDirection(blue.components.DragDirection) Utils(org.controlsfx.tools.Utils) BlueFX(blue.jfx.BlueFX) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) MenuItem(javafx.scene.control.MenuItem) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphicsContext(javafx.scene.canvas.GraphicsContext) Canvas(javafx.scene.canvas.Canvas) Line(blue.components.lines.Line) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Paint(javafx.scene.paint.Paint) Optional(java.util.Optional) DoubleStringConverter(javafx.util.converter.DoubleStringConverter) TableColumn(javafx.scene.control.TableColumn) LinePoint(blue.components.lines.LinePoint) Dialog(javafx.scene.control.Dialog) ScrollPane(javafx.scene.control.ScrollPane) TableModelListener(javax.swing.event.TableModelListener) ButtonType(javafx.scene.control.ButtonType) TableView(javafx.scene.control.TableView)

Example 50 with TableModelListener

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

the class MarkersList method addMarker.

public void addMarker(Marker marker) {
    markers.add(marker);
    marker.addPropertyChangeListener(this);
    Collections.sort(markers);
    int index = markers.indexOf(marker);
    if (listeners == null) {
        return;
    }
    TableModelEvent tme = new TableModelEvent(this, index, index, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
    for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
        TableModelListener listener = (TableModelListener) iter.next();
        listener.tableChanged(tme);
    }
    fireTableDataChanged();
}
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