Search in sources :

Example 81 with PropertyChangeListener

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;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) TableView(org.knime.core.node.tableview.TableView)

Example 82 with PropertyChangeListener

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();
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) DataColumnSpec(org.knime.core.data.DataColumnSpec) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 83 with PropertyChangeListener

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);
}
Also used : DataTable(org.knime.core.data.DataTable) PropertyChangeEvent(java.beans.PropertyChangeEvent) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) PropertyChangeListener(java.beans.PropertyChangeListener) TableColumnModel(javax.swing.table.TableColumnModel)

Example 84 with PropertyChangeListener

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) Dimension(java.awt.Dimension)

Example 85 with PropertyChangeListener

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]);
}
Also used : RemoveElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent) AddElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.AddElementPropertyChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) RemoveElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent) Test(org.junit.Test)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)228 PropertyChangeEvent (java.beans.PropertyChangeEvent)197 ActionEvent (java.awt.event.ActionEvent)27 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)27 ActionListener (java.awt.event.ActionListener)26 IFigure (org.eclipse.draw2d.IFigure)25 JPanel (javax.swing.JPanel)21 ArrayList (java.util.ArrayList)16 JLabel (javax.swing.JLabel)13 BorderLayout (java.awt.BorderLayout)12 Dimension (java.awt.Dimension)12 JButton (javax.swing.JButton)12 BoxLayout (javax.swing.BoxLayout)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 File (java.io.File)9 Composite (org.eclipse.swt.widgets.Composite)9 Test (org.junit.Test)9 IOException (java.io.IOException)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8