
/**
 * ConversionPlugin.java
 * Used to perform different kinds of scientific conversions
 *
 * Created: September 19, 2005
 *
 * @author Nathan Stevens
 * @version 0.11 4/14/06
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.File;

public class ConversionPlugin extends JFrame implements ActionListener,
        InstruViewPlugin {

    private static final String VERSION = "0.11 (4-14-05)";
    private InstruView instruView = null;
    private String name = "Conversion";

    public ConversionPlugin() {
    }

    public ConversionPlugin(InstruView instruView) {
        super("Conversion v- " + VERSION);

        // exist the program
        addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent we) {
                close();
            }
        });

        // Set the layout to border layout
        getContentPane().setLayout(new BorderLayout());

        /* add the different conversion panes now */
        JTabbedPane tabbPane = new JTabbedPane();
        //tabPane.addChangeListener(this);

        // Add the wavelength conversion panel
        JPanel wavelengthConversionPanel = new WavelengthConversionPanel(this);
        tabbPane.addTab("Wavelength", null, wavelengthConversionPanel,
                "Wavelength Conversion Panel"); //tooltip text


        getContentPane().add(tabbPane, "Center");

        // add the button panel now
        JPanel southPanel = new JPanel();
        southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));

        JButton button;

        southPanel.add(Box.createHorizontalGlue());

        button = new JButton("Close");
        button.setActionCommand("close");
        button.addActionListener(this);
        button.setToolTipText("Close this window");
        southPanel.add(button);

        getContentPane().add(southPanel, "South");

        // set the size and display the window at long last
        //setSize(500, 300);
        pack();
        setVisible(true);
    }

    // Method to handel action events
    public void actionPerformed(ActionEvent ae) {
        String cmd = ae.getActionCommand();

        if (cmd.equals("")) {
            //code;
        } else if (cmd.equals("")) {
            //code
        } else if (cmd.equals("close")) {
            close();
        } else {
            System.err.println("Action Command not handeled in class ConversionPlugin...");
            System.err.println(cmd);
        }
    }

    // Method to close this dialog
    private void close() {
        setVisible(false);
        dispose();
    }

    // Method to return information about this plugin
    public String[] getPluginInformation() {
        String[] information = {"Author : Nathan Stevens",
            "Version : " + VERSION,
            "",
            "A plugin for converting this to that"};

        return information;
    }

    // Method to add a single spectra data. not used
    public void addSpectraData(SpectraData sd) {
    }

    // Method to set any spectra data. not used
    public void addSpectraData(SpectraData[] sda) {
    }

    // Method to load an sdl file. not used
    public void loadSDL(ExperimentData experimentData, File file) {
    }

    // Method to load an sdl file. not used
    public void loadSDL(ExperimentData experimentData) {
    }

    // Method to print any messages
    public void print(String message) {
        System.out.println(message);
    }

    // the static class for putting it self into the class
    static class ConversionFactory extends PluginFactory {

        public InstruViewPlugin create(InstruView instruView) {
            return (new ConversionPlugin(instruView));
        }

        // get the experiment type
        public String getExperimentType() {
            return "none";
        }

        // get information about this plugin
        public String[] getPluginInformation() {
            String[] information = {"Author : Nathan Stevens",
                "Version : " + VERSION,
                "",
                "A plugin for converting this to that..."};

            return information;
        }
    }// -- end inner static class ConversionFactory
    // add this factory to the InstruviewPluginLoader factory hashtable


    static {
        InstruViewPluginLoader.pluginFactories.put("Conversion", new ConversionFactory());
    }
} //--end class conversion plugin
