use of javax.swing.event.ChangeListener in project knime-core by knime.
the class NodeDialogPane method addFlowVariablesTab.
/**
* Add the flow variables tab. Override to disable this tab.
*/
protected void addFlowVariablesTab() {
if (getTab(TAB_NAME_VARIABLES) == null) {
addTab(TAB_NAME_VARIABLES, m_flowVariableTab);
m_pane.addChangeListener(new ChangeListener() {
/**
* {@inheritDoc}
*/
@Override
public void stateChanged(final ChangeEvent e) {
if (m_pane.getSelectedIndex() == getTabIndex(TAB_NAME_VARIABLES)) {
updateFlowVariablesTab();
}
}
});
}
}
use of javax.swing.event.ChangeListener in project knime-core by knime.
the class AttributeSelectionPanel method newTargetSelected.
/**
* @param item
*/
private void newTargetSelected(final DataColumnSpec item) {
String col = m_targetColumnBox.getSelectedColumn();
if (m_lastTableSpec == null || col == null) {
return;
}
DataTableSpec filtered = getCurrentAttributeSpec();
Set<String> prevIn = m_includeColumnsFilterPanel.getIncludedColumnSet();
m_includeColumnsFilterPanel.update(filtered, false, prevIn);
ChangeEvent e = new ChangeEvent(this);
for (ChangeListener l : m_changeListenerList) {
l.stateChanged(e);
}
}
use of javax.swing.event.ChangeListener in project knime-core by knime.
the class CrosstabNodeView method createControlsPanel.
private JPanel createControlsPanel() {
JPanel p = new JPanel(new GridBagLayout());
p.setBackground(Color.white);
GridBagConstraints c = createGridBagConstraints();
c.insets = new Insets(8, 3, 3, 3);
m_propsPanel = new JPanel(new GridBagLayout());
m_propsPanel.setBackground(Color.white);
p.add(m_propsPanel, c);
c.insets = new Insets(3, 3, 3, 3);
c.gridy++;
p.add(new JLabel("Max rows:"), c);
c.gridy++;
m_maxRows = new SpinnerNumberModel(DEFAULT_MAX_ROWS, 1, 10000, 1);
m_maxRows.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
reCreateCrosstabulation();
}
});
p.add(new JSpinner(m_maxRows), c);
c.insets = new Insets(8, 3, 3, 3);
c.gridy++;
c.gridx = 0;
p.add(new JLabel("Max columns:"), c);
c.gridy++;
c.insets = new Insets(3, 3, 3, 3);
m_maxCols = new SpinnerNumberModel(DEFAULT_MAX_COLS, 1, 10000, 1);
m_maxCols.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
reCreateCrosstabulation();
}
});
p.add(new JSpinner(m_maxCols), c);
c.gridy++;
c.weighty = 1;
JPanel foo = new JPanel();
foo.setBackground(Color.white);
p.add(foo, c);
return p;
}
use of javax.swing.event.ChangeListener in project knime-core by knime.
the class AbstractHistogramProperties method updateHistogramSettings.
/**
* Updates the available slider with the current values of the Histogram
* plotter.
*
* @param vizModel the {@link AbstractHistogramVizModel} object which
* contains the data
*/
public void updateHistogramSettings(final AbstractHistogramVizModel vizModel) {
if (vizModel == null) {
return;
}
// update the bin settings tab components
// update the number of bin values
final int maxNoOfBins = vizModel.getMaxNoOfBins();
final int currentNoOfBins = vizModel.getNoOfBins();
m_noOfBinsModel.setMaximum(maxNoOfBins);
m_noOfBins.setValue(Integer.valueOf(currentNoOfBins));
m_noOfBinsLabel.setText(Integer.toString(currentNoOfBins));
// disable this noOfbins component for nominal values
if (vizModel.isBinNominal() || !vizModel.supportsHiliting()) {
m_noOfBins.setEnabled(false);
if (!vizModel.supportsHiliting()) {
m_noOfBins.setToolTipText("Not available for this histogram implementation");
} else {
m_noOfBins.setToolTipText("Only available for numerical properties");
}
} else {
m_noOfBins.setEnabled(true);
m_noOfBins.setToolTipText(AbstractHistogramProperties.NO_OF_BINS_TOOLTIP);
}
// show empty bins box
updateCheckBox(m_showEmptyBins, vizModel.isShowEmptyBins(), vizModel.containsEmptyBins());
// show missing value bin box
updateCheckBox(m_showMissingValBin, vizModel.isShowMissingValBin(), vizModel.containsMissingValueBin());
updateCheckBox(m_showInvalidValBin, vizModel.isShowInvalidValBin(), vizModel.containsInvalidValueBin());
// update the aggregation settings tab
// set the right aggregation method settings
// since the set selected method doesn't trigger an event
// we don't need to remove/add the action listener
final Collection<? extends ColorColumn> aggrColumns = vizModel.getAggrColumns();
if ((aggrColumns == null || aggrColumns.size() < 1) && !vizModel.supportsHiliting()) {
// aggregation methods but not count
for (final Enumeration<AbstractButton> buttons = m_aggrMethButtonGrp.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
if (!button.getActionCommand().equals(AggregationMethod.COUNT.name())) {
button.setEnabled(false);
button.setToolTipText(AGGR_METHOD_DISABLED_TOOLTIP);
}
// select the current aggregation method
if (button.getActionCommand().equals(vizModel.getAggregationMethod().name())) {
button.setSelected(true);
}
}
} else {
// enable all buttons
for (final Enumeration<AbstractButton> buttons = m_aggrMethButtonGrp.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
button.setEnabled(true);
// remove the tool tip
button.setToolTipText(null);
// select the current aggregation method
if (button.getActionCommand().equals(vizModel.getAggregationMethod().name())) {
button.setSelected(true);
}
}
}
// update the visualization settings tab
// show grid lines
updateCheckBox(m_showGrid, vizModel.isShowGridLines(), true);
// we don't need to remove/add the action listener
for (final Enumeration<AbstractButton> buttons = m_labelDisplayPolicy.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
if (button.getActionCommand().equals(vizModel.getLabelDisplayPolicy().getActionCommand())) {
button.setSelected(true);
}
}
// we don't need to remove/add the action listener
for (final Enumeration<AbstractButton> buttons = m_labelOrientation.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
if (button.getActionCommand().equals(LABEL_ORIENTATION_VERTICAL) && vizModel.isShowLabelVertical()) {
button.setSelected(true);
} else if (button.getActionCommand().equals(LABEL_ORIENTATION_HORIZONTAL) && !vizModel.isShowLabelVertical()) {
button.setSelected(true);
}
// disable the label orientation buttons if node label should be displayed
button.setEnabled(!LabelDisplayPolicy.NONE.equals(vizModel.getLabelDisplayPolicy()));
}
// we don't need to remove/add the action listener
for (final Enumeration<AbstractButton> buttons = m_layoutDisplayPolicy.getElements(); buttons.hasMoreElements(); ) {
final AbstractButton button = buttons.nextElement();
if (button.getActionCommand().equals(vizModel.getHistogramLayout().getActionCommand())) {
button.setSelected(true);
}
}
final int currentBinWidth = vizModel.getBinWidth();
final int maxBinWidth = vizModel.getMaxBinWidth();
int minBinWidth = AbstractHistogramVizModel.MIN_BIN_WIDTH;
if (minBinWidth > maxBinWidth) {
minBinWidth = maxBinWidth;
}
// update the bin width values
final ChangeListener[] widthListeners = m_binWidth.getChangeListeners();
for (final ChangeListener listener : widthListeners) {
m_binWidth.removeChangeListener(listener);
}
m_binWidth.setMaximum(maxBinWidth);
m_binWidth.setMinimum(minBinWidth);
m_binWidth.setValue(currentBinWidth);
m_binWidth.setEnabled(true);
m_binWidth.setToolTipText(AbstractHistogramProperties.BIN_WIDTH_TOOLTIP);
GUIUtils.setSliderLabels(m_binWidth, 2, false);
for (final ChangeListener listener : widthListeners) {
m_binWidth.addChangeListener(listener);
}
// show bin outline
updateCheckBox(m_showBinOutline, vizModel.isShowBinOutline(), true);
// show bar outline
updateCheckBox(m_showBarOutline, vizModel.isShowBarOutline(), true);
// show element outline
updateCheckBox(m_showElementOutline, vizModel.isShowElementOutline(), true);
}
use of javax.swing.event.ChangeListener in project knime-core by knime.
the class ColorLegendTab method createChangeColorButton.
/**
* Creates a button which opens a color chooser with the current color
* preselected, updates the color mapping and informs the listeners.
*
* @param colName column name
* @param currColor current color
* @return a button with the above described functionality
*/
private JButton createChangeColorButton(final String colName, final Color currColor) {
JButton btn = new JButton("Change...");
final JColorChooser chooser = new JColorChooser(currColor);
final ActionListener okListener = new ActionListener() {
/**
* {@inheritDoc}
*/
public void actionPerformed(final ActionEvent arg0) {
// set the new color in the mapping
m_mapping.put(colName, chooser.getColor());
// update the legend
update(m_mapping);
// inform the listener about a change
for (ChangeListener listener : m_listener) {
listener.stateChanged(new ChangeEvent(this));
}
}
};
btn.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
public void actionPerformed(final ActionEvent e) {
JDialog dialog = JColorChooser.createDialog(ColorLegendTab.this, "Select new color", true, chooser, okListener, null);
dialog.setVisible(true);
}
});
return btn;
}
Aggregations