All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.odell.glazedlists.impl.swing.SwingThreadProxyCalculation Maven / Gradle / Ivy

The newest version!
/* Glazed Lists                                                 (c) 2003-2010 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.impl.swing;

import ca.odell.glazedlists.calculation.Calculation;
import ca.odell.glazedlists.impl.gui.ThreadProxyCalculation;

import java.awt.EventQueue;

/**
 * {@link Calculation} that proxies all change events from the wrapped source calculation to the
 * Swing event dispatch thread.
 *
 * @author Holger Brands
 */
public class SwingThreadProxyCalculation extends ThreadProxyCalculation {

    /**
     * Create a {@link SwingThreadProxyCalculation} which delivers changes to the given
     * source on the Swing event dispatch thread.
     *
     * @param source the {@link Calculation} for which to proxy events
     */
    public SwingThreadProxyCalculation(Calculation source) {
        super(source);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void schedule(Runnable runnable) {
        if(EventQueue.isDispatchThread()) {
            runnable.run();
        } else {
            EventQueue.invokeLater(runnable);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy