use of java.beans.PropertyChangeListener in project knime-core by knime.
the class VariableFileReaderNodeDialog method createPreviewPanel.
private JPanel createPreviewPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Preview"));
Box hintBox = Box.createHorizontalBox();
Box tableBox = Box.createHorizontalBox();
hintBox.add(Box.createGlue());
hintBox.add(new JLabel("Click column header to change " + "column properties (* = name/type user settings)"));
hintBox.add(Box.createGlue());
PreviewTableContentView ptcv = new PreviewTableContentView();
m_previewTableView = new TableView(ptcv);
tableBox.add(m_previewTableView);
// add the analyzer warning at the bottom
m_analyzeWarn = new JLabel("");
m_analyzeWarn.setForeground(Color.red);
JPanel analBox = new JPanel();
analBox.setLayout(new BoxLayout(analBox, BoxLayout.X_AXIS));
analBox.add(Box.createHorizontalGlue());
analBox.add(m_analyzeWarn);
// reserve a certain height for the (in the beginning invisible) label
analBox.add(Box.createVerticalStrut(25));
analBox.add(Box.createHorizontalGlue());
panel.add(Box.createGlue());
panel.add(hintBox);
panel.add(Box.createVerticalStrut(10));
panel.add(tableBox);
panel.add(analBox);
panel.add(Box.createGlue());
// this is the callback for the preview table header click
ptcv.addPropertyChangeListener(PreviewTableContentView.PROPERTY_SPEC_CHANGED, new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
// thats the col idx the mouse was clicked on
Integer colNr = (Integer) evt.getNewValue();
setNewUserSettingsForColumn(colNr.intValue());
}
});
return panel;
}
use of java.beans.PropertyChangeListener in project knime-core by knime.
the class MissingValueHandling2NodeDialogPane method addToIndividualPanel.
private void addToIndividualPanel(final MissingValueHandling2Panel panel) {
panel.addPropertyChangeListener(MissingValueHandling2Panel.REMOVE_ACTION, new PropertyChangeListener() {
/**
* {@inheritDoc}
*/
@Override
public void propertyChange(final PropertyChangeEvent evt) {
removeFromIndividualPanel((MissingValueHandling2Panel) evt.getSource());
}
});
panel.addPropertyChangeListener(MissingValueHandling2Panel.REMOVED_INVALID_COLUMNS, new PropertyChangeListener() {
/**
* {@inheritDoc}
*/
@Override
public void propertyChange(final PropertyChangeEvent evt) {
DataColumnSpec[] removedSpecs = (DataColumnSpec[]) evt.getNewValue();
if (removedSpecs != null) {
for (DataColumnSpec spec : removedSpecs) {
if (m_searchableListPanel.isAdditionalColumn(spec.getName())) {
m_searchableListModifier.removeAdditionalColumn(spec.getName());
}
}
}
checkButtonStatus();
m_searchableListPanel.repaint();
}
});
m_individualsPanel.add(panel);
m_individualsPanel.revalidate();
// // force the outer parent to render out first individual if there does none exist previously
// getPanel().repaint();
}
use of java.beans.PropertyChangeListener in project knime-core by knime.
the class TableContentView method setModel.
// TableContentView(DataTable)
/**
* Checks that the given argument is of type {@link TableContentModel}
* and throws exception if it is not. Otherwise it sets the new model and
* updates the table.
*
* @param tableModel the new model, necessarily of type
* {@link TableContentModel}
* @see javax.swing.JTable#setModel(javax.swing.table.TableModel)
* @throws ClassCastException if dataModel not of type
* {@link TableContentModel}
* @throws IllegalArgumentException if <code>dataModel</code> is
* <code>null</code> as done by
* <code>JTable.setModel(TableModel)</code>
*/
@Override
public void setModel(final TableModel tableModel) {
TableContentModel tblModel = (TableContentModel) tableModel;
if (m_dataListener == null) {
// may be null when in <init>
m_dataListener = new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
String id = evt.getPropertyName();
if (!id.equals(TableContentModel.PROPERTY_DATA)) {
return;
}
TableColumnModel tcM = getColumnModel();
if (hasData()) {
DataTable data = getContentModel().getDataTable();
DataTableSpec spec = data.getDataTableSpec();
for (int i = 0; i < tcM.getColumnCount(); i++) {
int colInModel = convertColumnIndexToModel(i);
DataColumnSpec headerValue = spec.getColumnSpec(colInModel);
tcM.getColumn(i).setHeaderValue(headerValue);
}
}
// repaint sort icon
getTableHeader().revalidate();
// property data update to row header view
// (only sort icon - data update done via TableModelEvent)
firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
}
};
} else {
getContentModel().removePropertyChangeListener(m_dataListener);
}
tblModel.addPropertyChangeListener(m_dataListener);
super.setModel(tblModel);
}
use of java.beans.PropertyChangeListener in project knime-core by knime.
the class TableRowHeaderView method addColumn.
// TableRowHeaderView
/**
* Makes sure to register a property handler and sets the correct
* cell renderer.
* {@inheritDoc}
*/
@Override
public void addColumn(final TableColumn aColumn) {
super.addColumn(aColumn);
aColumn.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("width")) {
int newWidth = (Integer) evt.getNewValue();
// and catch requests to set it to this minimum.
if (newWidth == aColumn.getMinWidth()) {
return;
}
Dimension newSize = new Dimension(newWidth, 0);
setPreferredScrollableViewportSize(newSize);
}
}
});
// set renderer for table (similar to column header renderer)
// do not call the method setRenderer because it might be overridden
DataCellHeaderRenderer renderer = DataCellHeaderRenderer.newInstance();
renderer.showIcon(m_isShowColorInfo);
aColumn.setCellRenderer(renderer);
assert (getColumnCount() == 1);
}
use of java.beans.PropertyChangeListener in project eclipse-pmd by acanda.
the class WorkspaceModelTest method removeFiresARemoveElementPropertyChangeEvent.
/**
* Verifies that an event is fired when removing a project model.
*/
@Test
public void removeFiresARemoveElementPropertyChangeEvent() {
final WorkspaceModel model = new WorkspaceModel();
final boolean[] eventFired = new boolean[1];
final ProjectModel element = new ProjectModel("Foo");
model.add(element);
model.addPropertyChangeListener(WorkspaceModel.PROJECTS_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
eventFired[0] = true;
assertTrue("The event should be an RemoveElementPropertyChangeEvent", event instanceof RemoveElementPropertyChangeEvent);
assertSame("Event's added element", element, ((RemoveElementPropertyChangeEvent) event).getRemovedElement());
assertSame("Event's old value should be the removed element", element, event.getOldValue());
assertNull("Event's new value should be null", event.getNewValue());
}
});
model.remove(element.getProjectName());
assertTrue("An event should be fired when removing a project model", eventFired[0]);
}
Aggregations