Search in sources :

Example 96 with ChangeListener

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();
                }
            }
        });
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 97 with ChangeListener

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);
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 98 with ChangeListener

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;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 99 with ChangeListener

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);
}
Also used : AbstractButton(javax.swing.AbstractButton) ChangeListener(javax.swing.event.ChangeListener)

Example 100 with ChangeListener

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;
}
Also used : ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ChangeListener(javax.swing.event.ChangeListener) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Aggregations

ChangeListener (javax.swing.event.ChangeListener)218 ChangeEvent (javax.swing.event.ChangeEvent)205 JPanel (javax.swing.JPanel)54 ActionEvent (java.awt.event.ActionEvent)47 ActionListener (java.awt.event.ActionListener)46 JLabel (javax.swing.JLabel)34 Dimension (java.awt.Dimension)29 GridBagConstraints (java.awt.GridBagConstraints)27 GridBagLayout (java.awt.GridBagLayout)24 JCheckBox (javax.swing.JCheckBox)24 Insets (java.awt.Insets)21 JSlider (javax.swing.JSlider)20 PropertyChangeListener (java.beans.PropertyChangeListener)19 JButton (javax.swing.JButton)19 BorderLayout (java.awt.BorderLayout)17 PropertyChangeEvent (java.beans.PropertyChangeEvent)17 IOException (java.io.IOException)14 BoxLayout (javax.swing.BoxLayout)14 ButtonGroup (javax.swing.ButtonGroup)14 JSpinner (javax.swing.JSpinner)13