Search in sources :

Example 91 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project knime-core by knime.

the class FixedWidthFRNodeDialog method createPreviewPanel.

/**
 * @return jpanel with all the preview components
 */
private JPanel createPreviewPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Preview"));
    Box tableBox = Box.createHorizontalBox();
    PreviewTableContentView ptcv = new PreviewTableContentView();
    m_previewTableView = new TableView(ptcv);
    tableBox.add(m_previewTableView);
    panel.add(Box.createGlue());
    panel.add(tableBox);
    ptcv.addPropertyChangeListener(PreviewTableContentView.PROPERTY_SPEC_CHANGED, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            m_colIdx = (int) evt.getNewValue();
            m_colIdx = m_nodeSettings.getColIdxIncluded(m_colIdx);
            if (m_colIdx < m_nodeSettings.getNumberOfColumns() - 1) {
                // don't open edit dialog if clicked column equals
                // remaining characters column
                onEdit(m_colIdx);
            }
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) PreviewTableContentView(org.knime.base.node.io.filereader.PreviewTableContentView) TableView(org.knime.core.node.tableview.TableView)

Example 92 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project knime-core by knime.

the class ParallelCoordinatesViewPanel method createViewTypeMenu.

/**
 * @return - a JMenu entry handling the view type.
 */
public JMenu createViewTypeMenu() {
    JMenu menu = new JMenu("View Type");
    menu.setMnemonic('V');
    ActionListener actL = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            if (e.getActionCommand().equals(POPUP_ALL_VISIBLE)) {
                // set view to ALL VISIBLE
                setViewType(ALL_VISIBLE);
                ((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_ALL_VISIBLE, false, true);
                repaint();
            } else if (e.getActionCommand().equals(POPUP_HIDE_UNHILITED)) {
                // set view to HIDE_UNHILITED
                setViewType(HIDE_UNHILITED);
                unselectUnhilited();
                ((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_HIDE_UNHILITED, false, true);
                repaint();
            } else if (e.getActionCommand().equals(POPUP_FADE_UNHILITED)) {
                // set view to FADE_UNHILITED
                setViewType(FADE_UNHILITED);
                unselectUnhilited();
                ((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_FADE_UNHILITED, false, true);
                repaint();
            }
        }
    };
    ButtonGroup group = new ButtonGroup();
    // JMenuItem item
    JMenuItem item = new JRadioButtonMenuItem(POPUP_ALL_VISIBLE);
    item.setSelected(m_viewType == ALL_VISIBLE);
    item.addActionListener(actL);
    item.setMnemonic('A');
    item.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(final PropertyChangeEvent e) {
            ((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == ALL_VISIBLE);
        }
    });
    group.add(item);
    menu.add(item);
    item = new JRadioButtonMenuItem(POPUP_HIDE_UNHILITED);
    item.setSelected(m_viewType == HIDE_UNHILITED);
    item.addActionListener(actL);
    item.setMnemonic('H');
    item.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(final PropertyChangeEvent e) {
            ((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == HIDE_UNHILITED);
        }
    });
    group.add(item);
    menu.add(item);
    item = new JRadioButtonMenuItem(POPUP_FADE_UNHILITED);
    item.setSelected(m_viewType == FADE_UNHILITED);
    item.addActionListener(actL);
    item.setMnemonic('F');
    item.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(final PropertyChangeEvent e) {
            ((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == FADE_UNHILITED);
        }
    });
    group.add(item);
    menu.add(item);
    return menu;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 93 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project vcell by virtualcell.

the class VCDocumentDbTreePanel method initialize.

/**
 * Initialize the class.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
protected void initialize() {
    try {
        initializeNotCalled = false;
        // user code begin {1}
        // user code end
        setName("BioModelTreePanel");
        setLayout(new BorderLayout());
        getDatabaseSearchPanel().addActionListener(ivjEventHandler);
        getDatabaseSearchPanel().addCollapsiblePropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getSource() == getDatabaseSearchPanel() && evt.getPropertyName().equals(CollapsiblePanel.SEARCHPPANEL_EXPANDED)) {
                    boolean bSearchPanelExpanded = (Boolean) evt.getNewValue();
                    if (!bSearchPanelExpanded) {
                        search(true);
                    }
                }
            }
        });
        treeCellRenderer = createTreeCellRenderer();
        treeModel = createTreeModel();
        getJTree1().setModel(getTreeModel());
        getJTree1().setCellRenderer(treeCellRenderer);
        getTreeModel().addTreeModelListener(ivjEventHandler);
        getJTree1().getSelectionModel().addTreeSelectionListener(ivjEventHandler);
        getJTree1().addMouseListener(ivjEventHandler);
        add(getDatabaseSearchPanel(), BorderLayout.NORTH);
        JComponent topPanel = new JScrollPane(getJTree1());
        JComponent centerPanel = topPanel;
        if (bShowMetadata) {
            JSplitPane splitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.VERTICAL_SPLIT);
            splitPane.setDividerLocation(150);
            splitPane.setResizeWeight(0.7);
            getBottomPanel().setMinimumSize(new Dimension(150, 150));
            topPanel.setMinimumSize(new Dimension(150, 150));
            splitPane.setTopComponent(topPanel);
            splitPane.setBottomComponent(getBottomPanel());
            centerPanel = splitPane;
        }
        add(centerPanel, BorderLayout.CENTER);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) PropertyChangeEvent(java.beans.PropertyChangeEvent) BorderLayout(java.awt.BorderLayout) PropertyChangeListener(java.beans.PropertyChangeListener) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane)

Example 94 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project vcell by virtualcell.

the class PropertyChangeListenerProxyVCell method addProxyListener.

public static void addProxyListener(PropertyChangeSupport pcs, PropertyChangeListener listener) {
    if (listener instanceof PropertyChangeListenerProxyVCell) {
        throw new IllegalArgumentException("listener already proxy");
    }
    PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
    for (PropertyChangeListener pcl : listeners) {
        if (pcl == listener || (pcl instanceof PropertyChangeListenerProxyVCell && ((PropertyChangeListenerProxyVCell) pcl).listener == listener)) {
            throw new IllegalArgumentException("duplicate listener " + listener);
        }
    }
    pcs.addPropertyChangeListener(new PropertyChangeListenerProxyVCell(listener));
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener)

Example 95 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project drools by kiegroup.

the class PropertyListenerTest method runTest.

@Test
public void runTest() {
    final KieServices kieServices = KieServices.Factory.get();
    final Resource drlResource = kieServices.getResources().newClassPathResource("propertyListenerTest.drl", getClass());
    final KieBase kieBase = KieBaseUtil.getKieBaseAndBuildInstallModule(TestConstants.PACKAGE_REGRESSION, kieBaseTestConfiguration, drlResource);
    final KieSession session = kieBase.newKieSession();
    final ArrayList<Person> people = new ArrayList<Person>();
    people.add(new Person("Test 1"));
    people.add(new Person("Test 2"));
    LOGGER.info("== Listeners attached before rules ==");
    for (Person person : people) {
        for (PropertyChangeListener listener : person.getBoundSupport().getPropertyChangeListeners()) {
            LOGGER.info("Listener attached of type: " + listener);
        }
    }
    // call rules
    final List<Command<?>> commands = new ArrayList<Command<?>>();
    commands.add(kieServices.getCommands().newInsert(people));
    commands.add(kieServices.getCommands().newFireAllRules());
    session.execute(kieServices.getCommands().newBatchExecution(commands, null));
    session.dispose();
    LOGGER.info("Session disposed");
    LOGGER.info("== Listeners attached after rules (should be none) ==");
    printAndAssertListenersFromPeople(people);
    // update name to trigger update
    people.get(0).setName("Test 3");
    LOGGER.info("== Listeners attached after updating name (should be none) ==");
    printAndAssertListenersFromPeople(people);
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) Command(org.kie.api.command.Command) KieBase(org.kie.api.KieBase) Resource(org.kie.api.io.Resource) ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) KieSession(org.kie.api.runtime.KieSession) 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