
package org.openspml.browser;

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// avoid awt conflict
import java.util.List;

import org.openspml.util.*;
import org.openspml.message.*;

/**
 * Base class of an "installer" that is responsible for assimilating
 * an SpmlResult into the GUI after a response is received.
 * Requests are normally performed in their own thread by 
 * State.doRequset.  A seperate installer Runnable is necessary so that
 * the operations it performs will be done in Swing event thread.
 * 
 * Subclass this and implement the install() method.
 */
public abstract class Installer implements Runnable {

    SpmlResponse _response;

    public Installer() {
    }

    /**
     * Called by State.Executor after the response has been recveived.
     */
    public void setResponse(SpmlResponse r) {
        _response = r;
    }

    public void run() {
        try {
            install(_response);
        }
        catch (Throwable t) {
            SwingUtil.displayError(t);
        }
    }

    public abstract void install(SpmlResponse r);

}
