package org.helioviewer.plugins.eveplugin.radio.gui;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.helioviewer.jhv.gui.filters.lut.LUT;
import org.helioviewer.plugins.eveplugin.radio.model.ColorLookupModel;

public class RadioOptionsPanel extends JPanel implements ActionListener {

    private JComboBox lut;
    private JLabel color;

    private final Map<String, LUT> lutMap;

    public RadioOptionsPanel() {
        super();
        lutMap = LUT.getStandardList();
        initVisualComponents();
    }

    private void initVisualComponents() {
        setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

        color = new JLabel("Color", JLabel.RIGHT);
        lut = new JComboBox(lutMap.keySet().toArray());
        lut.setSelectedItem("Rainbow 2");
        lut.addActionListener(this);

        add(color);
        add(lut);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        ColorLookupModel.getInstance().setLUT(LUT.getStandardList().get((lut.getSelectedItem())));
    }

    /**
     * Adds a color table to the available list and set it active
     *
     * @param lut
     *            Color table to add
     */
    public void addLut(LUT newLut) {
        if (lutMap.put(newLut.getName(), newLut) == null) {
            lut.addItem(newLut.getName());
        }
        lut.setSelectedItem(newLut.getName());
        ColorLookupModel.getInstance().setLUT(newLut);
    }

}

@@ -205,35 +205,8 @@
 ox;%0A
-import javax.swing.JLabel;%0A
 impo
@@ -228,16 +228,16 @@
 JPanel;%0A
+
 %0Aimport 
@@ -454,34 +454,8 @@
 lut;
-%0A    private JLabel color;
 %0A%0A  
@@ -730,59 +730,8 @@
 );%0A%0A
-        color = new JLabel(%22Color%22, JLabel.RIGHT);%0A
     
@@ -866,28 +866,8 @@
 );%0A%0A
-        add(color);%0A
     

remove color label