package org.helioviewer.jhv.gui.dialogs.plugins;

import java.awt.Color;
import java.util.TreeMap;

import javax.swing.BoxLayout;
import javax.swing.JList;
import javax.swing.JPanel;

import org.helioviewer.jhv.base.plugin.controller.PluginContainer;
import org.helioviewer.jhv.base.plugin.controller.PluginManager;

@SuppressWarnings("serial")
class PluginsList extends JPanel {

    private static final Color selectionBackgroundColor = new JList<JPanel>().getSelectionBackground();
    private static final Color selectionForegroundColor = new JList<JPanel>().getSelectionForeground();
    private static final Color backgroundColor = new JList<JPanel>().getBackground();
    private static final Color foregroundColor = new JList<JPanel>().getForeground();

    private final TreeMap<String, PluginsListEntry> entryMap = new TreeMap<>();

    public PluginsList() {
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

        PluginContainer[] pluginArray = PluginManager.getSingletonInstance().getAllPlugins();
        for (PluginContainer plugin : pluginArray) {
            PluginsListEntry entry = new PluginsListEntry(plugin, this);
            entryMap.put(plugin.getName(), entry);
            add(entry);
        }
        if (pluginArray.length != 0) {
            selectItem(pluginArray[0].getName());
        }
    }

    void selectItem(String name) {
        // deselect all
        for (PluginsListEntry entry : entryMap.values()) {
            entry.setForeground(foregroundColor);
            entry.setBackground(backgroundColor);
        }

        if (entryMap.containsKey(name)) {
            PluginsListEntry selected = entryMap.get(name);
            selected.setForeground(selectionForegroundColor);
            selected.setBackground(selectionBackgroundColor);
        }
    }

    boolean isEmpty() {
        return entryMap.isEmpty();
    }

}

@@ -1066,18 +1066,16 @@
 inArray)
- %7B
 %0A       
@@ -1083,32 +1083,38 @@
     
-PluginsListEntry entry =
+entryMap.put(plugin.getName(),
  new
@@ -1144,16 +1144,17 @@
 n, this)
+)
 ;%0A      
@@ -1159,50 +1159,56 @@
     
-    entryMap.put(plugin.getName(), entry);
+for (PluginsListEntry entry : entryMap.values())
 %0A   
@@ -1228,26 +1228,16 @@
 entry);%0A
-        %7D%0A
         
@@ -1264,18 +1264,16 @@
 th != 0)
- %7B
 %0A       
@@ -1315,26 +1315,16 @@
 ame());%0A
-        %7D%0A
     %7D%0A%0A 

Order plugins