package org.helioviewer.plugins.eveplugin.view;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

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

import org.helioviewer.jhv.internal_plugins.filter.SOHOLUTFilterPlugin.LUT;
import org.helioviewer.plugins.eveplugin.radio.filter.FilterModel;

public class RadioOptionsPanel extends JPanel implements ActionListener {

    private JComboBox lut;
    private JLabel color;

    public RadioOptionsPanel() {
        super();
        initVisualComponents();
    }

    private void initVisualComponents() {

        setLayout(new BorderLayout());

        lut = new JComboBox(LUT.getStandardList().keySet().toArray());
        lut.addActionListener(this);
        color = new JLabel("Color:");

        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createTitledBorder("Radio Options"));
        panel.setLayout(new GridBagLayout());

        GridBagConstraints gc = new GridBagConstraints();
        gc.gridx = 0;
        gc.gridy = 0;

        panel.add(color, gc);

        gc.gridx = 1;
        gc.weightx = 1;
        panel.add(lut, gc);

        add(panel, BorderLayout.CENTER);
    }

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

}

@@ -211,16 +211,66 @@
 istener;
+%0Aimport java.io.IOException;%0Aimport java.util.Map;
 %0A%0Aimport
@@ -327,16 +327,49 @@
 mboBox;%0A
+import javax.swing.JFileChooser;%0A
 import j
@@ -415,16 +415,270 @@
 Panel;%0A%0A
+import org.helioviewer.base.logging.Log;%0Aimport org.helioviewer.base.message.Message;%0Aimport org.helioviewer.jhv.internal_plugins.filter.SOHOLUTFilterPlugin.GGRFilter;%0Aimport org.helioviewer.jhv.internal_plugins.filter.SOHOLUTFilterPlugin.GradientError;%0A
 import o
@@ -940,16 +940,95 @@
 l color;
+%0A    private int lastSelectedIndex;%0A%0A    private final Map%3CString, LUT%3E lutMap;
 %0A%0A    pu
@@ -1067,24 +1067,64 @@
    super();%0A
+        lutMap = LUT.getStandardList();%0A
         init
@@ -1261,37 +1261,22 @@
 omboBox(
-LUT.getStandardList()
+lutMap
 .keySet(
@@ -1285,24 +1285,118 @@
 toArray());%0A
+        lut.setSelectedItem(%22Rainbow 2%22);%0A        lastSelectedIndex = lut.getSelectedIndex();%0A
         lut.
@@ -1951,91 +1951,1906 @@
     
-FilterModel.getInstance().setLUT(LUT.getStandardList().get((lut.getSelectedItem()))
+LUT newMap = lutMap.get(lut.getSelectedItem());%0A        if (newMap == null) %7B%0A            // Add new color table%0A            JFileChooser fc = new JFileChooser();%0A            fc.setFileFilter(new GGRFilter());%0A            fc.setMultiSelectionEnabled(false);%0A            int state = fc.showOpenDialog(null);%0A            if (state == JFileChooser.APPROVE_OPTION) %7B%0A                try %7B%0A                    Log.info(%22Load gradient file %22 + fc.getSelectedFile());%0A                    addLut(LUT.readGimpGradientFile(fc.getSelectedFile()));%0A                    lastSelectedIndex = lut.getSelectedIndex();%0A                %7D catch (IOException ex) %7B%0A                    Message.warn(%22Error loading gradient file%22, %22Error loading gradient file: %22 + fc.getSelectedFile() + %22%5Cn%5Cn%22 + ex.getMessage());%0A                    Log.warn(%22Error loading gradient file: %22 + fc.getSelectedFile() + %22 - %22 + ex.getMessage());%0A                %7D catch (GradientError ex) %7B%0A                    Message.warn(%22Error applying gradient file%22, %22Error loading gradient file: %22 + fc.getSelectedFile() + %22%5Cn%5Cn%22 + ex.getMessage());%0A                    Log.warn(%22Error applying gradient file: %22 + fc.getSelectedFile() + %22 - %22 + ex.getMessage());%0A                %7D%0A            %7D else %7B%0A                lut.setSelectedIndex(lastSelectedIndex);%0A            %7D%0A        %7D else %7B%0A            FilterModel.getInstance().setLUT(LUT.getStandardList().get((lut.getSelectedItem())));%0A            lastSelectedIndex = lut.getSelectedIndex();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Adds a color table to the available list and set it active%0A     * %0A     * @param lut%0A     *            Color table to add%0A     */%0A    public void addLut(LUT newLut) %7B%0A        if (lutMap.put(newLut.getName(), newLut) == null) %7B%0A            lut.addItem(newLut.getName());%0A        %7D%0A        lut.setSelectedItem(newLut.getName());%0A        FilterModel.getInstance().setLUT(newLut
 );%0A 

Set default lut + functionality to load lut