Search in sources :

Example 36 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class MnemonicWrapper method getWrapper.

public static MnemonicWrapper getWrapper(Component component) {
    if (component == null || component.getClass().getName().equals("com.intellij.openapi.wm.impl.StripeButton")) {
        return null;
    }
    for (PropertyChangeListener listener : component.getPropertyChangeListeners()) {
        if (listener instanceof MnemonicWrapper) {
            MnemonicWrapper wrapper = (MnemonicWrapper) listener;
            // update mnemonics immediately
            wrapper.run();
            return wrapper;
        }
    }
    if (component instanceof JMenuItem) {
        // TODO: new MenuWrapper((JMenuItem)component);
        return null;
    }
    if (component instanceof AbstractButton) {
        return new ButtonWrapper((AbstractButton) component);
    }
    if (component instanceof JLabel) {
        return new LabelWrapper((JLabel) component);
    }
    return null;
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener)

Example 37 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project intellij-community by JetBrains.

the class TodoConfiguration method doSetTodoPatterns.

private void doSetTodoPatterns(@NotNull TodoPattern[] todoPatterns, final boolean shouldNotifyIndices) {
    TodoPattern[] oldTodoPatterns = myTodoPatterns;
    IndexPattern[] oldIndexPatterns = myIndexPatterns;
    myTodoPatterns = todoPatterns;
    buildIndexPatterns();
    // only trigger index refresh actual index patterns have changed
    if (shouldNotifyIndices && !Arrays.deepEquals(myIndexPatterns, oldIndexPatterns)) {
        PropertyChangeEvent event = new PropertyChangeEvent(this, IndexPatternProvider.PROP_INDEX_PATTERNS, oldTodoPatterns, todoPatterns);
        myMessageBus.syncPublisher(IndexPatternProvider.INDEX_PATTERNS_CHANGED).propertyChange(event);
    }
    // only trigger gui and code daemon refresh when either the index patterns or presentation attributes have changed
    if (!Arrays.deepEquals(myTodoPatterns, oldTodoPatterns)) {
        PropertyChangeListener multicaster = myPropertyChangeMulticaster.getMulticaster();
        multicaster.propertyChange(new PropertyChangeEvent(this, PROP_TODO_PATTERNS, oldTodoPatterns, todoPatterns));
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 38 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project JMRI by JMRI.

the class JmriJTablePersistenceManagerTest method testStopPersisting.

/**
     * Test of stopPersisting method, of class JmriJTablePersistenceManager.
     */
@Test
public void testStopPersisting() {
    JmriJTablePersistenceManagerSpy instance = new JmriJTablePersistenceManagerSpy();
    JTable table = testTable("test name");
    try {
        instance.persist(table);
    // passes
    } catch (NullPointerException ex) {
        Assert.fail("threw unexpected NPE");
    }
    int managers = 0;
    int tableListeners = 0;
    int columnListeners = 0;
    for (PropertyChangeListener listener : table.getPropertyChangeListeners()) {
        if (listener.equals(instance)) {
            managers++;
        }
        if (listener.equals(instance.getListener(table))) {
            tableListeners++;
        }
    }
    for (PropertyChangeListener listener : table.getColumn("c0").getPropertyChangeListeners()) {
        if (listener.equals(instance.getListener(table))) {
            columnListeners++;
        }
    }
    Assert.assertEquals(1, managers);
    Assert.assertEquals(1, tableListeners);
    Assert.assertEquals(1, columnListeners);
    try {
        instance.stopPersisting(table);
    // passes
    } catch (NullPointerException ex) {
        Assert.fail("threw unexpected NPE");
    }
    for (PropertyChangeListener listener : table.getColumn("c0").getPropertyChangeListeners()) {
        if (listener.equals(instance.getListener(table))) {
            columnListeners++;
        }
    }
    managers = 0;
    tableListeners = 0;
    columnListeners = 0;
    for (PropertyChangeListener listener : table.getPropertyChangeListeners()) {
        if (listener.equals(instance)) {
            managers++;
        }
        if (listener.equals(instance.getListener(table))) {
            tableListeners++;
        }
    }
    for (PropertyChangeListener listener : table.getColumn("c0").getPropertyChangeListeners()) {
        if (listener.equals(instance.getListener(table))) {
            columnListeners++;
        }
    }
    Assert.assertEquals(0, managers);
    Assert.assertEquals(0, tableListeners);
    Assert.assertEquals(0, columnListeners);
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) JTable(javax.swing.JTable) Test(org.junit.Test)

Example 39 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project JMRI by JMRI.

the class SpeedProfilePanel method notifyThrottleFound.

@Override
public void notifyThrottleFound(DccThrottle _throttle) {
    t = _throttle;
    if (t == null) {
        JOptionPane.showMessageDialog(null, Bundle.getMessage("ErrorThrottleNotFound"));
        log.warn("null throttle returned for train  " + re.getId() + " during automatic initialization.");
        setButtonStates(true);
        return;
    }
    if (log.isDebugEnabled()) {
        log.debug("throttle address= " + t.getLocoAddress().toString());
    }
    int speedStepMode = t.getSpeedStepMode();
    profileIncrement = t.getSpeedIncrement();
    //        int speedStep;
    if (speedStepMode == DccThrottle.SpeedStepMode14) {
        profileSpeedStepMode = 14;
    } else if (speedStepMode == DccThrottle.SpeedStepMode27) {
        profileSpeedStepMode = 27;
    } else if (speedStepMode == DccThrottle.SpeedStepMode28) {
        profileSpeedStepMode = 28;
    } else {
        // default to 128 speed step mode
        profileSpeedStepMode = 126;
    }
    if (finishSpeedStep <= 0) {
        finishSpeedStep = profileSpeedStepMode;
    }
    log.debug("Speed step mode " + profileSpeedStepMode);
    profileSpeed = profileIncrement * profileStep;
    if (profile) {
        startSensor = middleBlockSensor.getSensor();
        finishSensor = sensorB.getSensor();
        startListener = new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals("KnownState")) {
                    if (((Integer) e.getNewValue()) == Sensor.ACTIVE) {
                        startTiming();
                    }
                    if (((Integer) e.getNewValue()) == Sensor.INACTIVE) {
                        stopLoco();
                    }
                }
            }
        };
        finishListener = new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals("KnownState")) {
                    if (((Integer) e.getNewValue()) == Sensor.ACTIVE) {
                        stopCurrentSpeedStep();
                    }
                }
            }
        };
        isForward = true;
        startProfile();
    } else {
        if (re.getSpeedProfile() == null) {
            log.error("Loco has no speed profile");
            JOptionPane.showMessageDialog(null, Bundle.getMessage("ErrorNoSpeedProfile"));
            setButtonStates(true);
            return;
        }
        startSensor = middleBlockSensor.getSensor();
        startListener = new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals("KnownState")) {
                    if (((Integer) e.getNewValue()) == Sensor.ACTIVE) {
                        stopTrainTest();
                    }
                }
            }
        };
        startSensor.addPropertyChangeListener(startListener);
        int startstep = Integer.parseInt(speedStepTest.getText());
        isForward = true;
        t.setIsForward(isForward);
        try {
            Thread.sleep(250);
        } catch (InterruptedException e) {
        // Nthing I can do.      
        }
        profileSpeed = profileIncrement * startstep;
        t.setSpeedSetting(profileSpeed);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 40 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project JMRI by JMRI.

the class VSDControl method configButtonPressed.

/**
     * Handle "Config" button presses
     */
protected void configButtonPressed(ActionEvent e) {
    log.debug("(" + address + ") Config Button Pressed");
    VSDConfigDialog d = new VSDConfigDialog(this, Bundle.getMessage("ConfigDialogTitlePrefix") + " " + this.address, config);
    d.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            log.debug("property change name " + event.getPropertyName() + " old " + event.getOldValue() + " new " + event.getNewValue());
            configDialogPropertyChange(event);
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

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