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;
}
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);
}
};
}
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);
}
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);
}
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();
}
Aggregations